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.
116 lines
2.6 KiB
116 lines
2.6 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using DG.Tweening;
|
|
|
|
|
|
namespace DisComputer
|
|
{
|
|
/// <summary>
|
|
/// 基础控制单元
|
|
/// by lz
|
|
/// </summary>
|
|
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<ProgressArrow> 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;
|
|
}
|
|
/// <summary>
|
|
/// 设置单元信息
|
|
/// </summary>
|
|
/// <param name="val"></param>
|
|
public void SetInfoTxt(string val)
|
|
{
|
|
this.info_txt.text = val;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 重置单元信息
|
|
/// </summary>
|
|
public virtual void RewindUnit()
|
|
{
|
|
this.info_txt.text = init_info_str;
|
|
this.bg_img.color = initColor;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 开始闪动
|
|
/// </summary>
|
|
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);
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 显示箭头
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
public void ShowArrow(int id,bool isShake = false,System.Action finish=null)
|
|
{
|
|
ProgressArrow arrow = progressArrows[id];
|
|
arrow.gameObject.SetActive(true);
|
|
arrow.PlayArrow(isShake, finish);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 激活此单元
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
public virtual void Active(params object[] data)
|
|
{
|
|
ShakeUnit();
|
|
}
|
|
|
|
|
|
|
|
public void StopUnit()
|
|
{
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|