using UnityEngine; using UnityEngine.UI; using System.Collections; using System.Collections.Generic; public class ChatBarReplayItem : ItemRenderer { public Text titleTxt; public Text timeTxt; public Transform blueList; public Transform redList; public Transform shareBtnTrans; public Text shareBtnLabel; public Transform playBtnTrans; public Text playBtnLabel; private ChatMsg chatMsg; void Awake() { shareBtnLabel.text = Language.GetStr ("Public", "share"); playBtnLabel.text = Language.GetStr ("Public", "watch"); } public override object data { get { return base.data; } set { base.data = value; chatMsg = value as ChatMsg; if (chatMsg != null) { titleTxt.text = UserCache.GetNick (chatMsg.sender) + Language.GetStr ("ChatPanel", "replayTitle"); timeTxt.text = chatMsg.GetTimeStr (); ReplayInfo replayInfo = chatMsg.GetReplayInfo (); int blueCount = 0; int redCount = 0; List playerList = replayInfo.playerList; for(int i=0; i= blueList.childCount) continue; Text txt = blueList.GetChild (blueCount).GetComponent(); txt.text = player.nick; blueCount++; } else if(player.team == TeamUtil.Team.Red) { if (redCount >= redList.childCount) continue; Text txt = redList.GetChild (redCount).GetComponent(); txt.text = player.nick; redCount++; } } for(int i=blueCount; i(); txt.text = ""; } for(int i=redCount; i(); txt.text = ""; } playBtnTrans.gameObject.SetActive (true); shareBtnTrans.gameObject.SetActive (chatMsg.id <= 0); } else { shareBtnTrans.gameObject.SetActive (false); playBtnTrans.gameObject.SetActive (false); } } } public void Share() { ChatManager.GetInstance ().ShareReplayMsg (chatMsg, this); } public void Play() { if (chatMsg != null) { LoadingPanel loadingPanel = LoadingPanel.Show(false); loadingPanel.ReachTargetProgress.AddListener (StartReplay); LoadingPanel.Increase(0.1f); } } private void StartReplay() { LoadingPanel.GetCurrentPanel().ReachTargetProgress.RemoveListener (StartReplay); if (chatMsg != null) { string fileName = chatMsg.extra; ReplayManager.GetInstance ().Load (fileName); } else { LoadingPanel.Complete (null); } } }