201 lines
5.9 KiB
C#
201 lines
5.9 KiB
C#
|
|
using System.Collections;
|
|||
|
|
using UnityEngine;
|
|||
|
|
using UnityEngine.Events;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>Ƥ<EFBFBD><C6A4>
|
|||
|
|
/// </summary>
|
|||
|
|
public class SkinCar : MonoBehaviour
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD>ճ<EFBFBD><D5B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
[HideInInspector] public Transform judgmentOvertakingRay;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ǰת<C7B0><D7AA><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
[HideInInspector] public GameObject leftFrontIndicator;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>ǰת<C7B0><D7AA><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
[HideInInspector] public GameObject rightFrontIndicator;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
[HideInInspector] public GameObject leftQueenIndicator;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>Һ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
[HideInInspector] public GameObject rightQueenIndicator;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
[HideInInspector] public GameObject rightWheel;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>С<EFBFBD><D0A1><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
[HideInInspector]public E_CarSizeType carSizeType;
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>˸Э<CBB8><D0AD>
|
|||
|
|
/// </summary>
|
|||
|
|
private Coroutine flashingCoroutine;
|
|||
|
|
|
|||
|
|
private void Awake()
|
|||
|
|
{
|
|||
|
|
leftQueenIndicator = transform.Find("LeftQueenIndicator").gameObject;
|
|||
|
|
rightQueenIndicator = transform.Find("RightQueenIndicator").gameObject;
|
|||
|
|
leftFrontIndicator = transform.Find("LeftFrontIndicator").gameObject;
|
|||
|
|
rightFrontIndicator = transform.Find("RightFrontIndicator").gameObject;
|
|||
|
|
rightWheel = transform.Find("Wheels/Meshes/FrontRightWheel").gameObject;
|
|||
|
|
judgmentOvertakingRay = transform.Find("JudgmentOvertakingRay").transform;
|
|||
|
|
SetAllLight(false);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>رյ<D8B1>
|
|||
|
|
/// </summary>
|
|||
|
|
public void SetAllLight(bool isTrue)
|
|||
|
|
{
|
|||
|
|
leftQueenIndicator.gameObject.SetActive(isTrue);
|
|||
|
|
rightQueenIndicator.gameObject.SetActive(isTrue);
|
|||
|
|
leftFrontIndicator.gameObject.SetActive(isTrue);
|
|||
|
|
rightFrontIndicator.gameObject.SetActive(isTrue);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0>
|
|||
|
|
/// </summary>
|
|||
|
|
public void OpenFrontLight()
|
|||
|
|
{
|
|||
|
|
leftFrontIndicator.gameObject.SetActive(true);
|
|||
|
|
rightFrontIndicator.gameObject.SetActive(true);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// ֹͣ<CDA3><D6B9>˸
|
|||
|
|
/// </summary>
|
|||
|
|
public void StopFlashing()
|
|||
|
|
{
|
|||
|
|
if(flashingCoroutine!=null)
|
|||
|
|
{
|
|||
|
|
StopCoroutine(flashingCoroutine);
|
|||
|
|
MeshRenderer[] meshRenderers = GetComponentsInChildren<MeshRenderer>();
|
|||
|
|
for (int j = 0; j < meshRenderers.Length; j++)
|
|||
|
|
{
|
|||
|
|
meshRenderers[j].material = YooAssetManager.Instance.LoadAssetSync<Material>(PackagesName.GameData, "ColorVar1_Material");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><CDB8>
|
|||
|
|
/// </summary>
|
|||
|
|
public void BodyTransparency()
|
|||
|
|
{
|
|||
|
|
MeshRenderer[] meshRenderer = GetComponentsInChildren<MeshRenderer>();
|
|||
|
|
for (int i = 0; i < meshRenderer.Length; i++)
|
|||
|
|
{
|
|||
|
|
meshRenderer[i].material = YooAssetManager.Instance.LoadAssetSync<Material>(PackagesName.GameData, "ghost");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public void BodyRecovery()
|
|||
|
|
{
|
|||
|
|
MeshRenderer[] meshRenderer = GetComponentsInChildren<MeshRenderer>();
|
|||
|
|
for (int i = 0; i < meshRenderer.Length; i++)
|
|||
|
|
{
|
|||
|
|
meshRenderer[i].material = YooAssetManager.Instance.LoadAssetSync<Material>(PackagesName.GameData, "ColorVar1_Material");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>˸
|
|||
|
|
/// </summary>
|
|||
|
|
public void Flashing(string materialName,UnityAction unityAction)
|
|||
|
|
{
|
|||
|
|
flashingCoroutine=StartCoroutine(IE_Flashing(materialName,unityAction));
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><>˸Э<CBB8><D0AD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private IEnumerator IE_Flashing(string materialName, UnityAction callBack)
|
|||
|
|
{
|
|||
|
|
UIManager.Instance.GetUI<GameUI>().SetShimmerCountDownSetActive(true);
|
|||
|
|
MeshRenderer[] meshRenderers = GetComponentsInChildren<MeshRenderer>();
|
|||
|
|
for (int i = 0; i < 10; i++)
|
|||
|
|
{
|
|||
|
|
for (int j = 0; j < meshRenderers.Length; j++)
|
|||
|
|
{
|
|||
|
|
meshRenderers[j].material = YooAssetManager.Instance.LoadAssetSync<Material>(PackagesName.GameData, materialName);
|
|||
|
|
}
|
|||
|
|
yield return new WaitForSeconds(0.2f);
|
|||
|
|
for (int j = 0; j < meshRenderers.Length; j++)
|
|||
|
|
{
|
|||
|
|
meshRenderers[j].material = YooAssetManager.Instance.LoadAssetSync<Material>(PackagesName.GameData, "ColorVar1_Material");
|
|||
|
|
}
|
|||
|
|
yield return new WaitForSeconds(0.2f);
|
|||
|
|
}
|
|||
|
|
callBack?.Invoke();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// ʹ<><CAB9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public void USE()
|
|||
|
|
{
|
|||
|
|
StartCoroutine(IE_USE());
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// ʹ<>ó<EFBFBD>Э<EFBFBD><D0AD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
private IEnumerator IE_USE()
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < 2; i++)
|
|||
|
|
{
|
|||
|
|
leftFrontIndicator.gameObject.SetActive(false);
|
|||
|
|
rightFrontIndicator.gameObject.SetActive(false);
|
|||
|
|
yield return new WaitForSeconds(0.1f);
|
|||
|
|
leftFrontIndicator.gameObject.SetActive(true);
|
|||
|
|
rightFrontIndicator.gameObject.SetActive(true);
|
|||
|
|
yield return new WaitForSeconds(0.1f);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnEnable()
|
|||
|
|
{
|
|||
|
|
if (leftQueenIndicator != null)
|
|||
|
|
{
|
|||
|
|
leftQueenIndicator.gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
if (rightQueenIndicator != null)
|
|||
|
|
{
|
|||
|
|
rightQueenIndicator.gameObject.SetActive(false);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת
|
|||
|
|
/// </summary>
|
|||
|
|
public void RightWheelSpin()
|
|||
|
|
{
|
|||
|
|
if (Scenes.Instance.e_GameState == E_GameState.GameVictory)
|
|||
|
|
{
|
|||
|
|
rightWheel.transform.Rotate(Vector3.right * 800 * Time.deltaTime);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|