using System; using System.Collections.Generic; using UILib; using UnityEngine; using XMainClient.UI.UICommon; using XUtliPoolLib; namespace XMainClient { internal class BarrageItem : DlgBehaviourBase { private List m_colors = new List(); private List m_sizes = new List(); public IXUILabel label; public GameObject outline; public Transform cacheTrans; private BarrageQueue mQueue; private int labelWidth = 10; private Vector3 start; private Vector3 end; private float t_start; private float t_cnt; public void Awake() { this.cacheTrans = base.transform; this.label = (this.cacheTrans.GetComponent("XUILabel") as IXUILabel); this.outline = this.cacheTrans.Find("me").gameObject; this.m_colors = XSingleton.singleton.GetStringList("BarrageColors"); this.m_sizes = XSingleton.singleton.GetIntList("BarrageSize"); } public void Make(string txt, BarrageQueue queue, bool outl) { this.mQueue = queue; int index = UnityEngine.Random.Range(0, this.m_colors.Count); int fontSize = UnityEngine.Random.Range(this.m_sizes[0], this.m_sizes[1]); txt = XSingleton.singleton.StringCombine(this.m_colors[index], txt, "[-]"); this.label.SetText(txt); this.label.spriteDepth = queue.depth; this.label.fontSize = fontSize; this.label.SetDepthOffset(queue.queueCnt); this.labelWidth = this.label.spriteWidth; this.start = base.transform.localPosition; this.end = new Vector3(this.start.x - (float)(this.labelWidth * 2) - 1136f, this.start.y, this.start.z); this.t_start = Time.time; this.t_cnt = (float)BarrageDlg.MOVE_TIME; this.outline.SetActive(outl); } public void Update() { bool flag = DlgBase.singleton.IsOutScreen(this.cacheTrans.localPosition.x + (float)this.labelWidth); if (flag) { bool flag2 = this.mQueue != null; if (flag2) { this.mQueue.FadeOut(this); } DlgBase.singleton.RecycleItem(this); } else { bool flag3 = this.cacheTrans != null; if (flag3) { this.cacheTrans.localPosition = Vector3.Lerp(this.start, this.end, (Time.time - this.t_start) / this.t_cnt); } } } public void Drop() { bool flag = base.gameObject != null; if (flag) { UnityEngine.Object.Destroy(base.gameObject); } } } }