using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using DG.Tweening; namespace DisComputer { /// /// 联合体 /// 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; } /// /// 激活指令 /// /// 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(); }); } } /// /// 指令激活 /// /// 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; }); } } /// /// 地址激活 /// /// 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; }); } /// /// 地址激活 /// /// public void AddressAct(bool isColor,string add = "") { if (!string.IsNullOrEmpty(add)) add_txt.text = add; if (isColor) add_txt.color = shakeColor; } /// /// 指令内容设置 /// public void SetCommandVal(string val,bool isColor = false) { data_txt.text = val; if (isColor) data_txt.color = shakeColor; } Tween mask_tween; /// /// 模糊遮罩loop /// 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); } /// /// 清理模糊遮罩 /// public void ClearMask() { mask_tween.Kill(); Tween clearTw = mask_img.DOFade(.0f,0.75f).SetEase(Ease.Linear); } /// /// 复原 /// 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(); } } }