batteryDiagnosis/Assets/Scripts/ChangeObjMat.cs

272 lines
10 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using HighlightPlus;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class ChangeObjMat : MonoBehaviour
{
public Material m_TM;
public List<MeshRenderer> m_RendererList;
private List<List<Material>> m_RecordRendererList = new List<List<Material>>();
/// <summary>
/// ³µÁ¾ÎïÌå
/// </summary>
public GameObject m_Obj;
/// <summary>
/// ³µÁ¾Ïß¿ò
/// </summary>
public GameObject m_XKObj;
/// <summary>
/// ³µÅÆÉ¨Ãè
/// </summary>
public GameObject m_CPObj;
/// <summary>
/// ³µÉíɨÃè
/// </summary>
public GameObject m_CSSMObj;
/// <summary>
/// ºìÍâɨÃè
/// </summary>
public GameObject m_HWSMObj;
/// <summary>
/// ×ÏÍâɨÃè
/// </summary>
public GameObject m_ZWSMObj;
/// <summary>
/// ÉùÎÆ¼ì²â
/// </summary>
public GameObject m_SWJCObj;
/// <summary>
/// µç³Ø¼ì²â
/// </summary>
public GameObject m_DCJCObj;
/// <summary>
/// Ô¤Ô¼¾ùºâ
/// </summary>
public GameObject m_JHJCObj;
public HighlightEffect m_HighlightEffect;
void Start()
{
m_RendererList = GetComponentsInChildren<MeshRenderer>().ToList();
m_RecordRendererList.Clear();
for (int i = 0; i < m_RendererList.Count; i++)
{
m_RecordRendererList.Add(m_RendererList[i].materials.ToList());
}
if (Bootstrap.Instance != null) Bootstrap.Instance.eventCenter.AddEventListener<bool>(Enum_EventType.ChangeChildrenMat, ChangeChildrenMat);
if (Bootstrap.Instance != null) Bootstrap.Instance.eventCenter.AddEventListener(Enum_EventType.StepSwitching, StepSwitching);
ChangeChildrenMat(true);
}
public void ChangeChildrenMat(bool Change)
{
if (Change)
{
for (int i = 0; i < m_RendererList.Count; i++)
{
int len = m_RendererList[i].materials.Length;
Material[] matArr = new Material[len];
for (int j = 0; j < len; j++)
{
matArr[j] = m_TM;
}
for (int j = 0; j < len; j++)
{
m_RendererList[i].materials = matArr;
}
}
}
else
{
for (int i = 0; i < m_RecordRendererList.Count; i++)
{
List<Material> materialList = m_RecordRendererList[i];
m_RendererList[i].materials = materialList.ToArray();
}
}
}
public void StepSwitching()
{
StartCoroutine(StepSwitchingCoroutine());
}
IEnumerator StepSwitchingCoroutine()
{
Debug.Log("StepSwitchingCoroutine");
#region ³µÁ¾È볡
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"ÄúµÄ°®³µÒÑÈ볡£¡", 3);
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"³µÁ¾È볡");
});
yield return new WaitForSeconds(3);
#endregion
#region ³µÅÆÊ±ð
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"³µÅÆÊ¶±ð");
m_XKObj.SetActive(true);
m_CPObj.SetActive(true);
m_Obj.SetActive(false);
yield return new WaitForSeconds(5);
m_CPObj.SetActive(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"¼ì²âµ½³µÅƺÅΪ" + GetawayMqttClient.licensePlateData.LicensePlateNumber + "£¡", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region ³µÉíÍâ¹Û¼ì²â
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"ÏÖÔÚ½øÈë³µÉíÍâ¹Û¼ì²â»·½Ú1.Éî¶È¼ì²âÒÑ¿ªÊ¼£¡", 5);
});
yield return new WaitForSeconds(5);
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"³µÉíÍâ¹Û¼ì²â");
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"2.³µÍâ¹Û¼ì²â¿ªÊ¼£¡", 3);
});
yield return new WaitForSeconds(3);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"3.ÄúµÄ°®³µÕý½øÐгµÍâ¹Û¼ì²â...", 10);
});
m_CSSMObj.SetActive(true);
yield return new WaitForSeconds(11);
m_CSSMObj.SetActive(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"³µÍâ¹Û¼ì²âÒÑÍê³É£¡", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region ºìÍâʵʱ̽²â
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"³µÁ¾¼´½«½øÐкìÍâʵʱ̽²â£º1.ºìÍâ¼ì²âÒÑ¿ªÊ¼£¡", 3);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"ºìÍâʵʱ̽²â");
yield return new WaitForSeconds(3);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"2.ÄúµÄ°®³µÕý½øÐкìÍâ¼ì²â...", 10);
});
m_HighlightEffect.SetHighlighted(true);
m_HWSMObj.SetActive(true);////
yield return new WaitForSeconds(11);
m_HWSMObj.SetActive(false);////
m_HighlightEffect.SetHighlighted(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"3ºìÍâ¼ì²âÒÑÍê³É£¡", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region ×ÏÍâʵʱ̽²â
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"³µÁ¾¼´½«½øÐÐ×ÏÍâʵʱ̽²â£º1.×ÏÍâ¼ì²âÒÑ¿ªÊ¼£¡", 3);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"×ÏÍâʵʱ̽²â");
yield return new WaitForSeconds(3);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"2.ÄúµÄ°®³µÕý½øÐÐ×ÏÍâ¼ì²â...", 10);
});
m_HighlightEffect.SetHighlighted(true);
m_ZWSMObj.SetActive(true);////
yield return new WaitForSeconds(11);
m_ZWSMObj.SetActive(false);////
m_HighlightEffect.SetHighlighted(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"3.×ÏÍâ¼ì²âÒÑÍê³É£¡", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region ÉùÎÆ¼ì²â
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"³µÁ¾½øÐÐÉùÎÆ¼ì²â£º1.ÉùÎÆ¼ì²âÒÑ¿ªÊ¼£¡", 3);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"ÉùÎÆ¼ì²â");
yield return new WaitForSeconds(3);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"2.ÄúµÄ°®³µÕý½øÐÐÉùÎÆ¼ì²â...", 10);
});
m_SWJCObj.SetActive(true);////
yield return new WaitForSeconds(11);
m_SWJCObj.SetActive(false);////
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"3.ÉùÎÆ¹Û¼ì²âÒÑÍê³É£¡", 5);
});
yield return new WaitForSeconds(6);
#endregion
#region Éîȼì²â±¨¸æ
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"¾ùºâÒ»Ìå»ú¼ì²â×¼±¸£º1.µç³Ø¼ì²âÒÑ¿ªÊ¼£¡", 5);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"µç³Ø¼ì²â");
yield return new WaitForSeconds(5);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"2.ÄúµÄ°®³µÕý½øÐÐµç³Ø¼ì²â...", 10);
});
m_HighlightEffect.SetHighlighted(true);
m_DCJCObj.SetActive(true);////
yield return new WaitForSeconds(11);
m_DCJCObj.SetActive(false);////
m_HighlightEffect.SetHighlighted(false);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"3.µç³Ø¼ì²âÒÑÍê³É£¡", 3);
});
yield return new WaitForSeconds(4);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"4.Éî¶È¼ì²âÒÑÍê³É£¡", 5);
});
yield return new WaitForSeconds(6);
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"5.Éî¶È¼ì²â±¨¸æÒÑÉú³É£¬ÇëɨÃèÆÁÄ»ÓÒϽǵĶþάÂë»ñÈ¡£¡", 30);
});
yield return new WaitForSeconds(31);
#endregion
#region Ô¤Ô¼¾ùºâ
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"ÄúÒÑÔ¤Ô¼µç³Ø¾ùºâ²Ù×÷£¬ÇëÉÔµÈ...", 30);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"Ô¤Ô¼¾ùºâ");
m_HighlightEffect.SetHighlighted(true);
m_JHJCObj.SetActive(true);
yield return new WaitForSeconds(31);
m_JHJCObj.SetActive(false);
m_HighlightEffect.SetHighlighted(false);
#endregion
#region ¾ùºâ±¨¸æ
if (Bootstrap.UIMgr != null) Bootstrap.UIMgr.ShowPanel<UI_MiddleTipPanel>(this, E_UI_Layer.System, (p) =>
{
p.Init($"µç³Ø¾ùºâ²Ù×÷ÒÑÍê³É£¬ÇëɨÃèÆÁÄ»ÓÒϽǵĶþάÂë»ñÈ¡¾ùºâ±¨¸æ£¡¸ÐлÄúµÄÖ§³ÖºÍÅäºÏ£¬×£Äúһ·ƽ°²£¡", 0);
});
Bootstrap.Instance.eventCenter.EventTrigger(Enum_EventType.AudioPlay, $"µç³ØÕïËù¼ì²â¼°¾ùºâÈ«Á÷³ÌÒÑÍê³É");
m_XKObj.SetActive(false);
m_Obj.SetActive(true);
#endregion
}
private void OnDisable()
{
if (Bootstrap.Instance != null)
{
Bootstrap.Instance.eventCenter.RemoveEventListener<bool>(Enum_EventType.ChangeChildrenMat, ChangeChildrenMat);
Bootstrap.Instance.eventCenter.RemoveEventListener(Enum_EventType.StepSwitching, StepSwitching);
}
}
}