using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
namespace DisComputer
{
///
/// 基础控制单元
/// by lz
///
public class BasicUnit : MonoBehaviour
{
[Header("闪动颜色值")]
public Color shakeColor = new Color(243.0f / 255.0f, 199.0f / 255.0f, 45.0f / 255.0f, 1.0f);
[Header("背景底图")]
public Image bg_img;
[Header("信息底图")]
public Text info_txt;
[Header("箭头指引")]
public List progressArrows;
[Header("下一个单元集")]
public GameObject nextUnit;
//初始信息字符
[SerializeField]
private string init_info_str = "";
//初始色块色值
private Color initColor;
//闪烁动画控制器
private Tween shakeTween;
// Start is called before the first frame update
public virtual void Start()
{
initColor = bg_img.color;
}
///
/// 设置单元信息
///
///
public void SetInfoTxt(string val)
{
this.info_txt.text = val;
}
///
/// 重置单元信息
///
public virtual void RewindUnit()
{
this.info_txt.text = init_info_str;
this.bg_img.color = initColor;
}
///
/// 开始闪动
///
public void ShakeUnit()
{
shakeTween = bg_img.DOColor(shakeColor, 0.5f)
.SetEase(Ease.Linear)
.SetLoops(3)
.OnComplete(()=>
{
bg_img.color = initColor;
//Debug.LogFormat("name {0} color {1}",this.gameObject.name,initColor);
});
}
///
/// 显示箭头
///
///
public void ShowArrow(int id,bool isShake = false,System.Action finish=null)
{
ProgressArrow arrow = progressArrows[id];
arrow.gameObject.SetActive(true);
arrow.PlayArrow(isShake, finish);
}
///
/// 激活此单元
///
///
public virtual void Active(params object[] data)
{
ShakeUnit();
}
public void StopUnit()
{
}
}
}