6.23修改

This commit is contained in:
2274240467@qq.com 2024-06-23 19:05:40 +08:00
parent 1a0b71dd82
commit 4023a75f52
8 changed files with 1374 additions and 179 deletions

View File

@ -32,16 +32,43 @@ public class JunctionBox : MonoBehaviour
/// 接线盒是否盖上
/// </summary>
public bool iscover;
/// <summary>
/// 滑块的原始位置
/// </summary>
private List<Vector3> originalPosition=new List<Vector3>();
/// <summary>
/// 滑块的原始旋转
/// </summary>
private Quaternion originalRotation;
bool isanzhaung =false;
/// <summary>
/// 接线盒上的封印和螺丝
/// </summary>
public GameObject[] tool;
//public static JunctionBox intance;
//public void Awake()
//{
// intance = this;
//}
void Start()
{
Init();
}
public void Init()
{
for (int i = 0; i < GameObjectSlider.Length; i++)
{
GameObjectSlider[i].GetComponent<HighlightEffect>().enabled = false;
originalPosition.Add(GameObjectSlider[i].transform.localPosition);
//originalRotation = GameObjectSlider[i].transform.localRotation;
}
}
/// <summary>
@ -102,16 +129,41 @@ public class JunctionBox : MonoBehaviour
break;
}
}
//else
//{
// Debug.Log("线盒还在");
//}
if (AreAllTool())
{
switch (hit.collider.gameObject.name)
{
case "接线盒纵向滑块001":
hit.collider.gameObject.transform.DOLocalMove(originalPosition[0], 1f);
Debug.Log(hit.collider.gameObject.name);
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
break;
case "接线盒纵向滑块002":
hit.collider.gameObject.transform.DOLocalMove(originalPosition[1], 1f);
Debug.Log(hit.collider.gameObject.name);
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
break;
case "接线盒纵向滑块003":
hit.collider.gameObject.transform.DOLocalMove(originalPosition[2], 1f);
Debug.Log(hit.collider.gameObject.name);
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
break;
case "接线盒纵向滑块004":
hit.collider.gameObject.transform.DOLocalMove(originalPosition[3], 1f);
Debug.Log(hit.collider.gameObject.name);
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
break;
}
}
}
}
//
if (AreAllObjectsHidden())
{
iscover = true;
TransparentlidObj.transform.DOLocalMove(new Vector3(0, -0.0914f, 0), 2f);
iscover = true;
//isanzhaung = true;
for (int i = 0; i < GameObjectSlider.Length; i++)
{
GameObjectSlider[i].GetComponent<HighlightEffect>().enabled = true;
@ -128,8 +180,20 @@ public class JunctionBox : MonoBehaviour
return false; // 如果找到任何一个激活的对象返回false
}
}
return true; // 如果所有对象都未激活返回true
}
//判断新集中器上的螺丝和封印是否全部显示
public bool AreAllTool()
{
// 检查每个对象的激活状态
foreach (GameObject obj in tool)
{
if (obj.activeInHierarchy) // 使用 activeInHierarchy 如果你想检查对象是否在其父级结构中被激活
{
TransparentlidObj.gameObject.GetComponent<BoxCollider>().enabled = true;
return true; // 如果找到任何一个激活的对象,返回
}
}
return false; // 如果所有对象都未激活返回false
}
}

View File

@ -114,12 +114,12 @@ Material:
- _UVSec: 0
- _ZWrite: 1
- __dirty: 0
- _step_p1: 1
- _step_p2: 1
- _step_p3: 1
- _step_p4: 1
- _step_p5: 1
- _step_p6: 1
- _step_p1: 0
- _step_p2: 0
- _step_p3: 0
- _step_p4: 0
- _step_p5: 0
- _step_p6: 0
m_Colors:
- _BaseCol: {r: 0.23429155, g: 0.28497556, b: 0.3679245, a: 0}
- _Color: {r: 1, g: 1, b: 1, a: 1}

View File

@ -83,9 +83,9 @@ public class Screwdriver : MonoBehaviour
public InteractiveObjects[] interactiveObjects;
/// <summary>
/// 拆完封印
/// 拆完旧集中器下端螺丝后
/// </summary>
bool issplit;
bool issplit =true;
/// <summary>
/// 螺丝刀的原始位置
@ -113,11 +113,11 @@ public class Screwdriver : MonoBehaviour
void Init()
{
ElectricWireBcr.enabled = false;
ElectricWireSMR.SetBlendShapeWeight(0, 0);
ElectricWireSMR.SetBlendShapeWeight(1, 0);
ElectricWireSMR.SetBlendShapeWeight(2, 0);
ElectricWireSMR.SetBlendShapeWeight(3, 0);
ElectricWireSMR.SetBlendShapeWeight(4, 0);
//ElectricWireSMR.SetBlendShapeWeight(0, 0);
//ElectricWireSMR.SetBlendShapeWeight(1, 0);
//ElectricWireSMR.SetBlendShapeWeight(2, 0);
//ElectricWireSMR.SetBlendShapeWeight(3, 0);
//ElectricWireSMR.SetBlendShapeWeight(4, 0);
ElectricWireSMR.SetBlendShapeWeight(5, 0);
TapeMar.SetFloat("_step_p1", 0);
TapeMar.SetFloat("_step_p2", 0);
@ -226,31 +226,7 @@ public class Screwdriver : MonoBehaviour
}
}
}
//判断上下两颗螺丝是否全部取下
if (!ScrewObj[0].activeInHierarchy && !ScrewObj[1].activeInHierarchy)
{
StartCoroutine(Frist());
}
if (!ScrewObj[2].activeInHierarchy && !ScrewObj[3].activeInHierarchy)
{
StartCoroutine(Second());
}
if (!ScrewObj[4].activeInHierarchy && !ScrewObj[5].activeInHierarchy)
{
StartCoroutine(Thrid());
}
if (!ScrewObj[6].activeInHierarchy && !ScrewObj[7].activeInHierarchy)
{
StartCoroutine(Fourth());
}
if (!ScrewObj[9].activeInHierarchy)
{
StartCoroutine(Sixth());
}
if (!ScrewObj[8].activeInHierarchy)
{
StartCoroutine(Fivth());
}
chaiwan();
if (ConcentratorScrew())
{
StartCoroutine(IEConcentratorScrew());
@ -271,6 +247,52 @@ public class Screwdriver : MonoBehaviour
}
}
public void chaiwan()
{
if (!issplit)
{
//判断上下两颗螺丝是否全部取下
if (!ScrewObj[0].activeInHierarchy && !ScrewObj[1].activeInHierarchy)
{
StartCoroutine(Frist());
issplit = true;
}
if (!ScrewObj[2].activeInHierarchy && !ScrewObj[3].activeInHierarchy)
{
StartCoroutine(Second());
issplit = true;
}
if (!ScrewObj[4].activeInHierarchy && !ScrewObj[5].activeInHierarchy)
{
StartCoroutine(Thrid());
issplit = true;
}
if (!ScrewObj[6].activeInHierarchy && !ScrewObj[7].activeInHierarchy)
{
StartCoroutine(Fourth());
issplit = true;
}
if (!ScrewObj[9].activeInHierarchy)
{
StartCoroutine(Sixth());
issplit = true;
}
if (!ScrewObj[8].activeInHierarchy)
{
StartCoroutine(Fivth());
issplit = true;
}
}
}
/// <summary>
/// 判断集中器螺丝
/// </summary>
@ -313,6 +335,7 @@ public class Screwdriver : MonoBehaviour
{
if (obj.activeInHierarchy)
{
issplit = false;
return false;
}
}

View File

@ -31,12 +31,35 @@ public class Seal : MonoBehaviour
/// <summary>
/// 透明盖子碰撞
/// </summary>
public BoxCollider SparentoverCol;
// public BoxCollider SparentoverCol;
/// <summary>
/// ¹ñÃÅ¿¨Ë¨
/// 左边柜门
/// </summary>
public GameObject CabinetDoorLatch;
public GameObject DoorLatch;
/// <summary>
/// 柜门box碰撞
/// </summary>
public BoxCollider guimenbox;
/// <summary>
/// 透明盖子上的封印
/// </summary>
public GameObject[] parentoverSeal;
/// <summary>
/// 柜门卡栓碰撞
/// </summary>
public BoxCollider guimenkashuan;
public GameObject fengy;
/// <summary>
/// 判断封印盒子是否在手上
/// </summary>
bool isbox = true;
// Start is called before the first frame update
void Start()
{
@ -62,11 +85,38 @@ public class Seal : MonoBehaviour
}
if (hit.collider.gameObject.name == "集中器_封印R碰撞")
{
Debug.Log(hit.collider.gameObject.name);
Sealcol[1].gameObject.SetActive(true);
CabinetDoorLatch.GetComponent<BoxCollider>().enabled = true;
SparentoverCol.GetComponent<BoxCollider>().enabled = true;
DoorLatch.GetComponent<BoxCollider>().enabled = true;
//SparentoverCol.GetComponent<BoxCollider>().enabled = true;
Debug.Log(hit.collider.gameObject.name); MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
if (hit.collider.gameObject.name == "透明盖子封印碰撞R")
{
if (isbox)
{
isbox = true;
parentoverSeal[0].gameObject.SetActive(true);
}
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
if (hit.collider.gameObject.name == "透明盖子封印碰撞L")
{
if (isbox)
{
isbox = true;
parentoverSeal[1].gameObject.SetActive(true);
guimenkashuan.enabled = true;
//isbox = false;
}
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
if (hit.collider.gameObject.name == "柜门卡栓")
{
fengy.gameObject.SetActive(true);
//fengy.transform.localPosition = new Vector3(0.6371536f, 0.02661133f, -0.01525164f);
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
}
}
}
@ -75,4 +125,5 @@ public class Seal : MonoBehaviour
EndOfProcessImage.gameObject.SetActive(true);
Debug.Log("流程结束");
}
}

View File

@ -70,9 +70,9 @@ public class ToolManager : MonoBehaviour
{
Tool[5].gameObject.SetActive(false);
}
if (Tool[6].activeInHierarchy)
if (Tool[7].activeInHierarchy)
{
Tool[6].gameObject.SetActive(false);
Tool[7].gameObject.SetActive(false);
}
});
processBt.onClick.AddListener(delegate
@ -208,12 +208,12 @@ public class ToolManager : MonoBehaviour
if (message == "l型集中器")
{
Tool[6].gameObject.SetActive(true);
RetractBtn[4].gameObject.SetActive(true);
// RetractBtn[4].gameObject.SetActive(true);
}
if (message == "盒装封印")
{
Tool[7].gameObject.SetActive(true);
RetractBtn[5].gameObject.SetActive(true);
RetractBtn[4].gameObject.SetActive(true);
}
Debug.Log("Received message: " + message);

View File

@ -5,12 +5,15 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
/// <summary>
/// 集中器
/// </summary>
public class concentrator : MonoBehaviour
{
/// <summary>
/// 集中器
/// </summary>
public GameObject concentratorObj;
public GameObject ConcentratorObj;
/// <summary>
/// 集中器端子螺丝
@ -31,10 +34,12 @@ public class concentrator : MonoBehaviour
/// 电线前段胶带
/// </summary>
public Material TapeMar;
/// <summary>
/// 螺丝是否全部显示
/// </summary>
int allls;
/// <summary>
/// 是否播放集线器螺丝拆完后电线动画
/// </summary>
@ -46,7 +51,7 @@ public class concentrator : MonoBehaviour
public GameObject Cover;
/// <summary>
/// 新盖子上左右两颗螺丝
/// 新集中器盖子上左右两颗螺丝
/// </summary>
public GameObject[] screw;
@ -74,7 +79,7 @@ public class concentrator : MonoBehaviour
{
if (hit.collider.gameObject.name == "新的集中器碰撞")
{
concentratorObj.gameObject.transform.SetParent(null);
ConcentratorObj.gameObject.transform.SetParent(null);
StartCoroutine(Newconcentrator());
Debug.Log(hit.collider.gameObject.name);
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
@ -86,24 +91,50 @@ public class concentrator : MonoBehaviour
Debug.Log(hit.collider.gameObject.name);
//StartCoroutine(IEHubSegmentRowScrews());
ScrewObj[i].GetComponent<MeshRenderer>().enabled = true;
if (ScrewObj[0].GetComponent<MeshRenderer>().enabled & ScrewObj[1].GetComponent<MeshRenderer>().enabled)
{
StartCoroutine(TapeBackFrist());
}
if (ScrewObj[2].GetComponent<MeshRenderer>().enabled & ScrewObj[3].GetComponent<MeshRenderer>().enabled)
{
StartCoroutine(TapeBackSecond());
}
if (ScrewObj[4].GetComponent<MeshRenderer>().enabled & ScrewObj[5].GetComponent<MeshRenderer>().enabled)
{
StartCoroutine(TapeBackThird());
}
if (ScrewObj[6].GetComponent<MeshRenderer>().enabled & ScrewObj[7].GetComponent<MeshRenderer>().enabled)
{
StartCoroutine(TapeBackFourth());
}
if (ScrewObj[8].GetComponent<MeshRenderer>().enabled)
{
StartCoroutine(TapeBackFifth());
}
if (ScrewObj[9].GetComponent<MeshRenderer>().enabled)
{
StartCoroutine(TapeBackSixth());
}
}
}
if (hit.collider.gameObject.name == "pCylinder170")
if (AreAllObjectsHidden())
{
if (isplaying)
{
StartCoroutine(IEElectricWire()); MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
isplaying = false;
}
isPlayAni = false;
//StartCoroutine(IEElectricWire());
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
// Debug.Log("所有螺丝都显示");
}
//if (hit.collider.gameObject.name == "pCylinder170")
//{
// if (isplaying)
// {
// StartCoroutine(IEElectricWire());// MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
// isplaying = false;
// }
//}
}
}
if (AreAllObjectsHidden())
{
isPlayAni = false;
StartCoroutine(TapeBack());
// Debug.Log("所有螺丝都显示");
}
}
/// <summary>
@ -115,13 +146,15 @@ public class concentrator : MonoBehaviour
allls = 0;
for (int i = 0; i < ScrewObj.Length; i++)
{
if (ScrewObj[i].gameObject.GetComponent<MeshRenderer>().enabled)
if (ScrewObj[i].gameObject.GetComponent<MeshRenderer>().enabled == true)
{
//StartCoroutine(IEElectricWire());
allls++;
}
}
if (allls >= ScrewObj.Length - 1)
if (allls >=ScrewObj.Length )
{
StartCoroutine(IEElectricWire());
return true;
}
else
@ -129,31 +162,24 @@ public class concentrator : MonoBehaviour
return false;
}
}
/// <summary>
/// 集中器更换动画
/// 集中器更换动画
/// </summary>
/// <returns></returns>
IEnumerator Newconcentrator()
{
concentratorObj.gameObject.transform.DOLocalMove(oncentratorTrans.gameObject.transform.position, 1f);//3.0778f, 2.2149f, -1.4581f
yield return new WaitForSeconds(1.0f);
ConcentratorObj.gameObject.transform.DOLocalMove(oncentratorTrans.gameObject.transform.localPosition, 1f);//3.0778f, 2.2149f, -1.4581f
yield return new WaitForSeconds(1f);
}
/// <summary>
/// 集线器上线动画
/// 集中器盖子后续动画
/// </summary>
/// <returns></returns>
IEnumerator IEElectricWire()
{
TapeMarCol.enabled = false;
for (int i = 0; i < 6; i++)
{
for (int a = 100; a >= 0; a--)
{
yield return new WaitForSeconds(0.01f);
ElectricWireSMR.SetBlendShapeWeight(i, a);
}
}
yield return new WaitForSeconds(1f);
Cover.gameObject.SetActive(true);
yield return new WaitForSeconds(0.5f);
@ -165,24 +191,103 @@ public class concentrator : MonoBehaviour
}
/// <summary>
/// 胶带还原动画
/// 第一个螺丝和第二个安装完成后卸下胶带和电线安装的动画
/// </summary>
/// <returns></returns>
IEnumerator TapeBack()
IEnumerator TapeBackFrist()
{
TapeMarCol.enabled = true;
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p6", 0);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p5", 0);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p4", 0);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p3", 0);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p2", 0);
yield return new WaitForSeconds(1f);
TapeMar.SetFloat("_step_p1", 0);
yield return new WaitForSeconds(1f);
if (ElectricWireSMR.GetBlendShapeWeight(0)!=0&& ElectricWireSMR.GetBlendShapeWeight(0)==100)
{
for (int i = 100; i >= 0; i--)
{
yield return new WaitForSeconds(0.01f);
ElectricWireSMR.SetBlendShapeWeight(0, i);
}
}
}
IEnumerator TapeBackSecond()
{
TapeMar.SetFloat("_step_p2", 0);
if (ElectricWireSMR.GetBlendShapeWeight(1) != 0 && ElectricWireSMR.GetBlendShapeWeight(1) == 100)
{
for (int i = 100; i >= 0; i--)
{
yield return new WaitForSeconds(0.01f);
ElectricWireSMR.SetBlendShapeWeight(1, i);
}
}
}
IEnumerator TapeBackThird()
{
TapeMar.SetFloat("_step_p3", 0);
if (ElectricWireSMR.GetBlendShapeWeight(2) != 0 && ElectricWireSMR.GetBlendShapeWeight(2) == 100)
{
for (int i = 100; i >= 0; i--)
{
yield return new WaitForSeconds(0.01f);
ElectricWireSMR.SetBlendShapeWeight(2, i);
}
}
}
IEnumerator TapeBackFourth()
{
TapeMar.SetFloat("_step_p4", 0);
if (ElectricWireSMR.GetBlendShapeWeight(3) != 0 && ElectricWireSMR.GetBlendShapeWeight(3) == 100)
{
for (int i = 100; i >= 0; i--)
{
yield return new WaitForSeconds(0.01f);
ElectricWireSMR.SetBlendShapeWeight(3, i);
}
}
}
IEnumerator TapeBackFifth()
{
TapeMar.SetFloat("_step_p5", 0);
if (ElectricWireSMR.GetBlendShapeWeight(4) != 0 && ElectricWireSMR.GetBlendShapeWeight(4) == 100)
{
for (int i = 100; i >= 0; i--)
{
yield return new WaitForSeconds(0.01f);
ElectricWireSMR.SetBlendShapeWeight(4, i);
}
}
}
IEnumerator TapeBackSixth()
{
TapeMar.SetFloat("_step_p6", 0);
if (ElectricWireSMR.GetBlendShapeWeight(5) != 0 && ElectricWireSMR.GetBlendShapeWeight(5) == 100)
{
for (int i = 100; i >= 0; i--)
{
yield return new WaitForSeconds(0.01f);
ElectricWireSMR.SetBlendShapeWeight(5, i);
}
}
}
/// <summary>
/// 胶带还原&和电线还原动画
/// </summary>
/// <returns></returns>
//IEnumerator IETapeBackFrist()
//{
// yield return new WaitForSeconds(1f);
// TapeMar.SetFloat("_step_p6", 0);
// yield return new WaitForSeconds(1f);
// TapeMar.SetFloat("_step_p5", 0);
// yield return new WaitForSeconds(1f);
// TapeMar.SetFloat("_step_p4", 0);
// yield return new WaitForSeconds(1f);
// TapeMar.SetFloat("_step_p3", 0);
// yield return new WaitForSeconds(1f);
// TapeMar.SetFloat("_step_p2", 0);
// yield return new WaitForSeconds(1f);
// TapeMar.SetFloat("_step_p1", 0);
// yield return new WaitForSeconds(1f);
//}
}

View File

@ -52,10 +52,10 @@ public class Fieldobservation : MonoBehaviour
/// </summary>
public BoxCollider guimenkashuan;
/// <summary>
/// 透明盖子上的封印
/// </summary>
public GameObject[] parentoverSeal;
///// <summary>
///// 透明盖子上的封印
///// </summary>
//public GameObject[] parentoverSeal;
/// <summary>
/// µçÏäÃÅ
@ -109,26 +109,8 @@ public class Fieldobservation : MonoBehaviour
}
if (hit.collider.gameObject.name == "透明盖子封印碰撞R")
{
if (isbox)
{
parentoverSeal[0].gameObject.SetActive(true);
isbox = false;
}
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
if (hit.collider.gameObject.name == "透明盖子封印碰撞L")
{
if (isbox)
{
parentoverSeal[1].gameObject.SetActive(true);
guimenkashuan.enabled = true;
isbox = false;
}
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
if (hit.collider.gameObject.name == "柜门卡栓")
if (hit.collider.gameObject.name == "变电箱_门")
{
StartCoroutine(IEguimenkashuan());
//if (isbox)
@ -138,12 +120,7 @@ public class Fieldobservation : MonoBehaviour
// }
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
if (hit.collider.gameObject.name == "电柜门封印box碰撞")
{
fengy.gameObject.SetActive(true);
fengy.transform.localPosition = new Vector3(0.6371536f, 0.02661133f, -0.01525164f);
MotionEngine.GetModule<AnimationProcessManager>().HandleClick(hit.collider.gameObject.name);
}
}
}
}
@ -207,6 +184,6 @@ public class Fieldobservation : MonoBehaviour
guimen.gameObject.transform.DOLocalRotate(new Vector3(-90, 0, 0), 1);
yield return new WaitForSeconds(1.1f);
mensuo01.gameObject.transform.DOLocalRotate(new Vector3(0, 0, 0), 1);
guimenkashuan.gameObject.GetComponent<BoxCollider>().enabled = true;
}
}