using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; namespace BF { public class BattleSkillToast : MonoBehaviour { static int NORMAL_ADD_WIDTH = 60; static int LEGACY_ADD_WIDTH = 20; public Animator animator; public Transform normalBg; public Atlas skillAtlas; public Image skillIcon; public TMPro.TextMeshProUGUI normalText; public Transform legacyBg; public Atlas legacyAtlas; public Image legacyQltIcon; public Image legacyIcon; public TMPro.TextMeshProUGUI legacyText; private float putbackTime = 0; private bool isPause = false; [System.NonSerialized] public int ColorType = 0; private void Update() { if (isPause) { return; } putbackTime -= Time.deltaTime; if (putbackTime <= 0.0f) { BFMain.Instance.BattleMgr.PoolHelper.PutBackSkillToast(this); } } public void ShowNormalSkillToast(string spriteName, string desc) { putbackTime = 2;//BattleTMPNumber.PUT_BACK_TIME; // TODOJ normalBg.transform.localScale = Vector3.one; legacyBg.transform.localScale = Vector3.zero; var hashName = Utils.BKDRHash(spriteName); skillIcon.sprite = skillAtlas.GetSprite(hashName); normalText.text = desc; var preferredWidth = normalText.preferredWidth; normalText.rectTransform.sizeDelta = new Vector2(preferredWidth, normalText.rectTransform.sizeDelta.y); normalBg.GetComponent().sizeDelta = new Vector2(preferredWidth + NORMAL_ADD_WIDTH, normalBg.GetComponent().sizeDelta.y); animator.Play(BattleConst.ANIMATOR_HAS_NAME_SKILL_TOAST, -1, 0); } public void ShowLegacySkillToast(string qltName, string iconName, string desc) { putbackTime = 2;//BattleTMPNumber.PUT_BACK_TIME; // TODOJ normalBg.transform.localScale = Vector3.zero; legacyBg.transform.localScale = Vector3.one; var qltHashName = Utils.BKDRHash(qltName); var iconHashName = Utils.BKDRHash(iconName); legacyQltIcon.sprite = skillAtlas.GetSprite(qltHashName); legacyIcon.sprite = legacyAtlas.GetSprite(iconHashName); legacyText.text = desc; var preferredWidth = legacyText.preferredWidth; legacyText.rectTransform.sizeDelta = new Vector2(preferredWidth, legacyText.rectTransform.sizeDelta.y); legacyBg.GetComponent().sizeDelta = new Vector2(preferredWidth + LEGACY_ADD_WIDTH, legacyBg.GetComponent().sizeDelta.y); animator.Play(BattleConst.ANIMATOR_HAS_NAME_SKILL_TOAST, -1, 0); } public void SetEnabled(bool enabled) { // animator.enabled = enabled; this.enabled = enabled; } public void SetPause() { isPause = true; animator.speed = 0.0f; } public void SetResume() { isPause = false; animator.speed = 1.0f; } } }