This commit is contained in:
陈向学 2024-08-29 11:38:23 +08:00
parent d965c009e1
commit bbbdd24351
7 changed files with 193 additions and 18 deletions

View File

@ -188,6 +188,7 @@ public class Device_3Phase4WireMeter : Device_Base
Debug.Log("电能表已拆除"); Debug.Log("电能表已拆除");
transform.DOLocalMove(transform.localPosition - new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() => transform.DOLocalMove(transform.localPosition - new Vector3(0, 0.2f, 0.2f), 2).OnComplete(() =>
{ {
CallScoreAction(false);
gameObject.SetActive(false); gameObject.SetActive(false);
}); });
} }
@ -209,6 +210,7 @@ public class Device_3Phase4WireMeter : Device_Base
{ {
LiveSceneManager.Instance.currentTool = null; LiveSceneManager.Instance.currentTool = null;
Debug.Log("电能表已安装"); Debug.Log("电能表已安装");
CallScoreAction(true);
}); });
} }
} }

View File

@ -48,6 +48,7 @@ public class Device_NamePlate : Device_Base
tip2.Init("核对和抄录完成!"); tip2.Init("核对和抄录完成!");
} }
int state = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)); int state = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
CallScoreAction();
} }
}); });
} }

View File

@ -19,7 +19,7 @@ public class ScoreSubjectStep
/// <summary> /// <summary>
/// 步骤是否已完成 /// 步骤是否已完成
/// </summary> /// </summary>
bool isDone; public bool isDone;
public ScoreSubjectStep(int subProcessId,float maxScore) public ScoreSubjectStep(int subProcessId,float maxScore)
{ {
@ -35,9 +35,10 @@ public class ScoreSubjectStep
/// 得全或扣光 /// 得全或扣光
/// </summary> /// </summary>
/// <param name="AllScore"></param> /// <param name="AllScore"></param>
public void SetScore(bool AllScore) /// <param name="canRepeat">是否可以重复打分</param>
public void SetScore(bool AllScore,bool canRepeat=false)
{ {
if (!isDone) if (!isDone || canRepeat)
{ {
isDone = true; isDone = true;
currentScore = (AllScore ? maxScore : 0); currentScore = (AllScore ? maxScore : 0);
@ -48,9 +49,9 @@ public class ScoreSubjectStep
/// 百分比分数 /// 百分比分数
/// </summary> /// </summary>
/// <param name="scaleScore"></param> /// <param name="scaleScore"></param>
public void SetScore(float scaleScore) public void SetScore(float scaleScore, bool canRepeat=false)
{ {
if (!isDone) if (!isDone || canRepeat)
{ {
isDone = true; isDone = true;
currentScore = scaleScore*maxScore; currentScore = scaleScore*maxScore;

View File

@ -1,6 +1,7 @@
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
public class Score_1002 : ScoreBase public class Score_1002 : ScoreBase
@ -47,7 +48,43 @@ public class Score_1002 : ScoreBase
/// <summary> /// <summary>
/// 开关验电 /// 开关验电
/// </summary> /// </summary>
List<string> TestInSwitchList=new List<string>(); List<string> InSwitchCloseYDList=new List<string>();
/// <summary>
/// 拆除接线顺序
/// </summary>
List<string> unInstallJieXian=new List<string>()
{
"A_in_螺丝up", "A_in_螺丝down", "A_in_线",
"B_in_螺丝up","B_in_螺丝down","B_in_线",
"C_in_螺丝up","C_in_螺丝down","C_in_线",
"A_out_螺丝up","A_out_螺丝down","A_out_线",
"B_out_螺丝up","B_out_螺丝down","B_out_线",
"C_out_螺丝up","C_out_螺丝down","C_out_线",
"零_地_螺丝up","零_地_螺丝down","零_地_线",
"零_out_螺丝up","零_out_螺丝down","零_out_线"
};
/// <summary>
/// 拆除接线螺丝操作
/// </summary>
List<string> currentunInstallJieXian = new List<string>();
/// <summary>
/// 安装接线螺丝顺序
/// </summary>
List<string> installJieXian = new List<string>()
{
"零_out_线","零_out_螺丝up","零_out_螺丝down",
"零_地_线","零_地_螺丝up","零_地_螺丝down",
"C_out_线","C_out_螺丝up","C_out_螺丝down",
"B_out_线","B_out_螺丝up","B_out_螺丝down",
"A_out_线","A_out_螺丝up","A_out_螺丝down",
"C_in_线","C_in_螺丝up","C_in_螺丝down",
"B_in_线","B_in_螺丝up","B_in_螺丝down",
"A_in_线","A_in_螺丝up", "A_in_螺丝down"
};
/// <summary>
/// 安装接线螺丝操作
/// </summary>
List<string> currentInstallJieXian = new List<string>();
public override void CheckScore(string triggerName, object para) public override void CheckScore(string triggerName, object para)
{ {
base.CheckScore(triggerName, para); base.CheckScore(triggerName, para);
@ -95,15 +132,16 @@ public class Score_1002 : ScoreBase
{ {
if ((bool)para) if ((bool)para)
{ {
//接线检查打分 //3012之前时拆除流程之后时安装流程
//判断验电是否正确 if (!steps[3012].isDone)
if (isCheckE())
{ {
steps[3009].SetScore(true); //接线检查打分,判断三步验电是否正确
steps[3009].SetScore(isCheckE());
} }
else else
{ {
//安装检查
steps[3014].SetScore(true);
} }
} }
} }
@ -114,10 +152,74 @@ public class Score_1002 : ScoreBase
} }
else if (triggerName == "验电笔+in开关_螺丝1" || triggerName == "验电笔+in开关_螺丝2" || triggerName == "验电笔+in开关_螺丝3") else if (triggerName == "验电笔+in开关_螺丝1" || triggerName == "验电笔+in开关_螺丝2" || triggerName == "验电笔+in开关_螺丝3")
{ {
if(SiteManager.instance.measuringCabinet.inSwitch.isOpen==false) //3012之前是拆除之后是安装
if (!steps[3012].isDone)
{ {
TestInSwitchList.Add(triggerName); //断电情况下
isInSwitchCheckE(); if (SiteManager.instance.measuringCabinet.inSwitch.isOpen == false)
{
InSwitchCloseYDList.Add(triggerName);
steps[3010].SetScore(isInSwitchCheckE());
}
}
else
{
//通电情况下
if (SiteManager.instance.measuringCabinet.inSwitch.isOpen==true)
{
}
}
}
else if(triggerName == "电能表铭牌")
{
steps[3011].SetScore(true);
}
else if(unInstallJieXian.Contains(triggerName))
{
//3012之前是拆除之后是安装
//接线螺丝和线
if (!steps[3012].isDone)
{
//判断拆接线
if ((bool)para)
currentunInstallJieXian.Remove(triggerName);
else
currentunInstallJieXian.Add(triggerName);
}
else
{
//判断安装接线
if ((bool)para)
currentInstallJieXian.Add(triggerName);
else
currentInstallJieXian.Remove(triggerName);
//判分
if (triggerName.Contains("A_in_螺丝"))
{
steps[3013].SetScore(IsInstallJieXianCheckE(), true);
}
}
}
else if(triggerName== "电能表区域碰撞")
{
//取下电能表时判断验电顺序
if(!(bool)para)
{
steps[3012].SetScore(IsUninstallJieXianCheckE());
}
}
else if(triggerName.Contains("电能表拆装螺丝"))
{
//安装流程下
if (steps[3012].isDone)
{
//拆装螺丝
if ((bool)para)
currentInstallJieXian.Add(triggerName);
else
currentInstallJieXian.Remove(triggerName);
} }
} }
} }
@ -165,7 +267,7 @@ public class Score_1002 : ScoreBase
/// <returns></returns> /// <returns></returns>
private bool isInSwitchCheckE() private bool isInSwitchCheckE()
{ {
if (TestInSwitchList.Contains("验电笔+in开关_螺丝1") && TestInSwitchList.Contains("验电笔+in开关_螺丝2") && TestInSwitchList.Contains("验电笔+in开关_螺丝2")) if (InSwitchCloseYDList.Contains("验电笔+in开关_螺丝1") && InSwitchCloseYDList.Contains("验电笔+in开关_螺丝2") && InSwitchCloseYDList.Contains("验电笔+in开关_螺丝2"))
{ {
return true; return true;
} }
@ -174,4 +276,59 @@ public class Score_1002 : ScoreBase
return false; return false;
} }
} }
/// <summary>
/// 判断拆接线顺序
/// </summary>
/// <returns></returns>
private bool IsUninstallJieXianCheckE()
{
if(currentunInstallJieXian.Count!= unInstallJieXian.Count)
{
return false;
}
//一一比对
for (int i = 0; i < currentunInstallJieXian.Count; i++)
{
if (currentunInstallJieXian[i] != unInstallJieXian[i])
{
return false;
}
}
return true;
}
/// <summary>
/// 判断安装接线顺序
/// </summary>
/// <returns></returns>
public bool IsInstallJieXianCheckE()
{
if(!currentInstallJieXian.Contains("电能表拆装螺丝1") || !currentInstallJieXian.Contains("电能表拆装螺丝2"))
return false;
if (currentInstallJieXian.Count < currentInstallJieXian.Count+2)
{
return false;
}
//一一比对
string[] tmps=new string[currentInstallJieXian.Count];
currentInstallJieXian.CopyTo(tmps);
var tmplist=tmps.ToList();
tmplist.Remove("电能表拆装螺丝1");
tmplist.Remove("电能表拆装螺丝2");
for (int i = 0; i < tmplist.Count; i++)
{
if (tmplist[i] != installJieXian[i])
{
return false;
}
}
return true;
}
} }

View File

@ -57,6 +57,7 @@ public class Tool_Line: Tool_Base
isConnected = false; isConnected = false;
actionBack?.Invoke(isConnected); actionBack?.Invoke(isConnected);
int state = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)); int state = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
CallScoreAction(false);
}); });
} }
} }
@ -70,6 +71,7 @@ public class Tool_Line: Tool_Base
isConnected = true; isConnected = true;
actionBack?.Invoke(isConnected); actionBack?.Invoke(isConnected);
int state = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true)); int state = (triggerAction == null ? 0 : triggerAction.Invoke(triggerName, true));
CallScoreAction(true);
}); });
} }
} }

View File

@ -85,6 +85,8 @@ public class Tool_Screw : Tool_Base
isMoving = false; isMoving = false;
installAction?.Invoke(true); installAction?.Invoke(true);
screwdriver.ReBackHead(); screwdriver.ReBackHead();
screwdriver.isUseing = false;
CallScoreAction(true);
}); });
}); });
} }
@ -120,6 +122,8 @@ public class Tool_Screw : Tool_Base
isMoving = false; isMoving = false;
installAction?.Invoke(false); installAction?.Invoke(false);
screwdriver.ReBackHead(); screwdriver.ReBackHead();
screwdriver.isUseing = false;
CallScoreAction(false);
}); });
}); });
} }

View File

@ -8,6 +8,12 @@ using UnityEngine;
/// </summary> /// </summary>
public class Tool_Screwdriver : Tool_Base public class Tool_Screwdriver : Tool_Base
{ {
/// <summary>
/// 正在使用
/// </summary>
[HideInInspector]
public bool isUseing;
/// <summary> /// <summary>
/// 开始安装螺丝 /// 开始安装螺丝
/// </summary> /// </summary>
@ -16,6 +22,7 @@ public class Tool_Screwdriver : Tool_Base
{ {
if (!screw.isInstall) if (!screw.isInstall)
{ {
isUseing = true;
screw.BeInstalled(this); screw.BeInstalled(this);
} }
} }
@ -28,13 +35,14 @@ public class Tool_Screwdriver : Tool_Base
{ {
if (screw.isInstall) if (screw.isInstall)
{ {
isUseing = true;
screw.BeUnInstalled(this); screw.BeUnInstalled(this);
} }
} }
private void Update() private void Update()
{ {
if (Input.GetMouseButtonDown(0)) if (Input.GetMouseButtonDown(0) && !isUseing)
{ {
//点击螺丝验电 //点击螺丝验电
Ray tmpray = Camera.main.ScreenPointToRay(Input.mousePosition); Ray tmpray = Camera.main.ScreenPointToRay(Input.mousePosition);