using System; using System.Collections.Generic; using KKSG; using UILib; using UnityEngine; using XMainClient.UI.UICommon; using XUtliPoolLib; namespace XMainClient.UI { internal class MobaBattleHandler : DlgHandlerBase { protected override string FileName { get { return "Battle/MobaBattleHandler"; } } private XMobaBattleDocument _doc = null; private IXUISprite m_SkillTips; private IXUILabel m_SkillName; private IXUILabel m_SkillAttr; private IXUILabel m_SkillMP; private IXUILabel m_SkillCD; private IXUILabel m_SkillDesc; private IXUILabel m_BlueKill; private IXUILabel m_RedKill; private IXUILabel m_BlueLevel; private IXUILabel m_RedLevel; private IXUILabel m_MyKill; private IXUILabel m_MyDead; private IXUILabel m_MyAssist; private GameObject m_AdditionFrame; private IXUISprite[] m_AdditionBtn = new IXUISprite[3]; private IXUISprite m_DetailBtn; private GameObject m_DetailFrame; private IXUIButton m_DetailCloseBtn; private XUIPool m_RedPool = new XUIPool(XSingleton.singleton.m_uiTool); private XUIPool m_BluePool = new XUIPool(XSingleton.singleton.m_uiTool); private List _labelList = new List(); private List _uidList = new List(); private float _refreshSignTime; private IXUILabel m_ReviveLeftTime; private bool _OnDeath; private uint _additionCloseDelayToken; private XFx _addFx; private XFx _boardFx; private XFx _moveFx; private int _curExpInd = 0; private static readonly int EXPMAXCOUT = 8; private XUIPool m_ExpPool = new XUIPool(XSingleton.singleton.m_uiTool); private MobaBattleHandler.MobaExp[] m_ExpList = new MobaBattleHandler.MobaExp[MobaBattleHandler.EXPMAXCOUT]; private IXUISprite m_AttrShowBtn; public MapSignalHandler m_MapSignalHandler; private MobaHeadCondition m_headCondition; private class MobaExp { public GameObject m_Go; public IXUILabel m_Label; public IXUITweenTool m_PlayTween; public IUI3DFollow m_3DFollow; public bool state = false; public float vaildTime; public MobaExp(GameObject go) { this.m_Go = go; this.m_3DFollow = (go.GetComponent("UI3DFollow") as IUI3DFollow); this.m_Label = (go.transform.GetChild(0).GetComponent("XUILabel") as IXUILabel); this.m_PlayTween = (this.m_Label.gameObject.GetComponent("XUIPlayTween") as IXUITweenTool); go.SetActive(false); } public void SetExp(Vector3 pos, int exp) { this.m_Go.SetActive(true); this.state = true; this.m_3DFollow.SetPos(pos); this.m_Label.SetText(string.Format("jy+{0}", exp)); this.m_PlayTween.PlayTween(true, -1f); this.vaildTime = Time.realtimeSinceStartup + 1f; } } protected override void Init() { base.Init(); this._doc = XDocuments.GetSpecificDocument(XMobaBattleDocument.uuID); this.m_SkillTips = (base.transform.Find("SkillTips").GetComponent("XUISprite") as IXUISprite); this.m_SkillName = (this.m_SkillTips.transform.Find("Name").GetComponent("XUILabel") as IXUILabel); this.m_SkillAttr = (this.m_SkillTips.transform.Find("Attr").GetComponent("XUILabel") as IXUILabel); this.m_SkillMP = (this.m_SkillTips.transform.Find("MP").GetComponent("XUILabel") as IXUILabel); this.m_SkillCD = (this.m_SkillTips.transform.Find("CD").GetComponent("XUILabel") as IXUILabel); this.m_SkillDesc = (this.m_SkillTips.transform.Find("Desc").GetComponent("XUILabel") as IXUILabel); this.m_SkillTips.SetVisible(false); this.m_BlueKill = (base.transform.Find("ScoreBoard/BlueKill").GetComponent("XUILabel") as IXUILabel); this.m_RedKill = (base.transform.Find("ScoreBoard/RedKill").GetComponent("XUILabel") as IXUILabel); this.m_BlueLevel = (base.transform.Find("ScoreBoard/BlueLevel/Num").GetComponent("XUILabel") as IXUILabel); this.m_RedLevel = (base.transform.Find("ScoreBoard/RedLevel/Num").GetComponent("XUILabel") as IXUILabel); this.m_MyKill = (base.transform.Find("ScoreBoard/MyScore/Kill").GetComponent("XUILabel") as IXUILabel); this.m_MyDead = (base.transform.Find("ScoreBoard/MyScore/Dead").GetComponent("XUILabel") as IXUILabel); this.m_MyAssist = (base.transform.Find("ScoreBoard/MyScore/Assist").GetComponent("XUILabel") as IXUILabel); this.m_AdditionFrame = base.transform.Find("Addition").gameObject; for (int i = 0; i < 3; i++) { this.m_AdditionBtn[i] = (this.m_AdditionFrame.transform.Find("ADD" + i.ToString()).GetComponent("XUISprite") as IXUISprite); this.m_AdditionBtn[i].ID = (ulong)((long)i); } this.m_DetailBtn = (base.transform.Find("ScoreBoard/DetailBtn").GetComponent("XUISprite") as IXUISprite); this.m_DetailFrame = base.transform.Find("DetailFrame").gameObject; this.m_DetailCloseBtn = (this.m_DetailFrame.transform.Find("Close").GetComponent("XUIButton") as IXUIButton); Transform transform = this.m_DetailFrame.transform.Find("BlueTeam/BlueTpl"); this.m_BluePool.SetupPool(transform.parent.gameObject, transform.gameObject, 4u, false); transform = this.m_DetailFrame.transform.Find("RedTeam/RedTpl"); this.m_RedPool.SetupPool(transform.parent.gameObject, transform.gameObject, 4u, false); this.m_DetailFrame.SetActive(false); this.m_ReviveLeftTime = (base.transform.Find("ReviveLeftTime").GetComponent("XUILabel") as IXUILabel); this.m_ReviveLeftTime.SetVisible(false); this._OnDeath = false; this._curExpInd = 0; transform = base.transform.Find("ExpMgr/Tpl"); this.m_ExpPool.SetupPool(transform.parent.gameObject, transform.gameObject, (uint)MobaBattleHandler.EXPMAXCOUT, false); for (int j = 0; j < MobaBattleHandler.EXPMAXCOUT; j++) { GameObject go = this.m_ExpPool.FetchGameObject(false); this.m_ExpList[j] = new MobaBattleHandler.MobaExp(go); } this.m_AttrShowBtn = (base.transform.Find("AttrShowBtn").GetComponent("XUISprite") as IXUISprite); DlgHandlerBase.EnsureCreate(ref this.m_headCondition, base.transform.Find("condition").gameObject, this, true); DlgHandlerBase.EnsureCreate(ref this.m_MapSignalHandler, base.transform.Find("MapSignalHandler").gameObject, this, true); } public override void RegisterEvent() { base.RegisterEvent(); for (int i = 0; i < 3; i++) { this.m_AdditionBtn[i].RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAdditionBtnClick)); } this.m_DetailBtn.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnShowDetailBtnClick)); this.m_DetailCloseBtn.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCloseDetailBtnClick)); this.m_SkillTips.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnSkillTipsCloseClick)); this.m_AttrShowBtn.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAttrShowBtnClick)); } public override void OnUnload() { bool flag = this._addFx != null; if (flag) { XSingleton.singleton.DestroyFx(this._addFx, true); } bool flag2 = this._boardFx != null; if (flag2) { XSingleton.singleton.DestroyFx(this._boardFx, true); } bool flag3 = this._moveFx != null; if (flag3) { XSingleton.singleton.DestroyFx(this._moveFx, true); } XSingleton.singleton.KillTimer(this._additionCloseDelayToken); DlgHandlerBase.EnsureUnload(ref this.m_headCondition); DlgHandlerBase.EnsureUnload(ref this.m_MapSignalHandler); base.OnUnload(); } protected override void OnShow() { base.OnShow(); } public void RefreshMyScore() { bool flag = this._doc.MyData != null; if (flag) { this.m_MyKill.SetText(this._doc.MyData.kill.ToString()); this.m_MyDead.SetText(this._doc.MyData.dead.ToString()); this.m_MyAssist.SetText(this._doc.MyData.assist.ToString()); } } public void RefreshBattleMsg() { this.m_BlueKill.SetText(this._doc.MyTeamkill.ToString()); this.m_BlueLevel.SetText(this._doc.MyTeamLevel.ToString()); this.m_RedKill.SetText(this._doc.OtherTeamKill.ToString()); this.m_RedLevel.SetText(this._doc.OtherTeamLevel.ToString()); } public void OnAdditionBtnClick(IXUISprite iSp) { this._doc.QueryAdditionLevelUp((int)iSp.ID); } public void OnShowDetailBtnClick(IXUISprite iSp) { this.m_DetailFrame.SetActive(true); this.SetupDetailMsg(); } public bool OnCloseDetailBtnClick(IXUIButton btn) { this.m_DetailFrame.SetActive(false); return true; } public void SetGetExpAnimation(uint exp, uint posxz) { Vector3 pos; pos= new Vector3((posxz >> 16) / 100f, 0f, (posxz & 65535u) / 100f); int curExpInd = this._curExpInd; this._curExpInd = (this._curExpInd + 1) % MobaBattleHandler.EXPMAXCOUT; this.m_ExpList[this._curExpInd].SetExp(pos, (int)exp); } public void SetupDetailMsg() { bool flag = !this.m_DetailFrame.activeInHierarchy; if (!flag) { this.m_BluePool.FakeReturnAll(); this.m_RedPool.FakeReturnAll(); this._labelList.Clear(); this._uidList.Clear(); int num = 0; int num2 = 0; bool flag2 = this._doc.MyData == null; if (flag2) { XSingleton.singleton.AddErrorLog("show detail msg error. mydata is null.", null, null, null, null, null); } else { this.SetupSingleDetail(this._doc.MyData, true, num++); int i = 0; int count = this._doc.MobaData.BufferValues.Count; while (i < count) { bool flag3 = this._doc.MobaData.BufferValues[i].uid == this._doc.MyData.uid; if (!flag3) { bool flag4 = this._doc.MobaData.BufferValues[i].teamID == this._doc.MyData.teamID; if (flag4) { this.SetupSingleDetail(this._doc.MobaData.BufferValues[i], true, num++); } else { this.SetupSingleDetail(this._doc.MobaData.BufferValues[i], false, num2++); } } i++; } this.m_BluePool.ActualReturnAll(false); this.m_RedPool.ActualReturnAll(false); } } } public void SetupSingleDetail(MobaMemberData data, bool isBlue, int index) { GameObject gameObject = isBlue ? this.m_BluePool.FetchGameObject(false) : this.m_RedPool.FetchGameObject(false); OverWatchTable.RowData dataByHeroID = XHeroBattleDocument.GetDataByHeroID(data.heroID); gameObject.transform.localPosition = new Vector3(this.m_BluePool.TplPos.x, this.m_BluePool.TplPos.y - (float)(this.m_BluePool.TplHeight * index)); this._uidList.Add(data.uid); this._labelList.Add(gameObject.transform.Find("TIME").GetComponent("XUILabel") as IXUILabel); IXUISprite ixuisprite = gameObject.transform.Find("HeroIcon").GetComponent("XUISprite") as IXUISprite; GameObject gameObject2 = gameObject.transform.Find("UnSelect").gameObject; bool flag = dataByHeroID == null; if (flag) { ixuisprite.SetVisible(false); gameObject2.SetActive(true); } else { ixuisprite.SetVisible(true); gameObject2.SetActive(false); ixuisprite.SetSprite(dataByHeroID.Icon, dataByHeroID.IconAtlas, false); } IXUILabel ixuilabel = gameObject.transform.Find("Name").GetComponent("XUILabel") as IXUILabel; ixuilabel.SetText(data.name); IXUILabel ixuilabel2 = gameObject.transform.Find("HeroName").GetComponent("XUILabel") as IXUILabel; ixuilabel2.SetText((dataByHeroID == null) ? "" : dataByHeroID.Name); IXUILabel ixuilabel3 = gameObject.transform.Find("AttackLevel").GetComponent("XUILabel") as IXUILabel; ixuilabel3.SetText(string.Format(XStringDefineProxy.GetString("LEVEL"), data.attackLevel)); IXUILabel ixuilabel4 = gameObject.transform.Find("DefenseLevel").GetComponent("XUILabel") as IXUILabel; ixuilabel4.SetText(string.Format(XStringDefineProxy.GetString("LEVEL"), data.defenseLevel)); IXUILabel ixuilabel5 = gameObject.transform.Find("Kill").GetComponent("XUILabel") as IXUILabel; ixuilabel5.SetText(data.kill.ToString()); IXUILabel ixuilabel6 = gameObject.transform.Find("Dead").GetComponent("XUILabel") as IXUILabel; ixuilabel6.SetText(data.dead.ToString()); IXUILabel ixuilabel7 = gameObject.transform.Find("Assist").GetComponent("XUILabel") as IXUILabel; ixuilabel7.SetText(data.assist.ToString()); GameObject gameObject3 = gameObject.transform.Find("Me").gameObject; gameObject3.SetActive(data.isMy); } public void SetAdditionFrameState(bool state) { bool flag = state == this.m_AdditionFrame.activeSelf; if (!flag) { if (state) { this.m_AdditionFrame.SetActive(state); } else { XSingleton.singleton.KillTimer(this._additionCloseDelayToken); this._additionCloseDelayToken = XSingleton.singleton.SetTimer(0.15f, new XTimerMgr.ElapsedEventHandler(this.DelayCloseAdditionFrame), null); } } } public void DelayCloseAdditionFrame(object o = null) { this.m_AdditionFrame.SetActive(false); } public void ShowAdditionFx(int index) { bool flag = this._addFx != null; if (flag) { XSingleton.singleton.DestroyFx(this._addFx, true); } bool flag2 = this._boardFx != null; if (flag2) { XSingleton.singleton.DestroyFx(this._boardFx, true); } bool flag3 = this._moveFx != null; if (flag3) { XSingleton.singleton.DestroyFx(this._moveFx, true); } Transform transform = base.transform.Find(string.Format("AddFx{0}", index)); Transform transform2 = this.m_BlueLevel.gameObject.transform; this._addFx = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_xishou", transform, false); this._boardFx = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_fangkai", transform2, false); this._moveFx = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_guocheng", transform, false); this._addFx.Play(); this._boardFx.Play(); Vector3 vector = transform2.position - transform.position; float num = Vector3.Angle(Vector3.right, vector); bool flag4 = vector.y < 0f; if (flag4) { num = -num; } this._moveFx.Play(transform.transform.position, Quaternion.Euler(0f, 0f, num), Vector3.one, 1f); } public void OnSkillTipsCloseClick(IXUISprite iSp) { this.m_SkillTips.SetVisible(false); } public void ShowSkillTips(bool state, uint skillID, int skillLevel) { bool flag = XSingleton.singleton.Player == null; if (!flag) { this.m_SkillTips.SetVisible(state); if (state) { SkillList.RowData skillConfig = XSingleton.singleton.GetSkillConfig(skillID, (uint)skillLevel, XSingleton.singleton.Player.SkillCasterTypeID); bool flag2 = skillConfig == null; if (flag2) { XSingleton.singleton.AddLog("moba skill tips can't find skillconfig, skillID = ", skillID.ToString(), null, null, null, null, XDebugColor.XDebug_None); this.m_SkillTips.SetVisible(false); } else { this.m_SkillName.SetText(skillConfig.ScriptName); this.m_SkillAttr.SetText(XSkillTreeDocument.GetSkillAttrStr((int)skillConfig.Element)); this.m_SkillMP.SetText((skillConfig.CostMP[0] + skillConfig.CostMP[1] * (float)skillLevel).ToString()); bool flag3 = XSingleton.singleton.Player != null && XEntity.ValideEntity(XSingleton.singleton.Player.Transformer); string text; if (flag3) { text = string.Format("{0}s", Math.Round((double)XSkillMgr.GetCD(XSingleton.singleton.Player.Transformer, skillConfig.SkillScript, (uint)skillLevel) + 0.01, 1)); } else { text = "0s"; } this.m_SkillCD.SetText(text); this.m_SkillDesc.SetText(skillConfig.CurrentLevelDescription); } } } } public void SetOnDeath() { this._OnDeath = true; this.m_ReviveLeftTime.SetVisible(true); } public void OnAttrShowBtnClick(IXUISprite isp) { bool flag = DlgBase.singleton.IsVisible(); DlgBase.singleton.SetVisible(!flag, true); bool flag2 = this._doc.MyData == null; if (!flag2) { DlgBase.singleton.ShowByType(SceneType.SCENE_MOBA, this._doc.MyData.heroID); } } public override void OnUpdate() { base.OnUpdate(); bool flag = Camera.main != null; if (flag) { int i = 0; while (i < MobaBattleHandler.EXPMAXCOUT) { bool state = this.m_ExpList[i].state; if (state) { bool flag2 = Time.realtimeSinceStartup > this.m_ExpList[i].vaildTime; if (flag2) { this.m_ExpList[i].state = false; this.m_ExpList[i].m_Go.SetActive(false); } } IL_6E: i++; continue; goto IL_6E; } } bool flag3 = Time.realtimeSinceStartup - this._refreshSignTime < 1f; if (!flag3) { bool activeInHierarchy = this.m_DetailFrame.activeInHierarchy; if (activeInHierarchy) { this._refreshSignTime = Time.realtimeSinceStartup; for (int j = 0; j < this._uidList.Count; j++) { MobaMemberData mobaMemberData; bool flag4 = !this._doc.MobaData.TryGetValue(this._uidList[j], out mobaMemberData); if (flag4) { XSingleton.singleton.AddErrorLog("can't update label because not find data by uid = ", this._uidList[j].ToString(), null, null, null, null); } else { bool flag5 = mobaMemberData.reviveTime <= 0f; if (flag5) { this._labelList[j].SetVisible(false); } else { this._labelList[j].SetVisible(true); this._labelList[j].SetText(mobaMemberData.reviveTime.ToString()); } } } } bool flag6 = this._OnDeath && this._doc.MyData != null; if (flag6) { this._refreshSignTime = Time.realtimeSinceStartup; bool flag7 = this._doc.MyData.reviveTime <= 0f; if (flag7) { this._OnDeath = false; this.m_ReviveLeftTime.SetVisible(false); } else { this.m_ReviveLeftTime.SetText(this._doc.MyData.reviveTime.ToString()); } } } } } }