2096 lines
89 KiB
C#
2096 lines
89 KiB
C#
using DefaultNamespace.ProcessMode;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using DefaultNamespace;
|
||
using MotionFramework;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using static InterfaceManager;
|
||
|
||
/// <summary>
|
||
/// 模型处理器接口 - 用于处理不同模型的特定逻辑
|
||
/// </summary>
|
||
public interface IModelProcessor
|
||
{
|
||
/// <summary>
|
||
/// 处理模型检查逻辑
|
||
/// </summary>
|
||
/// <param name="model">模型GameObject</param>
|
||
/// <param name="materialCheck">物料检查信息</param>
|
||
/// <param name="checkGood">检查组件</param>
|
||
void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 10kV变压器处理器
|
||
/// </summary>
|
||
public class Transformer10kVProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活10kV变压器模型
|
||
ModerController.SetChildActive(model.transform, "10kV变压器", true);
|
||
// 确保10kV电缆终端模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示10kV变压器");
|
||
}
|
||
else
|
||
{
|
||
// 激活10kV电缆终端模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保10kV变压器模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV变压器", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform transformer = ModerController.FindChild(model.transform, "10kV变压器");
|
||
Transform cableTerminal = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果10kV变压器是激活的,设置其好状态
|
||
if (transformer != null && transformer.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(transformer, "10kV变压器_坏", false);
|
||
ModerController.SetChildActive(transformer, "10kV变压器_好", true);
|
||
Debug.Log("10kV变压器外观正常");
|
||
}
|
||
// 如果10kV电缆终端是激活的,设置其好状态
|
||
else if (cableTerminal != null && cableTerminal.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(cableTerminal, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(cableTerminal, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果10kV变压器是激活的,设置其坏状态
|
||
if (transformer != null && transformer.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(transformer, "10kV变压器", true);
|
||
ModerController.SetChildActive(transformer, "10kV变压器_好", false);
|
||
Debug.Log("10kV变压器外观破损");
|
||
}
|
||
// 如果10kV电缆终端是激活的,设置其坏状态
|
||
else if (cableTerminal != null && cableTerminal.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(cableTerminal, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(cableTerminal, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 1kV电缆终端处理器
|
||
/// </summary>
|
||
public class CableTerminal1kVProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活1kV电缆终端模型
|
||
ModerController.SetChildActive(model.transform, "1kV电缆终端", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示1kV电缆终端");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保1kV电缆终端模型关闭
|
||
ModerController.SetChildActive(model.transform, "1kV电缆终端", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform cableTerminal = ModerController.FindChild(model.transform, "1kV电缆终端");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果1kV电缆终端是激活的,设置其好状态
|
||
if (cableTerminal != null && cableTerminal.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(cableTerminal, "1kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(cableTerminal, "1kV电缆终端-好", true);
|
||
Debug.Log("1kV电缆终端外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果1kV电缆终端是激活的,设置其坏状态
|
||
if (cableTerminal != null && cableTerminal.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(cableTerminal, "1kV电缆终端", true);
|
||
ModerController.SetChildActive(cableTerminal, "1kV电缆终端-好", false);
|
||
Debug.Log("1kV电缆终端外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 10kV三相隔离开关处理器
|
||
/// </summary>
|
||
public class DisconnectSwitch10kVProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活10kV三相隔离开关模型
|
||
ModerController.SetChildActive(model.transform, "10kV三相隔离开关", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示10kV三相隔离开关");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保10kV三相隔离开关模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV三相隔离开关", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform disconnectSwitch = ModerController.FindChild(model.transform, "10kV三相隔离开关");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果10kV三相隔离开关是激活的,设置其好状态
|
||
if (disconnectSwitch != null && disconnectSwitch.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(disconnectSwitch, "10kV三相隔离开关-坏", false);
|
||
ModerController.SetChildActive(disconnectSwitch, "10kV三相隔离开关-好", true);
|
||
Debug.Log("10kV三相隔离开关外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果10kV三相隔离开关是激活的,设置其坏状态
|
||
if (disconnectSwitch != null && disconnectSwitch.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(disconnectSwitch, "10kV三相隔离开关", true);
|
||
ModerController.SetChildActive(disconnectSwitch, "10kV三相隔离开关-好", false);
|
||
Debug.Log("10kV三相隔离开关外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 10kV电缆终端处理器
|
||
/// </summary>
|
||
public class CableTerminal10kVProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活10kV电缆终端模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "交流盘形悬式瓷绝缘子", false);
|
||
Debug.Log("品类一致 - 显示10kV电缆终端");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "交流盘形悬式瓷绝缘子", true);
|
||
// 确保10kV电缆终端模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类不一致 - 交流盘形悬式瓷绝缘子");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform cableTerminal = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "交流盘形悬式瓷绝缘子");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果10kV电缆终端是激活的,设置其好状态
|
||
if (cableTerminal != null && cableTerminal.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(cableTerminal, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(cableTerminal, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "交流盘形悬式瓷绝缘子-坏", false);
|
||
ModerController.SetChildActive(otherModel, "交流盘形悬式瓷绝缘子-好", true);
|
||
Debug.Log("交流盘形悬式瓷绝缘子");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果10kV电缆终端是激活的,设置其坏状态
|
||
if (cableTerminal != null && cableTerminal.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(cableTerminal, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(cableTerminal, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "交流盘形悬式瓷绝缘子", true);
|
||
ModerController.SetChildActive(otherModel, "交流盘形悬式瓷绝缘子-好", false);
|
||
Debug.Log("交流盘形悬式瓷绝缘子");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 交流盘形悬式瓷绝缘子处理器
|
||
/// </summary>
|
||
public class PorcelainInsulatorProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活交流盘形悬式瓷绝缘子模型
|
||
ModerController.SetChildActive(model.transform, "交流盘形悬式瓷绝缘子", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示交流盘形悬式瓷绝缘子");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保交流盘形悬式瓷绝缘子模型关闭
|
||
ModerController.SetChildActive(model.transform, "交流盘形悬式瓷绝缘子", false);
|
||
Debug.Log("品类不一致 - 10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform insulator = ModerController.FindChild(model.transform, "交流盘形悬式瓷绝缘子");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果交流盘形悬式瓷绝缘子是激活的,设置其好状态
|
||
if (insulator != null && insulator.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(insulator, "交流盘形悬式瓷绝缘子-坏", false);
|
||
ModerController.SetChildActive(insulator, "交流盘形悬式瓷绝缘子-好", true);
|
||
Debug.Log("交流盘形悬式瓷绝缘子外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果交流盘形悬式瓷绝缘子是激活的,设置其坏状态
|
||
if (insulator != null && insulator.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(insulator, "交流盘形悬式瓷绝缘子", true);
|
||
ModerController.SetChildActive(insulator, "交流盘形悬式瓷绝缘子-好", false);
|
||
Debug.Log("交流盘形悬式瓷绝缘子外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 低压电流互感器处理器
|
||
/// </summary>
|
||
public class LowVoltageCurrentTransformerProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活低压电流互感器模型
|
||
ModerController.SetChildActive(model.transform, "低压电流互感器", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示低压电流互感器");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保低压电流互感器模型关闭
|
||
ModerController.SetChildActive(model.transform, "低压电流互感器", false);
|
||
Debug.Log("品类不一致 - 10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform currentTransformer = ModerController.FindChild(model.transform, "低压电流互感器");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果低压电流互感器是激活的,设置其好状态
|
||
if (currentTransformer != null && currentTransformer.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(currentTransformer, "低压电流互感器-坏", false);
|
||
ModerController.SetChildActive(currentTransformer, "低压电流互感器-好", true);
|
||
Debug.Log("低压电流互感器外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果低压电流互感器是激活的,设置其坏状态
|
||
if (currentTransformer != null && currentTransformer.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(currentTransformer, "低压电流互感器", true);
|
||
ModerController.SetChildActive(currentTransformer, "低压电流互感器-好", false);
|
||
Debug.Log("低压电流互感器外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 布电线处理器
|
||
/// </summary>
|
||
public class WireProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活布电线模型
|
||
ModerController.SetChildActive(model.transform, "布电线", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示布电线");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保布电线模型关闭
|
||
ModerController.SetChildActive(model.transform, "布电线", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform wire = ModerController.FindChild(model.transform, "布电线");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果布电线是激活的,设置其好状态
|
||
if (wire != null && wire.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(wire, "布电线-坏", false);
|
||
ModerController.SetChildActive(wire, "布电线-好", true);
|
||
Debug.Log("布电线外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果布电线是激活的,设置其坏状态
|
||
if (wire != null && wire.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(wire, "布电线", true);
|
||
ModerController.SetChildActive(wire, "布电线-好", false);
|
||
Debug.Log("布电线外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 接地短路故障指示器处理器
|
||
/// </summary>
|
||
public class GroundFaultIndicatorProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活接地短路故障指示器模型
|
||
ModerController.SetChildActive(model.transform, "接地短路故障指示器", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示接地短路故障指示器");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保接地短路故障指示器模型关闭
|
||
ModerController.SetChildActive(model.transform, "接地短路故障指示器", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform faultIndicator = ModerController.FindChild(model.transform, "接地短路故障指示器");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果接地短路故障指示器是激活的,设置其好状态
|
||
if (faultIndicator != null && faultIndicator.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(faultIndicator, "接地短路故障指示器-坏", false);
|
||
ModerController.SetChildActive(faultIndicator, "接地短路故障指示器-好", true);
|
||
Debug.Log("接地短路故障指示器外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果接地短路故障指示器是激活的,设置其坏状态
|
||
if (faultIndicator != null && faultIndicator.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(faultIndicator, "接地短路故障指示器", true);
|
||
ModerController.SetChildActive(faultIndicator, "接地短路故障指示器-好", false);
|
||
Debug.Log("接地短路故障指示器外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 接续金具-接地线夹处理器
|
||
/// </summary>
|
||
public class GroundClampProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活接续金具-接地线夹模型
|
||
ModerController.SetChildActive(model.transform, "接续金具-接地线夹", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示接续金具-接地线夹");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保接续金具-接地线夹模型关闭
|
||
ModerController.SetChildActive(model.transform, "接续金具-接地线夹", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform groundClamp = ModerController.FindChild(model.transform, "接续金具-接地线夹");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果接续金具-接地线夹是激活的,设置其好状态
|
||
if (groundClamp != null && groundClamp.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(groundClamp, "接续金具-接地线夹-坏", false);
|
||
ModerController.SetChildActive(groundClamp, "接续金具-接地线夹-好", true);
|
||
Debug.Log("接续金具-接地线夹外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果接续金具-接地线夹是激活的,设置其坏状态
|
||
if (groundClamp != null && groundClamp.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(groundClamp, "接续金具-接地线夹", true);
|
||
ModerController.SetChildActive(groundClamp, "接续金具-接地线夹-好", false);
|
||
Debug.Log("接续金具-接地线夹外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 柱上断路器处理器
|
||
/// </summary>
|
||
public class PoleCircuitBreakerProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活柱上断路器模型
|
||
ModerController.SetChildActive(model.transform, "柱上断路器", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示柱上断路器");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保柱上断路器模型关闭
|
||
ModerController.SetChildActive(model.transform, "柱上断路器", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform circuitBreaker = ModerController.FindChild(model.transform, "柱上断路器");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果柱上断路器是激活的,设置其好状态
|
||
if (circuitBreaker != null && circuitBreaker.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(circuitBreaker, "柱上断路器-坏", false);
|
||
ModerController.SetChildActive(circuitBreaker, "柱上断路器-好", true);
|
||
Debug.Log("柱上断路器外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果柱上断路器是激活的,设置其坏状态
|
||
if (circuitBreaker != null && circuitBreaker.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(circuitBreaker, "柱上断路器", true);
|
||
ModerController.SetChildActive(circuitBreaker, "柱上断路器-好", false);
|
||
Debug.Log("柱上断路器外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 电力电缆处理器
|
||
/// </summary>
|
||
public class PowerCableProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活电力电缆模型
|
||
ModerController.SetChildActive(model.transform, "电力电缆", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示电力电缆");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保电力电缆模型关闭
|
||
ModerController.SetChildActive(model.transform, "电力电缆", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform powerCable = ModerController.FindChild(model.transform, "电力电缆");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果电力电缆是激活的,设置其好状态
|
||
if (powerCable != null && powerCable.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(powerCable, "电力电缆-坏", false);
|
||
ModerController.SetChildActive(powerCable, "电力电缆-好", true);
|
||
Debug.Log("电力电缆外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果电力电缆是激活的,设置其坏状态
|
||
if (powerCable != null && powerCable.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(powerCable, "电力电缆", true);
|
||
ModerController.SetChildActive(powerCable, "电力电缆-好", false);
|
||
Debug.Log("电力电缆外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 电缆分支箱处理器
|
||
/// </summary>
|
||
public class CableBranchBoxProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活电缆分支箱模型
|
||
ModerController.SetChildActive(model.transform, "电缆分支箱", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示电缆分支箱");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保电缆分支箱模型关闭
|
||
ModerController.SetChildActive(model.transform, "电缆分支箱", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform branchBox = ModerController.FindChild(model.transform, "电缆分支箱");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果电缆分支箱是激活的,设置其好状态
|
||
if (branchBox != null && branchBox.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(branchBox, "电缆分支箱-坏", false);
|
||
ModerController.SetChildActive(branchBox, "电缆分支箱-好", true);
|
||
Debug.Log("电缆分支箱外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果电缆分支箱是激活的,设置其坏状态
|
||
if (branchBox != null && branchBox.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(branchBox, "电缆分支箱", true);
|
||
ModerController.SetChildActive(branchBox, "电缆分支箱-好", false);
|
||
Debug.Log("电缆分支箱外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 线路柱式瓷绝缘子处理器
|
||
/// </summary>
|
||
public class LinePorcelainInsulatorProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活线路柱式瓷绝缘子模型
|
||
ModerController.SetChildActive(model.transform, "线路柱式瓷绝缘子", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示线路柱式瓷绝缘子");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保线路柱式瓷绝缘子模型关闭
|
||
ModerController.SetChildActive(model.transform, "线路柱式瓷绝缘子", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform lineInsulator = ModerController.FindChild(model.transform, "线路柱式瓷绝缘子");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果线路柱式瓷绝缘子是激活的,设置其好状态
|
||
if (lineInsulator != null && lineInsulator.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(lineInsulator, "线路柱式瓷绝缘子-坏", false);
|
||
ModerController.SetChildActive(lineInsulator, "线路柱式瓷绝缘子-好", true);
|
||
Debug.Log("线路柱式瓷绝缘子外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果线路柱式瓷绝缘子是激活的,设置其坏状态
|
||
if (lineInsulator != null && lineInsulator.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(lineInsulator, "线路柱式瓷绝缘子", true);
|
||
ModerController.SetChildActive(lineInsulator, "线路柱式瓷绝缘子-好", false);
|
||
Debug.Log("线路柱式瓷绝缘子外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 联结金具-直角挂板处理器
|
||
/// </summary>
|
||
public class RightAngleHangerProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活联结金具-直角挂板模型
|
||
ModerController.SetChildActive(model.transform, "联结金具-直角挂板", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示联结金具-直角挂板");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保联结金具-直角挂板模型关闭
|
||
ModerController.SetChildActive(model.transform, "联结金具-直角挂板", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform hanger = ModerController.FindChild(model.transform, "联结金具-直角挂板");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果联结金具-直角挂板是激活的,设置其好状态
|
||
if (hanger != null && hanger.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(hanger, "联结金具-直角挂板-坏", false);
|
||
ModerController.SetChildActive(hanger, "联结金具-直角挂板-好", true);
|
||
Debug.Log("联结金具-直角挂板外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果联结金具-直角挂板是激活的,设置其坏状态
|
||
if (hanger != null && hanger.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(hanger, "联结金具-直角挂板", true);
|
||
ModerController.SetChildActive(hanger, "联结金具-直角挂板-好", false);
|
||
Debug.Log("联结金具-直角挂板外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 联结金具-直角挂板袋装处理器
|
||
/// </summary>
|
||
public class RightAngleHangerBagProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活联结金具-直角挂板袋装模型
|
||
ModerController.SetChildActive(model.transform, "联结金具-直角挂板袋装", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示联结金具-直角挂板袋装");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保联结金具-直角挂板袋装模型关闭
|
||
ModerController.SetChildActive(model.transform, "联结金具-直角挂板袋装", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform hangerBag = ModerController.FindChild(model.transform, "联结金具-直角挂板袋装");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果联结金具-直角挂板袋装是激活的,设置其好状态
|
||
if (hangerBag != null && hangerBag.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(hangerBag, "联结金具-直角挂板袋装-坏", false);
|
||
ModerController.SetChildActive(hangerBag, "联结金具-直角挂板袋装-好", true);
|
||
Debug.Log("联结金具-直角挂板袋装外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果联结金具-直角挂板袋装是激活的,设置其坏状态
|
||
if (hangerBag != null && hangerBag.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(hangerBag, "联结金具-直角挂板袋装", true);
|
||
ModerController.SetChildActive(hangerBag, "联结金具-直角挂板袋装-好", false);
|
||
Debug.Log("联结金具-直角挂板袋装外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 蝶式绝缘子处理器
|
||
/// </summary>
|
||
public class ButterflyInsulatorProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活蝶式绝缘子模型
|
||
ModerController.SetChildActive(model.transform, "蝶式绝缘子", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示蝶式绝缘子");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保蝶式绝缘子模型关闭
|
||
ModerController.SetChildActive(model.transform, "蝶式绝缘子", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform butterflyInsulator = ModerController.FindChild(model.transform, "蝶式绝缘子");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果蝶式绝缘子是激活的,设置其好状态
|
||
if (butterflyInsulator != null && butterflyInsulator.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(butterflyInsulator, "蝶式绝缘子-坏", false);
|
||
ModerController.SetChildActive(butterflyInsulator, "蝶式绝缘子-好", true);
|
||
Debug.Log("蝶式绝缘子外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果蝶式绝缘子是激活的,设置其坏状态
|
||
if (butterflyInsulator != null && butterflyInsulator.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(butterflyInsulator, "蝶式绝缘子", true);
|
||
ModerController.SetChildActive(butterflyInsulator, "蝶式绝缘子-好", false);
|
||
Debug.Log("蝶式绝缘子外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 配电箱处理器
|
||
/// </summary>
|
||
public class DistributionBoxProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活配电箱模型
|
||
ModerController.SetChildActive(model.transform, "配电箱", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示配电箱");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保配电箱模型关闭
|
||
ModerController.SetChildActive(model.transform, "配电箱", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform distributionBox = ModerController.FindChild(model.transform, "配电箱");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果配电箱是激活的,设置其好状态
|
||
if (distributionBox != null && distributionBox.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(distributionBox, "配电箱-坏", false);
|
||
ModerController.SetChildActive(distributionBox, "配电箱-好", true);
|
||
Debug.Log("配电箱外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果配电箱是激活的,设置其坏状态
|
||
if (distributionBox != null && distributionBox.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(distributionBox, "配电箱", true);
|
||
ModerController.SetChildActive(distributionBox, "配电箱-好", false);
|
||
Debug.Log("配电箱外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 高压熔断器处理器
|
||
/// </summary>
|
||
public class HighVoltageFuseProcessor : IModelProcessor
|
||
{
|
||
public void ProcessModel(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
// 根据检查类型进行不同处理
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
if (materialCheck.CorrectAnswer == "一致")
|
||
{
|
||
// 激活高压熔断器模型
|
||
ModerController.SetChildActive(model.transform, "高压熔断器", true);
|
||
// 确保其他模型关闭
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", false);
|
||
Debug.Log("品类一致 - 显示高压熔断器");
|
||
}
|
||
else
|
||
{
|
||
// 激活其他模型
|
||
ModerController.SetChildActive(model.transform, "10kV电缆终端", true);
|
||
// 确保高压熔断器模型关闭
|
||
ModerController.SetChildActive(model.transform, "高压熔断器", false);
|
||
Debug.Log("品类不一致 - 显示10kV电缆终端");
|
||
}
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
// 检查当前激活的是哪个模型
|
||
Transform fuse = ModerController.FindChild(model.transform, "高压熔断器");
|
||
Transform otherModel = ModerController.FindChild(model.transform, "10kV电缆终端");
|
||
|
||
if (materialCheck.CorrectAnswer == "完好")
|
||
{
|
||
// 如果高压熔断器是激活的,设置其好状态
|
||
if (fuse != null && fuse.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(fuse, "高压熔断器-坏", false);
|
||
ModerController.SetChildActive(fuse, "高压熔断器-好", true);
|
||
Debug.Log("高压熔断器外观正常");
|
||
}
|
||
// 如果其他模型是激活的,设置其好状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-坏", false);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", true);
|
||
Debug.Log("10kV电缆终端外观正常");
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 如果高压熔断器是激活的,设置其坏状态
|
||
if (fuse != null && fuse.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(fuse, "高压熔断器", true);
|
||
ModerController.SetChildActive(fuse, "高压熔断器-好", false);
|
||
Debug.Log("高压熔断器外观破损");
|
||
}
|
||
// 如果其他模型是激活的,设置其坏状态
|
||
else if (otherModel != null && otherModel.gameObject.activeInHierarchy)
|
||
{
|
||
ModerController.SetRandomBrokenModelActive(otherModel, "10kV电缆终端", true);
|
||
ModerController.SetChildActive(otherModel, "10kV电缆终端-好", false);
|
||
Debug.Log("10kV电缆终端外观破损");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// MODER控制器
|
||
/// </summary>
|
||
public class ModerController : MonoBehaviour
|
||
{
|
||
/// <summary>
|
||
/// MODER控制器的单例
|
||
/// </summary>
|
||
public static ModerController Instance;
|
||
|
||
private void Awake()
|
||
{
|
||
Instance = this;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 要排列的模型预制体
|
||
/// </summary>
|
||
public GameObject prefabModel;
|
||
|
||
/// <summary>
|
||
/// 入库检验区
|
||
/// </summary>
|
||
public Transform WarehousingInspectionArea;
|
||
|
||
/// <summary>
|
||
/// 出库检验区
|
||
/// </summary>
|
||
public Transform OutboundInspectionArea;
|
||
|
||
/// <summary>
|
||
/// 模型父物体
|
||
/// </summary>
|
||
public Transform parentTransform;
|
||
|
||
/// <summary>
|
||
/// 需要生成的模型数量
|
||
/// </summary>
|
||
public int modelCount;
|
||
|
||
/// <summary>
|
||
/// 每行模型数量
|
||
/// </summary>
|
||
public int modelsPerRow = 5;
|
||
|
||
/// <summary>
|
||
/// 模型行间距
|
||
/// </summary>
|
||
public float rowSpacing = 1.0f;
|
||
|
||
/// <summary>
|
||
/// 模型列间距
|
||
/// </summary>
|
||
public float columnSpacing = 1.0f;
|
||
|
||
/// <summary>
|
||
/// 入库/出库/...类型
|
||
/// </summary>
|
||
public string typeInboundOutbound;
|
||
|
||
/// <summary>
|
||
/// 物品列表
|
||
/// </summary>
|
||
public List<CheckGoods> checkGoods = new List<CheckGoods>();
|
||
|
||
/// <summary>
|
||
/// 是否已经佩戴安全帽
|
||
/// </summary>
|
||
public bool isWearingSafetyHat = false;
|
||
|
||
|
||
/// <summary>
|
||
/// 是否已经佩戴安全帽
|
||
/// </summary>
|
||
public bool iscomputer = false;
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 模型位置信息
|
||
/// </summary>
|
||
[Header("模型位置信息")] public ModerPosition[] moderPositions;
|
||
|
||
/// <summary>
|
||
/// 模型处理器字典
|
||
/// </summary>
|
||
private Dictionary<string, IModelProcessor> modelProcessors;
|
||
|
||
// Start is called before the first frame update
|
||
|
||
|
||
/// <summary>
|
||
/// 初始化模型处理器
|
||
/// </summary>
|
||
public void InitializeModelProcessors()
|
||
{
|
||
modelProcessors = new Dictionary<string, IModelProcessor>
|
||
{
|
||
{ "10kV变压器", new Transformer10kVProcessor() },
|
||
{ "1kV电缆终端", new CableTerminal1kVProcessor() },
|
||
{ "10kV三相隔离开关", new DisconnectSwitch10kVProcessor() },
|
||
{ "10kV电缆终端", new CableTerminal10kVProcessor() },
|
||
{ "交流盘形悬式瓷绝缘子", new PorcelainInsulatorProcessor() },
|
||
{ "低压电流互感器", new LowVoltageCurrentTransformerProcessor() },
|
||
{ "布电线", new WireProcessor() },
|
||
{ "接地短路故障指示器", new GroundFaultIndicatorProcessor() },
|
||
{ "接续金具-接地线夹", new GroundClampProcessor() },
|
||
{ "柱上断路器", new PoleCircuitBreakerProcessor() },
|
||
{ "电力电缆", new PowerCableProcessor() },
|
||
{ "电缆分支箱", new CableBranchBoxProcessor() },
|
||
{ "线路柱式瓷绝缘子", new LinePorcelainInsulatorProcessor() },
|
||
{ "联结金具-直角挂板", new RightAngleHangerProcessor() },
|
||
{ "联结金具-直角挂板袋装", new RightAngleHangerBagProcessor() },
|
||
{ "蝶式绝缘子", new ButterflyInsulatorProcessor() },
|
||
{ "配电箱", new DistributionBoxProcessor() },
|
||
{ "高压熔断器", new HighVoltageFuseProcessor() },
|
||
};
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化并排列模型
|
||
/// </summary>
|
||
/// <param name="prefabName"></param>
|
||
public void Init(string prefabName)
|
||
{
|
||
prefabModel = Resources.Load<GameObject>("Prefabs/Moder/" + prefabName);
|
||
ModerPosition moderPosition = moderPositions.FirstOrDefault(x => x.prefabName == prefabName);
|
||
if (moderPosition != null)
|
||
{
|
||
//每行模型数量
|
||
modelsPerRow = moderPosition.modelsPerRow;
|
||
//模型行间距
|
||
rowSpacing = moderPosition.rowSpacing;
|
||
//模型列间距
|
||
columnSpacing = moderPosition.columnSpacing;
|
||
}
|
||
else
|
||
{
|
||
return;
|
||
}
|
||
|
||
//模型生成区域 出库/入库
|
||
WarehousingInspectionArea = FindObjectByName<Transform>("WarehousingInspectionArea");
|
||
OutboundInspectionArea = FindObjectByName<Transform>("OutboundInspectionArea");
|
||
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("出库"))
|
||
{
|
||
typeInboundOutbound = "出库";
|
||
}
|
||
else
|
||
{
|
||
typeInboundOutbound = "入库";
|
||
}
|
||
|
||
switch (typeInboundOutbound)
|
||
{
|
||
case "入库":
|
||
parentTransform = WarehousingInspectionArea;
|
||
break;
|
||
case "出库":
|
||
parentTransform = OutboundInspectionArea;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
CombinedClass combinedClass = GameManager.Instance.combinedClass;
|
||
//实例化模型数量
|
||
modelCount = int.Parse(combinedClass.incomeQuantity);
|
||
//加载PLCJ
|
||
//StartCoroutine(LoadPLCJ());
|
||
ArrangeModels(prefabName);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 初始化并排列模型
|
||
/// </summary>
|
||
/// <summary>
|
||
/// 初始化并排列模型 - 根据题目类型选择不同的生成方式
|
||
/// </summary>
|
||
/// <param name="modelname">模型名称</param>
|
||
public void ArrangeModels(string modelname)
|
||
{
|
||
if (prefabModel == null || parentTransform == null || modelCount <= 0)
|
||
{
|
||
Debug.LogWarning("预制体为空,父物体为空或模型数量小于等于0,无法生成模型。");
|
||
return;
|
||
}
|
||
|
||
// 清除父物体下的所有子物体
|
||
foreach (Transform child in parentTransform)
|
||
{
|
||
Destroy(child.gameObject);
|
||
}
|
||
|
||
int rows = Mathf.CeilToInt(modelCount / (float)modelsPerRow);
|
||
Debug.Log("总共生成行数= " + rows);
|
||
|
||
// 根据题目名称判断使用哪种生成方式
|
||
string examName = MotionEngine.GetModule<GlobalDataStorage>().ExamName;
|
||
bool isOutboundExam = examName.Contains("出库");
|
||
|
||
Debug.Log($"【生成模式判断】题目名称: {examName}, 是否出库: {isOutboundExam}");
|
||
|
||
if (isOutboundExam)
|
||
{
|
||
// 出库场景:使用简单的按数量生成逻辑
|
||
Debug.Log("【出库模式】使用简单按数量生成逻辑");
|
||
GenerateModelsByCount(modelname);
|
||
}
|
||
else
|
||
{
|
||
// 非出库场景:使用复杂的物料分组生成逻辑
|
||
Debug.Log("【入库模式】使用物料分组生成逻辑");
|
||
GenerateModelsByMaterialGroups(modelname);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 出库场景:按数量简单生成模型
|
||
/// </summary>
|
||
/// <param name="modelname">模型名称</param>
|
||
private void GenerateModelsByCount(string modelname)
|
||
{
|
||
Debug.Log($"【出库模式】开始生成 {modelCount} 个模型");
|
||
|
||
for (int i = 0; i < modelCount; i++)
|
||
{
|
||
// 计算当前模型的位置
|
||
int row = i / modelsPerRow;
|
||
int column = i % modelsPerRow;
|
||
|
||
// 实例化模型并设置其位置
|
||
GameObject model = Instantiate(prefabModel, parentTransform);
|
||
CheckGoods checkGood = model.GetComponent<CheckGoods>();
|
||
if (checkGood != null)
|
||
{
|
||
checkGoods.Add(checkGood);
|
||
Debug.Log($" - 成功创建第 {i + 1} 个模型的检查组件");
|
||
}
|
||
|
||
model.gameObject.SetActive(true);
|
||
model.transform.name = $"{prefabModel.name}_{i + 1}";
|
||
model.transform.localPosition = new Vector3(column * columnSpacing, 0, row * rowSpacing);
|
||
|
||
Debug.Log($" - 模型 {i + 1} 位置: 行={row}, 列={column}, 坐标=({column * columnSpacing}, 0, {row * rowSpacing})");
|
||
|
||
model.GetComponent<CheckGoods>().Init();
|
||
}
|
||
|
||
Debug.Log($"【出库模式】生成完成,总共生成了 {modelCount} 个模型");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 入库场景:按物料分组生成模型
|
||
/// </summary>
|
||
/// <param name="modelname">模型名称</param>
|
||
private void GenerateModelsByMaterialGroups(string modelname)
|
||
{
|
||
List<MaterialCheckInfo> materialCheckInfoList = MotionEngine.GetModule<GlobalDataStorage>().materialCheckInfoList;
|
||
Debug.Log($"【入库模式】物料检查信息总共加载了 {materialCheckInfoList.Count} 个检查项目");
|
||
|
||
// 重构:按物料编号分组,确保每个物料只生成一个对象
|
||
var materialGroups = materialCheckInfoList
|
||
.GroupBy(d => ExtractMaterialNumberFromQuestion(d.Question))
|
||
.Where(g => !string.IsNullOrEmpty(g.Key) && g.Key != "未知")
|
||
.OrderBy(g => int.Parse(g.Key))
|
||
.ToList();
|
||
|
||
Debug.Log($"【入库模式】物料分组识别到 {materialGroups.Count} 个不同的物料");
|
||
|
||
if (materialGroups.Count > 0)
|
||
{
|
||
for (int i = 0; i < modelCount; i++)
|
||
{
|
||
var materialGroup = materialGroups[i];
|
||
string materialNumber = materialGroup.Key;
|
||
var materialChecks = materialGroup.ToList();
|
||
|
||
Debug.Log($"\n【物料 {materialNumber}】开始生成,包含 {materialChecks.Count} 个检查项目");
|
||
|
||
// 记录该物料的所有检查类型
|
||
foreach (var check in materialChecks)
|
||
{
|
||
string checkType = GetCheckType(check.Question);
|
||
Debug.Log($" - 检查类型: {checkType}, 正确答案: {check.CorrectAnswer}");
|
||
}
|
||
|
||
// 计算当前模型的位置
|
||
int row = i / modelsPerRow;
|
||
int column = i % modelsPerRow;
|
||
|
||
// 实例化模型并设置其位置
|
||
GameObject model = Instantiate(prefabModel, parentTransform);
|
||
CheckGoods checkGood = model.GetComponent<CheckGoods>();
|
||
if (checkGood != null)
|
||
{
|
||
checkGoods.Add(checkGood);
|
||
Debug.Log($" - 成功创建物料 {materialNumber} 的检查组件");
|
||
}
|
||
|
||
model.gameObject.SetActive(true);
|
||
model.transform.name = $"{prefabModel.name}_物料{materialNumber}";
|
||
model.transform.localPosition = new Vector3(column * columnSpacing, 0, row * rowSpacing);
|
||
|
||
Debug.Log($" - 物料 {materialNumber} 位置: 行={row}, 列={column}, 坐标=({column * columnSpacing}, 0, {row * rowSpacing})");
|
||
|
||
model.GetComponent<CheckGoods>().Init();
|
||
|
||
// 处理该物料的所有检查项目
|
||
for (int j = 0; j < materialChecks.Count; j++)
|
||
{
|
||
Debug.Log($" - 处理检查项目 {j + 1}: {materialChecks[j].Question}");
|
||
// 使用通用模型处理方法
|
||
ProcessModelCheck(model, materialChecks[j], checkGood, modelname);
|
||
}
|
||
|
||
Debug.Log($"【物料 {materialNumber}】生成完成,共处理 {materialChecks.Count} 个检查项目");
|
||
}
|
||
}
|
||
|
||
Debug.Log($"【入库模式】物料生成完成,总共生成了 {materialGroups.Count} 个物料对象,而不是之前的 {materialCheckInfoList.Count} 个");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检查物品是否全部完成
|
||
/// </summary>
|
||
public void CheckGoodsCheckCompleted()
|
||
{
|
||
//检查checkGoods所有成员的isCheckCompleted是否都为true
|
||
bool isAllCheckCompleted = true;
|
||
foreach (CheckGoods checkGood in checkGoods)
|
||
{
|
||
if (!checkGood.name.Contains("电力电缆"))
|
||
{
|
||
if (!checkGood.isCheckCompleted)
|
||
{
|
||
isAllCheckCompleted = false;
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!checkGood.isCheckCompleted || checkGood.arrowObj2.activeInHierarchy)
|
||
{
|
||
isAllCheckCompleted = false;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (isAllCheckCompleted)
|
||
{
|
||
//全部完成,通知UI
|
||
List<string> goodsName = new List<string>();
|
||
for (int i = 0; i < checkGoods.Count; i++)
|
||
{
|
||
CheckGoods checkGood = checkGoods[i];
|
||
Toggle TogPL = checkGood.TogPLGood.isOn ? checkGood.TogPLGood : checkGood.TogPLBad;
|
||
Toggle TogSL = checkGood.TogCJGood.isOn ? checkGood.TogCJGood : checkGood.TogCJBad;
|
||
Toggle Tog = checkGood.TogGood.isOn ? checkGood.TogGood : checkGood.TogBad;
|
||
|
||
goodsName.Add(TogPL.name);
|
||
goodsName.Add(TogSL.name);
|
||
goodsName.Add(Tog.name);
|
||
if (i == checkGoods.Count - 1)
|
||
{
|
||
if (MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(goodsName))
|
||
{
|
||
|
||
Debug.Log("处理成功");
|
||
if (GameManager.Instance.combinedClass.Subjectname.Contains("不可用办理实物退库") || MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("废旧物资入库"))
|
||
{
|
||
LoadTriggerNextGuide("关闭");
|
||
;
|
||
//TutorialGuideComponent.Instance.ShowGUIde();
|
||
}
|
||
else
|
||
{
|
||
LoadTriggerNextGuide();
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 加载PLCJ
|
||
/// </summary>
|
||
public IEnumerator LoadPLCJ()
|
||
{
|
||
yield return new WaitForSeconds(1.0f);
|
||
List<MaterialCheck> materialChecks = GameManager.Instance.materialChecks;
|
||
for (int i = 0; i < materialChecks.Count; i++)
|
||
{
|
||
if (i < checkGoods.Count)
|
||
checkGoods[i].PLCJ(materialChecks[i].materialCategory, materialChecks[i].manufacturer, materialChecks[i].appearanceCheck);
|
||
}
|
||
}
|
||
|
||
[ContextMenu("AddArrangeModelsInGrid")]
|
||
public void AddArrangeModelsInGrid()
|
||
{
|
||
ArrangeModels("1kV电缆终端");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 物资品类一致高亮(外部调用)
|
||
/// </summary>
|
||
public void MaterialVerification()
|
||
{
|
||
if (MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode.教学模式)
|
||
{
|
||
for (int i = 0; i < checkGoods.Count; i++)
|
||
{
|
||
checkGoods[i].arrowObj.SetActive(true);
|
||
if (checkGoods[i].arrowObj2 != null)
|
||
{
|
||
checkGoods[i].arrowObj2.SetActive(true);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 模型高亮显示
|
||
/// </summary>
|
||
public void HighlightModel()
|
||
{
|
||
for (int i = 0; i < checkGoods.Count; i++)
|
||
{
|
||
checkGoods[i].highlightEffect.SetHighlighted(true);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 通用模型处理方法 - 处理不同模型的检查逻辑
|
||
/// </summary>
|
||
/// <param name="model">模型GameObject</param>
|
||
/// <param name="materialCheck">物料检查信息</param>
|
||
/// <param name="checkGood">检查组件</param>
|
||
/// <param name="modelName">模型名称</param>
|
||
public void ProcessModelCheck(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood, string modelName)
|
||
{
|
||
// 获取对应的模型处理器
|
||
if (modelProcessors.TryGetValue(modelName, out IModelProcessor processor))
|
||
{
|
||
// 调用特定模型的处理器
|
||
processor.ProcessModel(model, materialCheck, checkGood);
|
||
}
|
||
else
|
||
{
|
||
Debug.LogWarning($"未找到模型 {modelName} 的处理器,使用默认处理逻辑");
|
||
// 默认处理逻辑
|
||
ProcessDefaultModelCheck(model, materialCheck, checkGood);
|
||
}
|
||
|
||
// 通用的检查逻辑 - 所有模型都需要检查品类一致性和外观
|
||
ProcessCommonChecks(materialCheck);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 默认模型处理逻辑
|
||
/// </summary>
|
||
/// <param name="model">模型GameObject</param>
|
||
/// <param name="materialCheck">物料检查信息</param>
|
||
/// <param name="checkGood">检查组件</param>
|
||
private void ProcessDefaultModelCheck(GameObject model, MaterialCheckInfo materialCheck, CheckGoods checkGood)
|
||
{
|
||
if (materialCheck.IsNormal)
|
||
{
|
||
Debug.Log($"{model.name} - 物料正常");
|
||
}
|
||
else
|
||
{
|
||
Debug.Log($"{model.name} - 物料缺陷");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 通用检查逻辑 - 处理品类一致性和外观检查
|
||
/// </summary>
|
||
/// <param name="materialCheck">物料检查信息</param>
|
||
private void ProcessCommonChecks(MaterialCheckInfo materialCheck)
|
||
{
|
||
if (materialCheck.Question.Contains("物资品类是否一致"))
|
||
{
|
||
string status = materialCheck.IsCategoryConsistent ? "一致" : "不一致";
|
||
Debug.Log($" 品类一致性: {status}");
|
||
}
|
||
else if (materialCheck.Question.Contains("厂家是否一致"))
|
||
{
|
||
string status = materialCheck.CorrectAnswer.Contains("一致") ? "一致" : "不一致";
|
||
Debug.Log($" 厂家一致性: {status}");
|
||
}
|
||
else if (materialCheck.Question.Contains("检查外观"))
|
||
{
|
||
string status = materialCheck.IsNormal ? "完好" : materialCheck.IsDamaged ? "破损" : "无法确定";
|
||
Debug.Log($" 外观检查: {status}");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 注册新的模型处理器
|
||
/// </summary>
|
||
/// <param name="modelName">模型名称</param>
|
||
/// <param name="processor">处理器实例</param>
|
||
public void RegisterModelProcessor(string modelName, IModelProcessor processor)
|
||
{
|
||
if (modelProcessors == null)
|
||
{
|
||
modelProcessors = new Dictionary<string, IModelProcessor>();
|
||
}
|
||
|
||
if (modelProcessors.ContainsKey(modelName))
|
||
{
|
||
Debug.LogWarning($"模型处理器 {modelName} 已存在,将被覆盖");
|
||
}
|
||
|
||
modelProcessors[modelName] = processor;
|
||
Debug.Log($"成功注册模型处理器: {modelName}");
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取所有已注册的模型名称
|
||
/// </summary>
|
||
/// <returns>模型名称列表</returns>
|
||
public List<string> GetRegisteredModelNames()
|
||
{
|
||
if (modelProcessors == null)
|
||
{
|
||
return new List<string>();
|
||
}
|
||
|
||
return modelProcessors.Keys.ToList();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 检查是否支持指定模型
|
||
/// </summary>
|
||
/// <param name="modelName">模型名称</param>
|
||
/// <returns>是否支持</returns>
|
||
public bool IsModelSupported(string modelName)
|
||
{
|
||
return modelProcessors != null && modelProcessors.ContainsKey(modelName);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 公用查询子对象方法 - 安全地查找子对象并进行SetActive操作
|
||
/// </summary>
|
||
/// <param name="parent">父对象</param>
|
||
/// <param name="childName">子对象名称</param>
|
||
/// <param name="active">是否激活</param>
|
||
/// <returns>是否成功找到并设置</returns>
|
||
public static bool SetChildActive(Transform parent, string childName, bool active)
|
||
{
|
||
if (parent == null)
|
||
{
|
||
Debug.LogWarning($"父对象为空,无法查找子对象: {childName}");
|
||
return false;
|
||
}
|
||
|
||
Transform child = parent.Find(childName);
|
||
if (child == null)
|
||
{
|
||
Debug.LogWarning($"在父对象 {parent.name} 中未找到子对象: {childName}");
|
||
return false;
|
||
}
|
||
|
||
child.gameObject.SetActive(active);
|
||
Debug.Log($"成功设置 {parent.name}/{childName} 的激活状态为: {active}");
|
||
return true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 公用查询子对象方法 - 查找子对象并返回
|
||
/// </summary>
|
||
/// <param name="parent">父对象</param>
|
||
/// <param name="childName">子对象名称</param>
|
||
/// <returns>找到的子对象,未找到返回null</returns>
|
||
public static Transform FindChild(Transform parent, string childName)
|
||
{
|
||
if (parent == null)
|
||
{
|
||
Debug.LogWarning($"父对象为空,无法查找子对象: {childName}");
|
||
return null;
|
||
}
|
||
|
||
Transform child = parent.Find(childName);
|
||
if (child == null)
|
||
{
|
||
Debug.LogWarning($"在父对象 {parent.name} 中未找到子对象: {childName}");
|
||
return null;
|
||
}
|
||
|
||
return child;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 随机选择并激活损坏模型变体
|
||
/// 支持格式:{baseModelName}-坏、{baseModelName}-坏-Da、{baseModelName}-坏-Db、{baseModelName}-坏-Dc、{baseModelName}-坏-Dd
|
||
/// </summary>
|
||
/// <param name="parent">父对象</param>
|
||
/// <param name="baseModelName">基础模型名称</param>
|
||
/// <param name="active">是否激活</param>
|
||
/// <returns>是否成功找到并设置</returns>
|
||
public static bool SetRandomBrokenModelActive(Transform parent, string baseModelName, bool active)
|
||
{
|
||
if (parent == null)
|
||
{
|
||
Debug.LogWarning($"父对象为空,无法查找损坏模型: {baseModelName}");
|
||
return false;
|
||
}
|
||
|
||
if (string.IsNullOrEmpty(baseModelName))
|
||
{
|
||
Debug.LogWarning("基础模型名称为空,无法查找损坏模型");
|
||
return false;
|
||
}
|
||
|
||
// 收集所有可能的损坏模型变体
|
||
List<string> possibleBrokenModels = new List<string>();
|
||
|
||
// 添加基础损坏模型
|
||
string baseBrokenModel = $"{baseModelName}-坏";
|
||
possibleBrokenModels.Add(baseBrokenModel);
|
||
|
||
// 添加变体损坏模型(Da, Db, Dc, Dd)
|
||
string[] variants = { "Da", "Db", "Dc", "Dd" };
|
||
foreach (string variant in variants)
|
||
{
|
||
string variantBrokenModel = $"{baseModelName}-坏-{variant}";
|
||
possibleBrokenModels.Add(variantBrokenModel);
|
||
}
|
||
|
||
// 检查哪些损坏模型实际存在
|
||
List<string> existingBrokenModels = new List<string>();
|
||
foreach (string modelName in possibleBrokenModels)
|
||
{
|
||
Transform child = parent.Find(modelName);
|
||
if (child != null)
|
||
{
|
||
existingBrokenModels.Add(modelName);
|
||
Debug.Log($"找到损坏模型: {modelName}");
|
||
}
|
||
}
|
||
|
||
if (existingBrokenModels.Count == 0)
|
||
{
|
||
Debug.LogWarning($"未找到任何损坏模型变体,基础模型: {baseModelName}");
|
||
return false;
|
||
}
|
||
|
||
if (active)
|
||
{
|
||
// 随机选择一个损坏模型变体
|
||
int randomIndex = Random.Range(0, existingBrokenModels.Count);
|
||
string selectedBrokenModel = existingBrokenModels[randomIndex];
|
||
|
||
// 激活选中的损坏模型
|
||
Transform selectedChild = parent.Find(selectedBrokenModel);
|
||
if (selectedChild != null)
|
||
{
|
||
selectedChild.gameObject.SetActive(true);
|
||
Debug.Log($"随机选择并激活损坏模型: {selectedBrokenModel}");
|
||
}
|
||
|
||
// 关闭所有其他损坏模型
|
||
foreach (string modelName in existingBrokenModels)
|
||
{
|
||
if (modelName != selectedBrokenModel)
|
||
{
|
||
Transform otherChild = parent.Find(modelName);
|
||
if (otherChild != null)
|
||
{
|
||
otherChild.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
// 关闭所有损坏模型
|
||
foreach (string modelName in existingBrokenModels)
|
||
{
|
||
Transform child = parent.Find(modelName);
|
||
if (child != null)
|
||
{
|
||
child.gameObject.SetActive(false);
|
||
}
|
||
}
|
||
Debug.Log($"关闭所有损坏模型,基础模型: {baseModelName}");
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 从问题文本中提取物料编号 - 重构版本:更准确的提取逻辑
|
||
/// </summary>
|
||
/// <param name="questionText">问题文本</param>
|
||
/// <returns>物料编号字符串</returns>
|
||
private static string ExtractMaterialNumberFromQuestion(string questionText)
|
||
{
|
||
if (string.IsNullOrEmpty(questionText))
|
||
{
|
||
Debug.LogWarning("问题文本为空,无法提取物料编号");
|
||
return "未知";
|
||
}
|
||
|
||
try
|
||
{
|
||
// 使用正则表达式提取物料编号,支持"物料X"格式
|
||
var match = System.Text.RegularExpressions.Regex.Match(questionText, @"物料(\d+)");
|
||
if (match.Success)
|
||
{
|
||
string materialNumber = match.Groups[1].Value;
|
||
Debug.Log($"从问题文本 '{questionText}' 中成功提取物料编号: {materialNumber}");
|
||
return materialNumber;
|
||
}
|
||
else
|
||
{
|
||
Debug.LogWarning($"无法从问题文本 '{questionText}' 中提取物料编号");
|
||
return "未知";
|
||
}
|
||
}
|
||
catch (System.Exception ex)
|
||
{
|
||
Debug.LogError($"提取物料编号时发生异常: {ex.Message}");
|
||
return "未知";
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获取检查类型描述 - 根据问题文本判断检查类型
|
||
/// </summary>
|
||
/// <param name="questionText">问题文本</param>
|
||
/// <returns>检查类型描述</returns>
|
||
private static string GetCheckType(string questionText)
|
||
{
|
||
if (string.IsNullOrEmpty(questionText))
|
||
{
|
||
return "未知检查类型";
|
||
}
|
||
|
||
if (questionText.Contains("物资品类是否一致"))
|
||
{
|
||
return "物资品类一致性检查";
|
||
}
|
||
else if (questionText.Contains("厂家是否一致"))
|
||
{
|
||
return "厂家一致性检查";
|
||
}
|
||
else if (questionText.Contains("检查外观"))
|
||
{
|
||
return "外观质量检查";
|
||
}
|
||
else
|
||
{
|
||
return "其他检查类型";
|
||
}
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 模型位置
|
||
/// </summary>
|
||
[System.Serializable]
|
||
public class ModerPosition
|
||
{
|
||
/// <summary>
|
||
/// 加载预制体名称
|
||
/// </summary>
|
||
[Header("加载预制体名称")] public string prefabName;
|
||
|
||
/// <summary>
|
||
/// 每行模型数量
|
||
/// </summary>
|
||
[Header("每行模型数量")] public int modelsPerRow;
|
||
|
||
/// <summary>
|
||
/// 模型行间距
|
||
/// </summary>
|
||
[Header("模型行间距")] public float rowSpacing;
|
||
|
||
/// <summary>
|
||
/// 模型列间距
|
||
/// </summary>
|
||
[Header("模型列间距")] public float columnSpacing;
|
||
} |