This commit is contained in:
陈向学 2024-08-28 16:08:13 +08:00
parent 9e83a5e606
commit afed813ff8
11 changed files with 116 additions and 47 deletions

View File

@ -14,11 +14,6 @@ public class Device_Base : PermanentTriggerBase
/// </summary> /// </summary>
public Func<string,bool,int> triggerAction; public Func<string,bool,int> triggerAction;
/// <summary>
/// 打分事件
/// </summary>
public Action<string, object, int, int> scoreAction;
private Vector3 head_LocalPos; private Vector3 head_LocalPos;
private Vector3 head_LocalEulerAnglesl; private Vector3 head_LocalEulerAnglesl;
@ -28,7 +23,6 @@ public class Device_Base : PermanentTriggerBase
{ {
base.OnStart(); base.OnStart();
AddTriggerAction(GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID); AddTriggerAction(GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID);
AddScoreAction(ScoreManager.instance.Check);
} }
} }
@ -53,10 +47,6 @@ public class Device_Base : PermanentTriggerBase
{ {
this.triggerAction = action; this.triggerAction = action;
} }
public void AddScoreAction(Action<string, object, int, int> back)
{
this.scoreAction = back;
}
/// <summary> /// <summary>
/// 设置工具回到手中的位置 /// 设置工具回到手中的位置

View File

@ -35,7 +35,7 @@ public abstract class ScoreBase : MonoBehaviour
/// <summary> /// <summary>
/// 判分 /// 判分
/// </summary> /// </summary>
public virtual void CheckScore() public virtual void CheckScore(string triggerName,object para)
{ {
} }

View File

@ -31,6 +31,6 @@ public class ScoreManager : MonoBehaviour
if (schemeid == 0) if (schemeid == 0)
schemeid = GameManager.RunModelMgr.schemeID; schemeid = GameManager.RunModelMgr.schemeID;
scoreSubjectList.Find(a => a.systemId == systemctlid && a.schemeId == schemeid)?.CheckScore(); scoreSubjectList.Find(a => a.systemId == systemctlid && a.schemeId == schemeid)?.CheckScore(triggerName, para);
} }
} }

View File

@ -4,6 +4,10 @@ using UnityEngine;
public class ScoreSubjectStep public class ScoreSubjectStep
{ {
/// <summary>
/// 步骤id
/// </summary>
public int subProcessId;
/// <summary> /// <summary>
/// 步骤满分 /// 步骤满分
/// </summary> /// </summary>
@ -11,19 +15,46 @@ public class ScoreSubjectStep
/// <summary> /// <summary>
/// 步骤得分 /// 步骤得分
/// </summary> /// </summary>
float currentScore; float currentScore=0;
/// <summary> /// <summary>
/// 步骤是否已完成 /// 步骤是否已完成
/// </summary> /// </summary>
bool isDone; bool isDone;
public ScoreSubjectStep(int subProcessId,float maxScore)
{
this.subProcessId = subProcessId;
this.maxScore = maxScore;
}
public ScoreSubjectStep(float maxScore) public ScoreSubjectStep(float maxScore)
{ {
this.maxScore = maxScore; this.maxScore = maxScore;
} }
public void SetScore(float score) /// <summary>
/// 得全或扣光
/// </summary>
/// <param name="AllScore"></param>
public void SetScore(bool AllScore)
{
if (!isDone)
{ {
isDone = true; isDone = true;
currentScore = (AllScore ? maxScore : 0);
Debug.Log(string.Format("打分:{0} 得分:{1}", subProcessId, currentScore));
}
}
/// <summary>
/// 百分比分数
/// </summary>
/// <param name="scaleScore"></param>
public void SetScore(float scaleScore)
{
if (!isDone)
{
isDone = true;
currentScore = scaleScore*maxScore;
Debug.Log(string.Format("打分:{0} 得分:{1}", subProcessId, currentScore));
}
} }
} }

View File

@ -1,5 +1,6 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using UnityEngine; using UnityEngine;
public class Score_1002 : ScoreBase public class Score_1002 : ScoreBase
@ -10,30 +11,65 @@ public class Score_1002 : ScoreBase
public override void Init() public override void Init()
{ {
base.Init(); base.Init();
List<ScoreSubjectStep> tmps= new List<ScoreSubjectStep>();
tmps.Add(new ScoreSubjectStep(3001, 0));
tmps.Add(new ScoreSubjectStep(3002,0));
tmps.Add(new ScoreSubjectStep(3003,5));
tmps.Add(new ScoreSubjectStep(3004,5));
tmps.Add(new ScoreSubjectStep(3005, 5));
tmps.Add(new ScoreSubjectStep(3006, 10));
tmps.Add(new ScoreSubjectStep(3007, 5));
tmps.Add(new ScoreSubjectStep(3008, 0));
tmps.Add(new ScoreSubjectStep(3009, 3));
tmps.Add(new ScoreSubjectStep(3010,4));
tmps.Add(new ScoreSubjectStep(3011, 3));
tmps.Add(new ScoreSubjectStep(3012, 20));
tmps.Add(new ScoreSubjectStep(3013, 20));
tmps.Add(new ScoreSubjectStep(3014, 5));
tmps.Add(new ScoreSubjectStep(3015, 5));
tmps.Add(new ScoreSubjectStep(3016, 3));
tmps.Add(new ScoreSubjectStep(3017, 4));
tmps.Add(new ScoreSubjectStep(3018, 3));
steps = new Dictionary<int, ScoreSubjectStep>(); steps = new Dictionary<int, ScoreSubjectStep>();
steps.Add(3001, new ScoreSubjectStep(0)); tmps.ForEach(a =>
steps.Add(3002, new ScoreSubjectStep(0)); {
steps.Add(3003, new ScoreSubjectStep(5)); steps.Add(a.subProcessId, a);
steps.Add(3004, new ScoreSubjectStep(5)); });
steps.Add(3005, new ScoreSubjectStep(5));
steps.Add(3006, new ScoreSubjectStep(10));
steps.Add(3007, new ScoreSubjectStep(5));
steps.Add(3008, new ScoreSubjectStep(0));
steps.Add(3009, new ScoreSubjectStep(3));
steps.Add(3010, new ScoreSubjectStep(4));
steps.Add(3011, new ScoreSubjectStep(3));
steps.Add(3012, new ScoreSubjectStep(20));
steps.Add(3013, new ScoreSubjectStep(20));
steps.Add(3014, new ScoreSubjectStep(5));
steps.Add(3015, new ScoreSubjectStep(5));
steps.Add(3016, new ScoreSubjectStep(3));
steps.Add(3017, new ScoreSubjectStep(4));
steps.Add(3018, new ScoreSubjectStep(3));
} }
public override void CheckScore() public override void CheckScore(string triggerName, object para)
{ {
base.CheckScore(); base.CheckScore(triggerName, para);
if(triggerName =="手机")
{
if(para.ToString()== "任务接受完成")
{
steps[3001].SetScore(true);
}
else if(para.ToString()== "任务接受完成")
{
steps[3002].SetScore(true);
}
}
else if (triggerName == "现场按钮")
{
//检查是否穿戴
float tmp = 0;
tmp +=(PacksackBagMgr.Instance.wearDic.ContainsKey("国网安全帽") ? 0.25f : 0);
tmp += (PacksackBagMgr.Instance.wearDic.ContainsKey("工作服") ? 0.25f : 0);
tmp += (PacksackBagMgr.Instance.wearDic.ContainsKey("绝缘手套") ? 0.25f : 0);
tmp += (PacksackBagMgr.Instance.wearDic.ContainsKey("绝缘靴") ? 0.25f : 0);
steps[3003].SetScore(tmp);
//检查背包是否携带
string[] shoudleTools = new string[] { "剥线钳", "绝缘螺丝刀", "验电笔", "工作证", "盒装封印", "绝缘胶带", "三相四线电能表", "国网安全帽", "工作服", "绝缘手套", "绝缘靴" };
float tmp2 = 1;
shoudleTools.ToList().ForEach(a =>
{
tmp2 -= (PacksackBagMgr.Instance.toolAndMaterialDic.ContainsKey(a) ? 0 : 0.1f);
});
steps[3004].SetScore(Mathf.Clamp01(tmp2));
}
} }
} }

View File

@ -18,10 +18,7 @@ public class Tool_Base : PermanentTriggerBase
/// trigger触发事件 /// trigger触发事件
/// </summary> /// </summary>
public Func<string, bool, int> triggerAction; public Func<string, bool, int> triggerAction;
/// <summary>
/// 打分事件
/// </summary>
public Action<string, object, int, int> scoreAction;
private Vector3 head_LocalPos; private Vector3 head_LocalPos;
private Vector3 head_LocalEulerAnglesl; private Vector3 head_LocalEulerAnglesl;
@ -32,7 +29,6 @@ public class Tool_Base : PermanentTriggerBase
{ {
base.OnStart(); base.OnStart();
AddTriggerAction(GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID); AddTriggerAction(GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID);
AddScoreAction(ScoreManager.instance.Check);
} }
} }
protected override void OnMEnter() protected override void OnMEnter()
@ -58,10 +54,6 @@ public class Tool_Base : PermanentTriggerBase
this.triggerAction = action; this.triggerAction = action;
} }
public void AddScoreAction(Action<string, object, int, int> back)
{
this.scoreAction = back;
}
/// <summary> /// <summary>
/// 设置工具回到手中的位置 /// 设置工具回到手中的位置
/// </summary> /// </summary>

View File

@ -10,7 +10,7 @@ public class PacksackBagMgr : BaseManager<PacksackBagMgr>
/// <summary> /// <summary>
/// 背包里所有东西 /// 背包里所有东西
/// </summary> /// </summary>
private Dictionary<string, List<ItemInfo>> toolAndMaterialDic = new Dictionary<string, List<ItemInfo>>(); public Dictionary<string, List<ItemInfo>> toolAndMaterialDic = new Dictionary<string, List<ItemInfo>>();
/// <summary> /// <summary>
/// 已经穿戴 /// 已经穿戴
/// </summary> /// </summary>

View File

@ -40,7 +40,11 @@ public class MobileController : PermanentTriggerBase
{ {
GameManager.UIMgr.ShowPanel<UI_CustomSessionPanel>(E_UI_Layer.Mid, (panel) => GameManager.UIMgr.ShowPanel<UI_CustomSessionPanel>(E_UI_Layer.Mid, (panel) =>
{ {
panel.Init(triggerID, "好的", (intTemp) => { GameManager.UIMgr.HidePanel<UI_CustomSessionPanel>(); }); panel.Init(triggerID, "好的", (intTemp) =>
{
ScoreManager.instance.Check(triggerName, "工作预约完成");
GameManager.UIMgr.HidePanel<UI_CustomSessionPanel>();
});
}); });
} }
} }

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using UnityEngine; using UnityEngine;
using HighlightPlus; using HighlightPlus;
using UnityEngine.EventSystems; using UnityEngine.EventSystems;
using System;
/// <summary> /// <summary>
/// ³£×¤½»»¥ /// ³£×¤½»»¥
@ -12,9 +13,16 @@ public class PermanentTriggerBase : MonoBehaviour
public int triggerID; public int triggerID;
public string triggerName; public string triggerName;
public HighlightEffect _highlight; public HighlightEffect _highlight;
/// <summary>
/// 打分事件
/// </summary>
public Action<string, object, int, int> scoreAction;
private void Awake() private void Awake()
{ {
OnAwake(); OnAwake();
AddScoreAction(ScoreManager.instance.Check);
} }
private void Start() private void Start()
@ -87,4 +95,9 @@ public class PermanentTriggerBase : MonoBehaviour
//{ //{
// GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID); // GameManager.EventMgr.RemoveEventListener<string>(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID);
//} //}
public void AddScoreAction(Action<string, object, int, int> back)
{
this.scoreAction = back;
}
} }

View File

@ -184,6 +184,8 @@ public class UI_MenuBar : BasePanel
{ {
panel.Init(); panel.Init();
GameManager.EventMgr.EventTrigger<float>(Enum_EventType.UpdateProgress, 0.1f); GameManager.EventMgr.EventTrigger<float>(Enum_EventType.UpdateProgress, 0.1f);
//判分
ScoreManager.instance.Check(siteName, null);
GameManager.ScenesMgr.LoadSceneAsyn("05_LiveScene", () => GameManager.ScenesMgr.LoadSceneAsyn("05_LiveScene", () =>
{ {
GameManager.EventMgr.EventTrigger<float>(Enum_EventType.UpdateProgress, 0.9f); GameManager.EventMgr.EventTrigger<float>(Enum_EventType.UpdateProgress, 0.9f);

View File

@ -17,6 +17,7 @@ public class UI_ReceiveTaskPanel : BasePanel
case "Button_Accept": case "Button_Accept":
if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(triggerName, true) == 0) if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(triggerName, true) == 0)
{ {
ScoreManager.instance.Check(triggerName, "任务接受完成");
//GameManager.ProcessMgr.CheckSubProcessSteps(GameManager.ProcessMgr.subProcessStepId); //GameManager.ProcessMgr.CheckSubProcessSteps(GameManager.ProcessMgr.subProcessStepId);
GameManager.UIMgr.HidePanel<UI_ReceiveTaskPanel>(); GameManager.UIMgr.HidePanel<UI_ReceiveTaskPanel>();
} }