You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
122 lines
3.3 KiB
122 lines
3.3 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System;
|
|
using DG.Tweening;
|
|
using LzFramework;
|
|
using Newtonsoft.Json;
|
|
|
|
namespace CpuIII
|
|
{
|
|
/// <summary>
|
|
/// cpu 控制
|
|
/// </summary>
|
|
public class CpuControll : MonoBehaviour
|
|
{
|
|
|
|
|
|
public List<CpuUnitInfo> cpu_units;
|
|
|
|
|
|
private CpuUnitInfoConfig cpuUnitInfoConfig;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
WebGLConfiguratiobReader webGLConfiguratiobReader = new WebGLConfiguratiobReader("Config/cpuConfig.json");
|
|
CoroutineManager.Singleton.CreateCoroutine(webGLConfiguratiobReader.ReadCoroutine(),
|
|
() =>
|
|
{
|
|
Debug.LogFormat("On Start");
|
|
}, (finish) => {
|
|
Debug.LogFormat("On Finish");
|
|
cpuUnitInfoConfig = JsonConvert.DeserializeObject<CpuUnitInfoConfig>(webGLConfiguratiobReader.ReadResult);
|
|
Debug.LogFormat("ReadResult {0}", webGLConfiguratiobReader.ReadResult);
|
|
Debug.LogFormat("cpuUnitInfoConfig {0}", cpuUnitInfoConfig.cpuInfos.Count);
|
|
StartCoroutine(AnimatorProgress());
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 动画进度
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
IEnumerator AnimatorProgress()
|
|
{
|
|
float delayTime = 0.3f;
|
|
for (int i = 0; i < cpu_units.Count; i++)
|
|
{
|
|
|
|
cpu_units[i].target.gameObject.SetActive(true);
|
|
|
|
yield return new WaitForSeconds(delayTime);
|
|
|
|
Outline outline = cpu_units[i].target.gameObject.GetComponent<Outline>();
|
|
|
|
if(outline!=null)
|
|
outline.enabled = false;
|
|
|
|
delayTime = delayTime - i * 0.1f;
|
|
if (delayTime < 0)
|
|
delayTime = 0.01f;
|
|
}
|
|
yield return new WaitForSeconds(0.2f);
|
|
|
|
StartCoroutine(ShowOutLineProgress());
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示外发光
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
IEnumerator ShowOutLineProgress()
|
|
{
|
|
yield return new WaitForSeconds(3.0f);
|
|
|
|
for(int i = 0;i< cpu_units.Count; i++)
|
|
{
|
|
for(int j = 0;j< cpuUnitInfoConfig.cpuInfos.Count; j++)
|
|
{
|
|
if(string.Equals(cpu_units[i].name, cpuUnitInfoConfig.cpuInfos[j]))
|
|
{
|
|
Outline outline = cpu_units[i].target.gameObject.GetComponent<Outline>();
|
|
|
|
|
|
if (outline != null)
|
|
{
|
|
outline.enabled = true;
|
|
MeshRenderer mesh = cpu_units[i].target.GetComponent<MeshRenderer>();
|
|
outline.FadeColor();
|
|
|
|
}
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
|
|
[Serializable]
|
|
public class CpuUnitInfo
|
|
{
|
|
public string name;
|
|
|
|
public Transform target;
|
|
|
|
public Color outLineColor;
|
|
}
|
|
|
|
public class CpuUnitInfoConfig
|
|
{
|
|
public List<string> cpuInfos;
|
|
}
|
|
}
|
|
|