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.
96 lines
2.0 KiB
96 lines
2.0 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using LzFramework;
|
|
using DG.Tweening;
|
|
namespace DisComputer
|
|
{
|
|
/*
|
|
* @func 灯光动画控制
|
|
* @author lz
|
|
* @date 2020/07/14
|
|
*
|
|
*/
|
|
public class GamePCLighter : Singleton<GamePCLighter>
|
|
{
|
|
|
|
|
|
//主灯光
|
|
public Light _main_light;
|
|
|
|
public Color[] colors;
|
|
|
|
public List<SpareLightConfig> spareLightConfigs;
|
|
|
|
private Light[] lights;
|
|
|
|
private Tween lightTw;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
lights = transform.GetComponentsInChildren<Light>();
|
|
HideLight();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 设置灯光颜色
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void SetLightColor(string name)
|
|
{
|
|
|
|
for(int i = 0;i < spareLightConfigs.Count; i++)
|
|
{
|
|
|
|
if(spareLightConfigs[i].name == name)
|
|
{
|
|
Debug.LogFormat("Name{0}", name);
|
|
for(int k = 0; k < lights.Length; k++)
|
|
{
|
|
lights[k].color = spareLightConfigs[i].color;
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 显示灯光
|
|
/// </summary>
|
|
public void ShowLight()
|
|
{
|
|
this.gameObject.SetActive(true);
|
|
_main_light.intensity = 8;
|
|
|
|
lightTw = _main_light.DOIntensity(20, 1.0f).SetEase(Ease.Linear).SetLoops(-1,LoopType.Yoyo);
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 隐藏灯光
|
|
/// </summary>
|
|
public void HideLight()
|
|
{
|
|
lightTw.Kill();
|
|
this.gameObject.SetActive(false);
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
[System.Serializable]
|
|
public class SpareLightConfig
|
|
{
|
|
public string name;
|
|
|
|
public Color color;
|
|
}
|
|
}
|
|
|