From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- Client/Assets/Scripts/XMainClient/BarrageItem.cs | 92 ++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/BarrageItem.cs (limited to 'Client/Assets/Scripts/XMainClient/BarrageItem.cs') diff --git a/Client/Assets/Scripts/XMainClient/BarrageItem.cs b/Client/Assets/Scripts/XMainClient/BarrageItem.cs new file mode 100644 index 00000000..f66f121d --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/BarrageItem.cs @@ -0,0 +1,92 @@ +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); + } + } + } +} -- cgit v1.1-26-g67d0