diff --git a/Assets/Scripts/CXX/Devices/Device_Base.cs b/Assets/Scripts/CXX/Devices/Device_Base.cs index 5ba38cf..31e18f8 100644 --- a/Assets/Scripts/CXX/Devices/Device_Base.cs +++ b/Assets/Scripts/CXX/Devices/Device_Base.cs @@ -14,11 +14,6 @@ public class Device_Base : PermanentTriggerBase /// public Func triggerAction; - /// - /// 打分事件 - /// - public Action scoreAction; - private Vector3 head_LocalPos; private Vector3 head_LocalEulerAnglesl; @@ -28,7 +23,6 @@ public class Device_Base : PermanentTriggerBase { base.OnStart(); AddTriggerAction(GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID); - AddScoreAction(ScoreManager.instance.Check); } } @@ -53,10 +47,6 @@ public class Device_Base : PermanentTriggerBase { this.triggerAction = action; } - public void AddScoreAction(Action back) - { - this.scoreAction = back; - } /// /// 设置工具回到手中的位置 diff --git a/Assets/Scripts/CXX/Score/ScoreBase.cs b/Assets/Scripts/CXX/Score/ScoreBase.cs index ff41794..addbc8f 100644 --- a/Assets/Scripts/CXX/Score/ScoreBase.cs +++ b/Assets/Scripts/CXX/Score/ScoreBase.cs @@ -35,7 +35,7 @@ public abstract class ScoreBase : MonoBehaviour /// /// 判分 /// - public virtual void CheckScore() + public virtual void CheckScore(string triggerName,object para) { } diff --git a/Assets/Scripts/CXX/Score/ScoreManager.cs b/Assets/Scripts/CXX/Score/ScoreManager.cs index 746132a..6943b74 100644 --- a/Assets/Scripts/CXX/Score/ScoreManager.cs +++ b/Assets/Scripts/CXX/Score/ScoreManager.cs @@ -31,6 +31,6 @@ public class ScoreManager : MonoBehaviour if (schemeid == 0) 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); } } diff --git a/Assets/Scripts/CXX/Score/ScoreSubjectStep.cs b/Assets/Scripts/CXX/Score/ScoreSubjectStep.cs index 1a70440..0c5637a 100644 --- a/Assets/Scripts/CXX/Score/ScoreSubjectStep.cs +++ b/Assets/Scripts/CXX/Score/ScoreSubjectStep.cs @@ -4,6 +4,10 @@ using UnityEngine; public class ScoreSubjectStep { + /// + /// 步骤id + /// + public int subProcessId; /// /// 步骤满分 /// @@ -11,19 +15,46 @@ public class ScoreSubjectStep /// /// 步骤得分 /// - float currentScore; + float currentScore=0; /// /// 步骤是否已完成 /// bool isDone; + public ScoreSubjectStep(int subProcessId,float maxScore) + { + this.subProcessId = subProcessId; + this.maxScore = maxScore; + } + public ScoreSubjectStep(float maxScore) { this.maxScore = maxScore; } - public void SetScore(float score) + /// + /// 得全或扣光 + /// + /// + public void SetScore(bool AllScore) { - isDone = true; - + if (!isDone) + { + isDone = true; + currentScore = (AllScore ? maxScore : 0); + Debug.Log(string.Format("打分:{0} 得分:{1}", subProcessId, currentScore)); + } + } + /// + /// 百分比分数 + /// + /// + public void SetScore(float scaleScore) + { + if (!isDone) + { + isDone = true; + currentScore = scaleScore*maxScore; + Debug.Log(string.Format("打分:{0} 得分:{1}", subProcessId, currentScore)); + } } } diff --git a/Assets/Scripts/CXX/Score/Score_1002.cs b/Assets/Scripts/CXX/Score/Score_1002.cs index 5681aa2..c1a9c5c 100644 --- a/Assets/Scripts/CXX/Score/Score_1002.cs +++ b/Assets/Scripts/CXX/Score/Score_1002.cs @@ -1,5 +1,6 @@ using System.Collections; using System.Collections.Generic; +using System.Linq; using UnityEngine; public class Score_1002 : ScoreBase @@ -10,30 +11,65 @@ public class Score_1002 : ScoreBase public override void Init() { base.Init(); + List tmps= new List(); + 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(); - steps.Add(3001, new ScoreSubjectStep(0)); - steps.Add(3002, new ScoreSubjectStep(0)); - steps.Add(3003, new ScoreSubjectStep(5)); - 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)); + tmps.ForEach(a => + { + steps.Add(a.subProcessId, a); + }); } - 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)); + } } } diff --git a/Assets/Scripts/CXX/Tools/Tool_Base.cs b/Assets/Scripts/CXX/Tools/Tool_Base.cs index 4c315be..2732093 100644 --- a/Assets/Scripts/CXX/Tools/Tool_Base.cs +++ b/Assets/Scripts/CXX/Tools/Tool_Base.cs @@ -18,10 +18,7 @@ public class Tool_Base : PermanentTriggerBase /// trigger触发事件 /// public Func triggerAction; - /// - /// 打分事件 - /// - public Action scoreAction; + private Vector3 head_LocalPos; private Vector3 head_LocalEulerAnglesl; @@ -32,7 +29,6 @@ public class Tool_Base : PermanentTriggerBase { base.OnStart(); AddTriggerAction(GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID); - AddScoreAction(ScoreManager.instance.Check); } } protected override void OnMEnter() @@ -58,10 +54,6 @@ public class Tool_Base : PermanentTriggerBase this.triggerAction = action; } - public void AddScoreAction(Action back) - { - this.scoreAction = back; - } /// /// 设置工具回到手中的位置 /// diff --git a/Assets/Scripts/Project/Manager/PacksackBagMgr.cs b/Assets/Scripts/Project/Manager/PacksackBagMgr.cs index d49ad43..50e9405 100644 --- a/Assets/Scripts/Project/Manager/PacksackBagMgr.cs +++ b/Assets/Scripts/Project/Manager/PacksackBagMgr.cs @@ -10,7 +10,7 @@ public class PacksackBagMgr : BaseManager /// /// 鑳屽寘閲屾墍鏈変笢瑗 /// - private Dictionary> toolAndMaterialDic = new Dictionary>(); + public Dictionary> toolAndMaterialDic = new Dictionary>(); /// /// 宸茬粡绌挎埓 /// diff --git a/Assets/Scripts/Project/Objects/Other/MobileController.cs b/Assets/Scripts/Project/Objects/Other/MobileController.cs index e333ab8..14bfa9a 100644 --- a/Assets/Scripts/Project/Objects/Other/MobileController.cs +++ b/Assets/Scripts/Project/Objects/Other/MobileController.cs @@ -40,7 +40,11 @@ public class MobileController : PermanentTriggerBase { GameManager.UIMgr.ShowPanel(E_UI_Layer.Mid, (panel) => { - panel.Init(triggerID, "好的", (intTemp) => { GameManager.UIMgr.HidePanel(); }); + panel.Init(triggerID, "好的", (intTemp) => + { + ScoreManager.instance.Check(triggerName, "工作预约完成"); + GameManager.UIMgr.HidePanel(); + }); }); } } diff --git a/Assets/Scripts/Project/Objects/Other/PermanentTriggerBase.cs b/Assets/Scripts/Project/Objects/Other/PermanentTriggerBase.cs index 37f3d38..cf5d327 100644 --- a/Assets/Scripts/Project/Objects/Other/PermanentTriggerBase.cs +++ b/Assets/Scripts/Project/Objects/Other/PermanentTriggerBase.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using UnityEngine; using HighlightPlus; using UnityEngine.EventSystems; +using System; /// /// 常驻交互 @@ -12,9 +13,16 @@ public class PermanentTriggerBase : MonoBehaviour public int triggerID; public string triggerName; public HighlightEffect _highlight; + + /// + /// 打分事件 + /// + public Action scoreAction; + private void Awake() { OnAwake(); + AddScoreAction(ScoreManager.instance.Check); } private void Start() @@ -87,4 +95,9 @@ public class PermanentTriggerBase : MonoBehaviour //{ // GameManager.EventMgr.RemoveEventListener(Enum_EventType.SwitchSubProcessStepTriggerID, SwitchSubProcessStepTriggerID); //} + + public void AddScoreAction(Action back) + { + this.scoreAction = back; + } } diff --git a/Assets/Scripts/Project/UI/UI_Panel/UI_MenuBar.cs b/Assets/Scripts/Project/UI/UI_Panel/UI_MenuBar.cs index 0c29e8b..57c9e35 100644 --- a/Assets/Scripts/Project/UI/UI_Panel/UI_MenuBar.cs +++ b/Assets/Scripts/Project/UI/UI_Panel/UI_MenuBar.cs @@ -184,6 +184,8 @@ public class UI_MenuBar : BasePanel { panel.Init(); GameManager.EventMgr.EventTrigger(Enum_EventType.UpdateProgress, 0.1f); + //判分 + ScoreManager.instance.Check(siteName, null); GameManager.ScenesMgr.LoadSceneAsyn("05_LiveScene", () => { GameManager.EventMgr.EventTrigger(Enum_EventType.UpdateProgress, 0.9f); diff --git a/Assets/Scripts/Project/UI/UI_Panel/UI_ReceiveTaskPanel.cs b/Assets/Scripts/Project/UI/UI_Panel/UI_ReceiveTaskPanel.cs index 30f2327..55712c4 100644 --- a/Assets/Scripts/Project/UI/UI_Panel/UI_ReceiveTaskPanel.cs +++ b/Assets/Scripts/Project/UI/UI_Panel/UI_ReceiveTaskPanel.cs @@ -17,6 +17,7 @@ public class UI_ReceiveTaskPanel : BasePanel case "Button_Accept": if (GameManager.ProcessMgr.IsRightSubProcessStepsTriggerID(triggerName, true) == 0) { + ScoreManager.instance.Check(triggerName, "任务接受完成"); //GameManager.ProcessMgr.CheckSubProcessSteps(GameManager.ProcessMgr.subProcessStepId); GameManager.UIMgr.HidePanel(); }