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.

206 lines
4.6 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
namespace DisComputer
{
/// <summary>
/// 联合体
/// </summary>
public class ComboomItem : MonoBehaviour
{
[Header("地址背景图")]
public Image add_img;
[Header("地址文本")]
public Text add_txt;
[Header("数据背景图")]
public Image data_img;
[Header("数据文本")]
public Text data_txt;
public ProgressArrow progressArrow;
public Color shakeColor;
private Color initColor;
//模糊遮罩
public Image mask_img;
// Start is called before the first frame update
void Start()
{
initColor = data_img.color;
}
/// <summary>
/// 激活指令
/// </summary>
/// <param name="data"></param>
public void CommandAct(CommandData data,System.Action finishhandle=null)
{
Tween tween = data_img.DOColor(shakeColor, 0.5f)
.SetEase(Ease.Linear)
.SetLoops(-1);
data_txt.text = data.ActName;
if (progressArrow != null)
{
progressArrow.gameObject.SetActive(true);
progressArrow.PlayArrow(false,()=>
{
tween.Kill();
data_img.color = initColor;
finishhandle?.Invoke();
});
}
}
/// <summary>
/// 指令激活
/// </summary>
/// <param name="data"></param>
public void CommandAct(string data, System.Action finishhandle = null)
{
data_txt.text = data;
if (progressArrow != null)
{
Tween tween = data_img.DOColor(shakeColor, 0.5f)
.SetEase(Ease.Linear)
.SetLoops(-1);
progressArrow.gameObject.SetActive(true);
progressArrow.PlayArrow(false,() =>
{
tween.Kill();
data_img.color = initColor;
});
}else
{
Tween tween = data_img.DOColor(shakeColor, 0.5f)
.SetEase(Ease.Linear)
.SetLoops(3).OnComplete(()=>
{
data_img.color = initColor;
});
}
}
/// <summary>
/// 地址激活
/// </summary>
/// <param name="data"></param>
public void AddressAct(string add ="")
{
if (!string.IsNullOrEmpty(add))
add_txt.text = add;
add_img.DOColor(shakeColor, 0.5f)
.SetEase(Ease.Linear)
.SetLoops(3)
.OnComplete(() => {
add_img.color = initColor;
});
}
/// <summary>
/// 地址激活
/// </summary>
/// <param name="data"></param>
public void AddressAct(bool isColor,string add = "")
{
if (!string.IsNullOrEmpty(add))
add_txt.text = add;
if (isColor)
add_txt.color = shakeColor;
}
/// <summary>
/// 指令内容设置
/// </summary>
public void SetCommandVal(string val,bool isColor = false)
{
data_txt.text = val;
if (isColor)
data_txt.color = shakeColor;
}
Tween mask_tween;
/// <summary>
/// 模糊遮罩loop
/// </summary>
public void MaskShake()
{
mask_img.gameObject.SetActive(true);
mask_img.color = new Color(1.0f, 1.0f, 1.0f, 0.83f);
mask_tween = mask_img.DOFade(1.0f, 1.5f)
.SetEase(Ease.Linear)
.SetLoops(-1,LoopType.Yoyo);
}
/// <summary>
/// 清理模糊遮罩
/// </summary>
public void ClearMask()
{
mask_tween.Kill();
Tween clearTw = mask_img.DOFade(.0f,0.75f).SetEase(Ease.Linear);
}
/// <summary>
/// 复原
/// </summary>
public void Rewind(int type)
{
add_img.color = initColor;
data_img.color = initColor;
if(type == 0)
data_txt.text = "";
else
data_txt.text = "";
if(mask_img!=null)
mask_img.gameObject.SetActive(false);
if (progressArrow != null)
progressArrow.SetArrowZero();
}
}
}