using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; using UnityEngine.UI; using GameConfig.giftConfig; using TEngine; namespace GameLogic { public class UITopTipsItem : MonoBehaviour { private Text m_Name; private Text m_Info; private Image m_Img; void Awake() { m_Name = transform.Find("Name").GetComponent(); m_Info = transform.Find("Info").GetComponent(); m_Img = transform.GetComponent(); } public void OnInit(UnitPlayerData unitPlayerData, GiftConfig giftConfig, int num) { m_Name.text = unitPlayerData.protCustMessageData.nickName; if (giftConfig == null) { m_Info.text = "成为超级大球球"; } else { m_Info.text = "增加神秘力量"; } int id = Random.Range(1, 4); m_Img.sprite = GameModule.Resource.LoadAsset("DM_" + id); // DM_1 5FFE5F // DM_2 6AE1FF // DM_3 F8E967 switch (id) { case 1: ColorUtility.TryParseHtmlString("#5FFE5F", out Color color1); m_Info.color = color1; break; case 2: ColorUtility.TryParseHtmlString("#6AE1FF", out Color color2); m_Info.color = color2; break; case 3: ColorUtility.TryParseHtmlString("#F8E967", out Color color3); m_Info.color = color3; break; } transform.DOLocalMoveX(-600, 4f).SetEase(Ease.Linear).OnComplete(() => { if (this != null && this.gameObject != null && transform.parent != null) { Destroy(gameObject); } }); } } }