From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/BattleSkillHandler.cs | 1273 ++++++++++++++++++++ 1 file changed, 1273 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/BattleSkillHandler.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/BattleSkillHandler.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/BattleSkillHandler.cs b/Client/Assets/Scripts/XMainClient/UI/BattleSkillHandler.cs new file mode 100644 index 00000000..68397aba --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/BattleSkillHandler.cs @@ -0,0 +1,1273 @@ +using System; +using System.Collections.Generic; +using KKSG; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class BattleSkillHandler : DlgHandlerBase + { + public bool IsAwakeSlotSettingOn + { + get + { + XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); + bool flag = specificDocument != null; + return !flag || specificDocument.GetValue(XOptionsDefine.OD_Awake_Slot) != 0; + } + } + + private BattleSkillHandler.XSkillButton[] m_buttons = null; + + private XBattleSkillDocument _doc = null; + + private XSkillTreeDocument _skill_doc = null; + + public float LastAttackTime = 0f; + + private bool bNormalAttackPressed = false; + + private XTimerMgr.ElapsedEventHandler _DestroyShowSkillFx = null; + + private IXGameSirControl m_sirControl; + + private List mSkillSets; + + private int mSkillSize = 0; + + private XFx _addFx; + + private XFx _skillFx; + + private XFx _moveFx; + + private int _showSkillNum; + + private uint _fxDelayToken; + + private uint _fxDelayDelToken; + + private XUIPool m_LevelPool = new XUIPool(XSingleton.singleton.m_uiTool); + + private float _pressTime; + + private List[] skillSet = new List[10]; + + public struct XSkillButton + { + public bool Visible + { + get + { + return this.m_visible; + } + } + + public bool Enabled + { + get + { + return this.m_enabled; + } + } + + public bool Active; + + public bool AlwaysHot; + + public IXUIButton m_skill; + + public IXUISprite m_skillIcon; + + public IXUIProgress m_skillCD; + + public IXUITweenTool m_skillCDOver; + + public GameObject m_skillNoMp; + + public IXUILabel m_skillCDText; + + public float m_skillCost; + + public uint m_skillId; + + public GameObject m_skillHighlight; + + public IXUISprite m_lock; + + public IXUISprite m_add; + + public IXUISprite m_skillLevel; + + public int m_skillMaxLevel; + + public bool m_TimesVis; + + public IXUILabel m_Times; + + private bool m_enabled; + + private bool m_visible; + + private Vector3 m_OriginPos; + + private Vector3 m_CDOverOriginPos; + + public XSkillButton(GameObject panelObject, int idx) + { + this.AlwaysHot = false; + this.Active = true; + this.m_visible = true; + this.m_TimesVis = false; + Transform transform = panelObject.transform.Find("Skill" + idx + "/Bg"); + this.m_OriginPos = transform.transform.localPosition; + this.m_skill = (transform.GetComponent("XUIButton") as IXUIButton); + this.m_skill.ID = (ulong)((long)idx); + bool flag = XSingleton.singleton.SceneType == SceneType.SCENE_MOBA && idx >= 2 && idx <= 5; + if (flag) + { + Transform transform2 = transform.transform.parent.Find("Addsp"); + transform2.gameObject.SetActive(true); + this.m_add = (transform2.GetComponent("XUISprite") as IXUISprite); + transform2.gameObject.SetActive(false); + transform2 = transform.transform.Find("level"); + transform2.gameObject.SetActive(true); + this.m_skillLevel = (transform2.GetComponent("XUISprite") as IXUISprite); + this.m_skillLevel.SetFillAmount(0f); + } + else + { + bool flag2 = XSingleton.singleton.SceneType == SceneType.SCENE_WEEKEND4V4_CRAZYBOMB & idx == 0; + if (flag2) + { + this.m_add = null; + Transform transform3 = transform.transform.Find("level"); + transform3.gameObject.SetActive(true); + this.m_skillLevel = (transform3.GetComponent("XUISprite") as IXUISprite); + this.m_skillLevel.SetFillAmount(0f); + transform3 = transform.transform.Find("icon/p"); + transform3.gameObject.SetActive(false); + } + else + { + bool flag3 = XSingleton.singleton.SceneType == SceneType.SCENE_SURVIVE && idx == 0; + if (flag3) + { + this.m_add = null; + this.m_skillLevel = null; + Transform transform4 = transform.transform.Find("icon"); + Transform transform5 = transform.transform.Find("ChickenDinnerIcon"); + transform5.gameObject.SetActive(true); + transform5.localPosition = XGameUI.Far_Far_Away; + IXUISprite ixuisprite = transform4.GetComponent("XUISprite") as IXUISprite; + IXUISprite ixuisprite2 = transform5.GetComponent("XUISprite") as IXUISprite; + ixuisprite.spriteWidth = ixuisprite2.spriteWidth; + ixuisprite.spriteHeight = ixuisprite2.spriteHeight; + transform4.rotation = transform5.rotation; + } + else + { + this.m_add = null; + this.m_skillLevel = null; + } + } + } + this.m_skillMaxLevel = 0; + bool flag4 = (idx >= 2 && idx <= 6) || idx == XSkillTreeDocument.AwakeSkillSlot; + if (flag4) + { + this.m_Times = (transform.transform.Find("icon/Times").GetComponent("XUILabel") as IXUILabel); + this.m_Times.gameObject.transform.localPosition = XGameUI.Far_Far_Away; + } + else + { + this.m_Times = null; + } + this.m_skillIcon = (transform.transform.Find("icon").GetComponent("XUISprite") as IXUISprite); + this.m_skillCD = (this.m_skillIcon.gameObject.GetComponent("XUIProgress") as IXUIProgress); + this.m_skillCDOver = (this.m_skillIcon.transform.Find("cdover").GetComponent("XUIPlayTween") as IXUITweenTool); + this.m_CDOverOriginPos = this.m_skillCDOver.gameObject.transform.localPosition; + this.m_skillCDOver.gameObject.transform.localPosition = XGameUI.Far_Far_Away; + this.m_skillCDText = (this.m_skillIcon.transform.Find("Text").GetComponent("XUILabel") as IXUILabel); + this.m_skillNoMp = this.m_skillIcon.transform.Find("nomp").gameObject; + this.m_skillHighlight = transform.transform.Find("highlight").gameObject; + this.m_skillHighlight.transform.localPosition = XGameUI.Far_Far_Away; + this.m_lock = null; + Transform transform6 = transform.transform.Find("lock"); + bool flag5 = transform6 != null; + if (flag5) + { + this.m_lock = (transform6.GetComponent("XUISprite") as IXUISprite); + this.m_lock.gameObject.SetActive(false); + } + this.m_skillCost = 0f; + this.m_skillId = 0u; + this.m_enabled = true; + } + + public void SetButtonStatus(bool enable) + { + bool flag = this.m_enabled != enable; + if (flag) + { + if (enable) + { + this.m_skill.SetEnable(true, false); + } + else + { + this.m_skillNoMp.transform.localPosition = XGameUI.Far_Far_Away; + this.m_skill.SetEnable(false, this.m_skill.ID == 0UL); + } + } + this.m_enabled = enable; + } + + public void SetButtonHighlight(bool enable) + { + this.m_skillHighlight.transform.localPosition = (enable ? Vector3.zero : XGameUI.Far_Far_Away); + } + + public void SetButtonInRange(bool enable) + { + } + + public void SetButton(bool active) + { + this.m_visible = active; + this.m_skill.SetVisible(active); + } + + public void SetCDText(bool active) + { + this.m_skillCDText.gameObject.transform.localPosition = (active ? Vector3.zero : XGameUI.Far_Far_Away); + } + + public void SetCDOver(bool active) + { + } + + public void SetNoMP(bool active) + { + this.m_skillNoMp.gameObject.transform.localPosition = (active ? Vector3.zero : XGameUI.Far_Far_Away); + } + + private void _OnCDOverFinished(IXUITweenTool tween) + { + this.SetCDOver(false); + } + + public void SetSkillLevel(int level) + { + bool flag = this.m_skillLevel == null; + if (!flag) + { + this.m_skillLevel.SetFillAmount((float)level * 1f / (float)this.m_skillMaxLevel); + } + } + } + + public BattleSkillHandler() + { + this._DestroyShowSkillFx = new XTimerMgr.ElapsedEventHandler(this.DestroyShowSkillFx); + } + + protected override void Init() + { + base.Init(); + this._showSkillNum = 0; + Transform transform = base.PanelObject.transform.Find("LevelTpl"); + bool flag = XSingleton.singleton.SceneType == SceneType.SCENE_MOBA || XSingleton.singleton.SceneType == SceneType.SCENE_WEEKEND4V4_CRAZYBOMB; + if (flag) + { + this.m_LevelPool.SetupPool(transform.parent.gameObject, transform.gameObject, 16u, false); + } + else + { + transform.gameObject.SetActive(false); + } + this.m_buttons = new BattleSkillHandler.XSkillButton[XBattleSkillDocument.Total_skill_slot]; + int num = 0; + while ((long)num < (long)((ulong)XBattleSkillDocument.Total_skill_slot)) + { + this.m_buttons[num] = new BattleSkillHandler.XSkillButton(base.PanelObject, num); + num++; + } + this.m_sirControl = XSingleton.singleton.GameSirControl; + this._doc = XDocuments.GetSpecificDocument(XBattleSkillDocument.uuID); + this._doc.BattleView = this; + this._doc.Init(); + this._skill_doc = XDocuments.GetSpecificDocument(XSkillTreeDocument.uuID); + this.mSkillSets = new List(); + string[] andSeparateValue = XSingleton.singleton.GetAndSeparateValue("GameSirKeyCodes", XGlobalConfig.ListSeparator); + bool flag2 = andSeparateValue == null || andSeparateValue.Length == 0; + if (flag2) + { + this.mSkillSize = 0; + } + else + { + this.mSkillSize = andSeparateValue.Length; + for (int i = 0; i < this.mSkillSize; i++) + { + this.mSkillSets.Add(andSeparateValue[i].Split(XGlobalConfig.SequenceSeparator)); + } + } + } + + public override void RegisterEvent() + { + base.RegisterEvent(); + int num = 0; + while ((long)num < (long)((ulong)XBattleSkillDocument.Total_skill_slot)) + { + this.m_buttons[num].m_skill.RegisterPressEventHandler(new ButtonPressEventHandler(this.OnSkillCast)); + bool flag = this.m_buttons[num].m_add != null; + if (flag) + { + this.m_buttons[num].m_add.ID = (ulong)((long)num); + this.m_buttons[num].m_add.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnAddClick)); + this.m_buttons[num].m_add.RegisterSpritePressEventHandler(new SpritePressEventHandler(this.OnAddPress)); + } + bool flag2 = this.m_buttons[num].m_lock != null; + if (flag2) + { + this.m_buttons[num].m_lock.ID = (ulong)((long)num); + this.m_buttons[num].m_lock.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnLockClick)); + } + num++; + } + this.m_buttons[0].m_skill.RegisterPressEventHandler(new ButtonPressEventHandler(this.OnAttackPressed)); + } + + public override void OnUnload() + { + bool flag = this._addFx != null; + if (flag) + { + XSingleton.singleton.DestroyFx(this._addFx, true); + } + bool flag2 = this._skillFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._skillFx, true); + } + bool flag3 = this._moveFx != null; + if (flag3) + { + XSingleton.singleton.DestroyFx(this._moveFx, true); + } + this._doc.BattleView = null; + XSingleton.singleton.KillTimer(this._fxDelayToken); + XSingleton.singleton.KillTimer(this._fxDelayDelToken); + base.OnUnload(); + } + + protected override void OnShow() + { + base.OnShow(); + this.bNormalAttackPressed = false; + bool flag = XSingleton.singleton.SceneType != SceneType.SCENE_HEROBATTLE; + if (flag) + { + this.ResetSkill(false, false); + } + } + + public void SetButtonNum(int num) + { + bool flag = this._showSkillNum == num; + if (!flag) + { + this._showSkillNum = num; + int group = 0; + bool flag2 = num != 0; + if (flag2) + { + group = 5 - num; + } + int num2 = 2; + while (num2 <= 5 && num2 < this.m_buttons.Length) + { + IXPositionGroup ixpositionGroup = this.m_buttons[num2].m_skill.gameObject.GetComponent("PositionGroup") as IXPositionGroup; + ixpositionGroup.SetGroup(group); + num2++; + } + } + } + + public void SetupSkillMobaLevel() + { + bool flag = XSingleton.singleton.Player == null || XSingleton.singleton.Player.Transformer == null; + if (!flag) + { + this.m_LevelPool.ReturnAll(true); + bool flag2 = XSingleton.singleton.SceneType == SceneType.SCENE_MOBA; + if (flag2) + { + int i = 2; + while (i <= 5) + { + bool flag3 = i < XSingleton.singleton.Player.SkillSlot.Length && i < this.m_buttons.Length; + if (flag3) + { + int skillMaxLevel = XSingleton.singleton.GetSkillMaxLevel(XSingleton.singleton.Player.SkillSlot[i], XSingleton.singleton.Player.SkillCasterTypeID); + bool flag4 = skillMaxLevel <= 1; + if (!flag4) + { + Transform parent = this.m_buttons[i].m_skillLevel.gameObject.transform.Find("p"); + for (int j = 0; j < skillMaxLevel; j++) + { + float num = (float)j * 2f * 3.14159274f / (float)skillMaxLevel; + GameObject gameObject = this.m_LevelPool.FetchGameObject(false); + gameObject.transform.parent = parent; + gameObject.transform.localScale = Vector3.one; + gameObject.transform.localPosition = new Vector3(Mathf.Sin(num) * 40f, Mathf.Cos(num) * 40f); + gameObject.transform.eulerAngles = new Vector3(0f, 0f, -num * 57.29578f); + } + this.m_buttons[i].m_skillMaxLevel = skillMaxLevel; + } + } + IL_1AF: + i++; + continue; + goto IL_1AF; + } + } + else + { + int skillMaxLevel2 = XSingleton.singleton.GetSkillMaxLevel(XSingleton.singleton.Player.SkillSlot[0], XSingleton.singleton.Player.SkillCasterTypeID); + Transform parent2 = this.m_buttons[0].m_skillLevel.gameObject.transform.Find("p"); + for (int k = 0; k < skillMaxLevel2; k++) + { + float num2 = (float)k * 2f * 3.14159274f / (float)skillMaxLevel2; + GameObject gameObject2 = this.m_LevelPool.FetchGameObject(false); + gameObject2.transform.parent = parent2; + gameObject2.transform.localScale = Vector3.one; + gameObject2.transform.localPosition = new Vector3(Mathf.Sin(num2) * 64f, Mathf.Cos(num2) * 64f); + gameObject2.transform.eulerAngles = new Vector3(0f, 0f, -num2 * 57.29578f); + } + this.m_buttons[0].m_skillMaxLevel = skillMaxLevel2; + this.SetMobaSkillLevel(0, false); + } + } + } + + private void _SetAttackGlow(bool bActive) + { + } + + public void ResetPressState() + { + this.bNormalAttackPressed = false; + this.m_buttons[0].m_skill.ResetState(); + this._SetAttackGlow(false); + } + + public void BindSkill(int idx, uint skill, bool rebind = false) + { + bool flag = (long)idx >= (long)((ulong)XBattleSkillDocument.Total_skill_slot) || (!rebind && skill == this.m_buttons[idx].m_skillId); + if (flag) + { + bool flag2 = skill == 0u && this.m_buttons[idx].m_lock != null; + if (flag2) + { + uint level = XSingleton.singleton.XPlayerData.Level; + uint skillSlotUnLockLevel = this._skill_doc.GetSkillSlotUnLockLevel(idx); + this.m_buttons[idx].SetButton(this._ShouldShowButton(skill, idx)); + bool flag3 = level < skillSlotUnLockLevel; + if (flag3) + { + this.m_buttons[idx].m_lock.gameObject.SetActive(true); + } + else + { + this.m_buttons[idx].m_lock.gameObject.SetActive(false); + } + } + } + else + { + bool flag4 = !this.m_buttons[idx].Active; + if (!flag4) + { + bool flag5 = skill > 0u; + if (flag5) + { + uint skillLevel = XSingleton.singleton.Player.Skill.IsSkillReplaced ? 1u : XSingleton.singleton.Player.Attributes.SkillLevelInfo.GetSkillLevel(skill); + SkillList.RowData skillConfig = XSingleton.singleton.GetSkillConfig(skill, skillLevel, XSingleton.singleton.Player.SkillCasterTypeID); + bool flag6 = skillConfig != null; + if (flag6) + { + this.m_buttons[idx].m_skillCost = XSingleton.singleton.Player.SkillMgr.GetMPCost(skill); + this.m_buttons[idx].m_skillId = skill; + this.m_buttons[idx].m_skillIcon.SetSprite(skillConfig.Icon, skillConfig.Atlas, false); + bool flag7 = this.m_buttons[idx].m_lock != null; + if (flag7) + { + this.m_buttons[idx].m_lock.gameObject.SetActive(false); + } + } + else + { + this.m_buttons[idx].m_skillId = 0u; + this.m_buttons[idx].m_skillIcon.spriteName = ""; + this.m_buttons[idx].SetButtonStatus(false); + } + } + else + { + this.m_buttons[idx].m_skillId = 0u; + this.m_buttons[idx].m_skillIcon.spriteName = ""; + this.m_buttons[idx].SetButtonStatus(false); + } + } + } + } + + public void OnSetOptionsValue() + { + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(XSingleton.singleton.SceneID); + int awakeSkillSlot = XSkillTreeDocument.AwakeSkillSlot; + bool flag = awakeSkillSlot < this.m_buttons.Length && awakeSkillSlot < XSingleton.singleton.Player.SkillSlot.Length; + if (flag) + { + this.m_buttons[awakeSkillSlot].SetButton(sceneData.ShowSkill && this._ShouldShowButton(XSingleton.singleton.Player.SkillSlot[awakeSkillSlot], awakeSkillSlot)); + } + } + + private bool IsAwakeSkillSlotNeedOpen() + { + return this._skill_doc.IsAwakeSkillSlotOpen && this._skill_doc.IsSelfAwaked && this.IsAwakeSlotSettingOn; + } + + private bool _ShouldShowButton(uint skillID, int idx) + { + bool flag = idx == XSkillTreeDocument.AwakeSkillSlot && !this.IsAwakeSkillSlotNeedOpen(); + bool result; + if (flag) + { + result = false; + } + else + { + bool flag2 = skillID > 0u; + if (flag2) + { + result = true; + } + else + { + bool flag3 = XSingleton.singleton.Player.IsTransform || XSingleton.singleton.Player.Skill.IsSkillReplaced; + if (flag3) + { + result = false; + } + else + { + SkillTypeEnum skillSlotType = this._skill_doc.GetSkillSlotType(idx); + result = (skillSlotType != SkillTypeEnum.Skill_Buff || this._skill_doc.GetSkillSlotUnLockLevel(XFastEnumIntEqualityComparer.ToInt(XSkillSlot.Skill_1_Buff)) <= XSingleton.singleton.XPlayerData.Level); + } + } + } + return result; + } + + public void ResetSkill(bool showfx = false, bool rebind = false) + { + int num = 0; + while ((long)num < (long)((ulong)XBattleSkillDocument.Total_skill_slot)) + { + this.ResetSkill(num, rebind); + bool flag = showfx && this.m_buttons[num].m_skillId > 0u; + if (flag) + { + this.PlayShowSkillFx(num); + } + this.m_buttons[num].SetButton(this._ShouldShowButton(this.m_buttons[num].m_skillId, num)); + num++; + } + bool flag2 = XSingleton.singleton.SceneType == SceneType.SCENE_MOBA || XSingleton.singleton.SceneType == SceneType.SCENE_WEEKEND4V4_CRAZYBOMB; + if (flag2) + { + DlgBase.singleton.SkillHandler.SetupSkillMobaLevel(); + int num2 = 0; + while ((long)num2 < (long)((ulong)XBattleSkillDocument.Total_skill_slot)) + { + uint num3; + bool flag3 = XBattleSkillDocument.SkillLevelDict.TryGetValue(this.m_buttons[num2].m_skillId, out num3); + if (flag3) + { + XBattleSkillDocument.SkillLevel[num2] = (int)num3; + DlgBase.singleton.SkillHandler.SetMobaSkillLevel(num2, false); + } + num2++; + } + bool flag4 = XSingleton.singleton.SceneType == SceneType.SCENE_MOBA; + if (flag4) + { + DlgBase.singleton.SkillHandler.RefreshAddBtn(null); + } + } + SceneTable.RowData sceneData = XSingleton.singleton.GetSceneData(XSingleton.singleton.SceneID); + bool flag5 = !sceneData.ShowSkill; + if (flag5) + { + int num4 = 1; + while ((long)num4 < (long)((ulong)XBattleSkillDocument.Total_skill_slot)) + { + this.m_buttons[num4].SetButton(false); + num4++; + } + } + bool flag6 = !sceneData.ShowNormalAttack; + if (flag6) + { + this.m_buttons[0].SetButton(false); + } + } + + public void ResetSkill(int idx, bool rebind = false) + { + bool flag = idx < XSingleton.singleton.Player.SkillSlot.Length; + if (flag) + { + this.BindSkill(idx, XSingleton.singleton.Player.SkillSlot[idx], rebind); + this.m_buttons[idx].SetButtonHighlight(false); + this.m_buttons[idx].SetButtonInRange(false); + } + else + { + XSingleton.singleton.AddErrorLog("skill slot ", idx.ToString(), "missing...", null, null, null); + } + } + + public void CoolDownSkillAll() + { + int num = 0; + while ((long)num < (long)((ulong)XBattleSkillDocument.Total_skill_slot)) + { + bool flag = this.m_buttons[num].m_skillId > 0u; + if (flag) + { + XSkillCore skill = XSingleton.singleton.Player.SkillMgr.GetSkill(this.m_buttons[num].m_skillId); + bool flag2 = skill != null; + if (flag2) + { + skill.CoolDown(); + } + this.PlayShowSkillFx(num); + } + num++; + } + } + + public void MakeCoolDownAtLaunch() + { + int num = 0; + while ((long)num < (long)((ulong)XBattleSkillDocument.Total_skill_slot)) + { + bool flag = this.m_buttons[num].m_skillId > 0u; + if (flag) + { + XSkillCore skill = XSingleton.singleton.Player.SkillMgr.GetSkill(this.m_buttons[num].m_skillId); + bool flag2 = skill != null; + if (flag2) + { + skill.MakeCoolDownAtLaunch(); + } + } + num++; + } + } + + public void DisableSkill(int idx) + { + this.BindSkill(idx, 0u, false); + this.m_buttons[idx].Active = false; + this.m_buttons[idx].SetButton(false); + } + + public void ShowSkillSlot(int index) + { + } + + public void EnableSkill(int idx) + { + this.m_buttons[idx].Active = true; + this.m_buttons[idx].SetButton(true); + bool flag = idx < XSingleton.singleton.Player.SkillSlot.Length; + if (flag) + { + this.BindSkill(idx, XSingleton.singleton.Player.SkillSlot[idx], false); + this.PlayShowSkillFx(idx); + } + else + { + XSingleton.singleton.AddErrorLog("skill slot ", idx.ToString(), "missing...", null, null, null); + } + } + + public void AlwaysHot(int idx, bool isHot) + { + this.m_buttons[idx].AlwaysHot = isHot; + this.m_buttons[idx].SetButtonStatus(true); + } + + public void OnDeath() + { + this.bNormalAttackPressed = false; + this.m_buttons[0].m_skill.ResetState(); + this._SetAttackGlow(false); + } + + public override void OnUpdate() + { + base.OnUpdate(); + bool flag = this.bNormalAttackPressed; + if (flag) + { + this.CastNormalAttack(); + } + bool flag2 = !DlgBase.singleton.IsMainUIVisible(); + if (flag2) + { + this.UpdateKeyBoard(); + } + this.UpdateGameSirControl(); + this.UpdateSkillInfo(); + } + + protected void DestroyShowSkillFx(object o) + { + GameObject o2 = o as GameObject; + XSingleton.singleton.UnSafeDestroy(o2, true, false); + } + + public void OnAttackPressed(bool state) + { + this.OnAttackPressed(null, state); + } + + private void OnAttackPressed(IXUIButton go, bool state) + { + this.bNormalAttackPressed = state; + bool flag = !state; + if (!flag) + { + this._doc.OnSlotClicked(0); + } + } + + private void CastNormalAttack() + { + this.ImpCast(0); + } + + private void OnSkillCast(IXUIButton go, bool state) + { + bool flag = !state; + if (!flag) + { + this._doc.OnSlotClicked((int)go.ID); + this.ImpCast((int)go.ID); + } + } + + private void OnLockClick(IXUISprite sp) + { + int slotid = (int)sp.ID; + uint skillSlotUnLockLevel = this._skill_doc.GetSkillSlotUnLockLevel(slotid); + string text = string.Format(XStringDefineProxy.GetString("OpenSkillAtLevel"), skillSlotUnLockLevel); + XSingleton.singleton.ShowSystemNoticeTip(text); + } + + public void OnAddClick(IXUISprite sp) + { + bool flag = this._pressTime > 1f; + if (!flag) + { + bool flag2 = (int)sp.ID >= this.m_buttons.Length; + if (!flag2) + { + XMobaBattleDocument specificDocument = XDocuments.GetSpecificDocument(XMobaBattleDocument.uuID); + bool flag3 = this.IsSkillCanLevelUp((int)sp.ID); + if (flag3) + { + specificDocument.QuerySkillLevelUp(this.m_buttons[(int)sp.ID].m_skillId); + } + } + } + } + + public void SetMobaSkillLevel(int slot, bool isLevelUp) + { + bool flag = isLevelUp && this.m_buttons[slot].m_add != null; + if (flag) + { + bool flag2 = this._addFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._addFx, true); + } + bool flag3 = this._skillFx != null; + if (flag3) + { + XSingleton.singleton.DestroyFx(this._skillFx, true); + } + bool flag4 = this._moveFx != null; + if (flag4) + { + XSingleton.singleton.DestroyFx(this._moveFx, true); + } + Transform transform = this.m_buttons[slot].m_skillIcon.transform; + Transform transform2 = this.m_buttons[slot].m_add.transform.parent.Find("Fx"); + this._addFx = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_jiahao", transform2, false); + this._skillFx = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_jinenglan", transform, false); + this._moveFx = XSingleton.singleton.CreateUIFx("Effects/FX_Particle/UIfx/UI_yxxg_feixing", transform2, false); + this._addFx.Play(); + this._skillFx.Play(); + Vector3 vector = transform.position - transform2.position; + float num = Vector3.Angle(Vector3.right, vector); + bool flag5 = vector.y < 0f; + if (flag5) + { + num = -num; + } + this._moveFx.Play(transform2.transform.position, Quaternion.Euler(0f, 0f, num), Vector3.one, 1f); + } + this.m_buttons[slot].SetSkillLevel(XBattleSkillDocument.SkillLevel[slot]); + } + + public void DelayRefreshAddBtn() + { + XSingleton.singleton.KillTimer(this._fxDelayToken); + this._fxDelayToken = XSingleton.singleton.SetTimer(0.1f, new XTimerMgr.ElapsedEventHandler(this.RefreshAddBtn), null); + XSingleton.singleton.KillTimer(this._fxDelayDelToken); + this._fxDelayDelToken = XSingleton.singleton.SetTimer(2f, new XTimerMgr.ElapsedEventHandler(this.DelayRefreshFx), null); + } + + public void DelayRefreshFx(object o = null) + { + bool flag = this._addFx != null; + if (flag) + { + XSingleton.singleton.DestroyFx(this._addFx, true); + } + bool flag2 = this._skillFx != null; + if (flag2) + { + XSingleton.singleton.DestroyFx(this._skillFx, true); + } + bool flag3 = this._moveFx != null; + if (flag3) + { + XSingleton.singleton.DestroyFx(this._moveFx, true); + } + this._addFx = null; + this._skillFx = null; + this._moveFx = null; + } + + public void RefreshAddBtn(object o = null) + { + bool flag = XBattleSkillDocument.Total_skill_slot <= 5u || XSingleton.singleton.Player == null; + if (!flag) + { + bool flag2 = !XEntity.ValideEntity(XSingleton.singleton.Player.Transformer); + if (!flag2) + { + XMobaBattleDocument specificDocument = XDocuments.GetSpecificDocument(XMobaBattleDocument.uuID); + int skillPoint = specificDocument.SkillPoint; + for (int i = 2; i <= 5; i++) + { + this.m_buttons[i].m_add.SetVisible(this.IsSkillCanLevelUp(i)); + } + } + } + } + + public bool IsSkillCanLevelUp(int index) + { + bool flag = XBattleSkillDocument.Total_skill_slot <= 5u || XSingleton.singleton.Player == null; + bool result; + if (flag) + { + result = false; + } + else + { + XMobaBattleDocument specificDocument = XDocuments.GetSpecificDocument(XMobaBattleDocument.uuID); + bool flag2 = specificDocument.SkillPoint == 0; + if (flag2) + { + result = false; + } + else + { + int skillMaxLevel = XSingleton.singleton.GetSkillMaxLevel(this.m_buttons[index].m_skillId, XSingleton.singleton.Player.SkillCasterTypeID); + bool flag3 = XBattleSkillDocument.SkillLevel[index] >= skillMaxLevel; + if (flag3) + { + result = false; + } + else + { + SkillList.RowData skillConfig = XSingleton.singleton.GetSkillConfig(this.m_buttons[index].m_skillId, (uint)(XBattleSkillDocument.SkillLevel[index] + 1), XSingleton.singleton.Player.SkillCasterTypeID); + bool flag4 = skillConfig == null || XBattleSkillDocument.SkillLevel[index] >= skillConfig.UpReqRoleLevel.Length || (int)skillConfig.UpReqRoleLevel[XBattleSkillDocument.SkillLevel[index]] > specificDocument.MyLevel(); + result = !flag4; + } + } + } + return result; + } + + public bool OnAddPress(IXUISprite sp, bool state) + { + bool flag = (int)sp.ID >= this.m_buttons.Length; + bool result; + if (flag) + { + result = false; + } + else + { + if (state) + { + this._pressTime = Time.time; + } + else + { + this._pressTime = Time.time - this._pressTime; + } + bool flag2 = DlgBase.singleton.m_MobaBattleHandler != null; + if (flag2) + { + DlgBase.singleton.m_MobaBattleHandler.ShowSkillTips(state, this.m_buttons[(int)sp.ID].m_skillId, XBattleSkillDocument.SkillLevel[(int)sp.ID] + 1); + } + result = true; + } + return result; + } + + private void ImpCast(int idx) + { + bool flag = this.m_buttons[idx].m_skillId == 0u || !this.m_buttons[idx].Enabled || !this.m_buttons[idx].Visible; + if (!flag) + { + uint num = this._doc.NextJASkillBaseOnCurrent(); + bool flag2 = num == this.m_buttons[idx].m_skillId; + if (flag2) + { + bool flag3 = this._doc.IsInQTEChain(num); + if (flag3) + { + this._doc.CastSkill(this.m_buttons[idx]); + } + else + { + bool syncMode = XSingleton.singleton.SyncMode; + if (syncMode) + { + this._doc.FireSkillEvent(idx); + } + else + { + this.LastAttackTime = Time.time; + } + } + } + else + { + this._doc.CastSkill(this.m_buttons[idx]); + } + } + } + + protected void UpdateSkillInfo() + { + XPlayer player = XSingleton.singleton.Player; + bool flag = player == null; + if (!flag) + { + int num = (int)XSingleton.singleton.Player.Attributes.GetAttr(XAttributeDefine.XAttr_CurrentMP_Basic); + int num2 = 0; + while ((long)num2 < (long)((ulong)XBattleSkillDocument.Total_skill_slot)) + { + XSkillCore xskillCore = this._doc.HasReplaced(this.m_buttons[num2].m_skillId); + bool flag2 = xskillCore != null; + if (flag2) + { + bool showRunningTime = xskillCore.ShowRunningTime; + if (showRunningTime) + { + bool flag3 = this.m_buttons[num2].m_Times != null; + if (flag3) + { + bool flag4 = xskillCore.LeftRunningTime != 0; + bool flag5 = this.m_buttons[num2].m_TimesVis != flag4; + if (flag5) + { + this.m_buttons[num2].m_TimesVis = flag4; + this.m_buttons[num2].m_Times.gameObject.transform.localPosition = (flag4 ? new Vector3(24f, -30f) : XGameUI.Far_Far_Away); + } + this.m_buttons[num2].m_Times.SetText(xskillCore.LeftRunningTime.ToString()); + } + } + else + { + bool flag6 = this.m_buttons[num2].m_Times != null; + if (flag6) + { + bool timesVis = this.m_buttons[num2].m_TimesVis; + if (timesVis) + { + this.m_buttons[num2].m_TimesVis = false; + this.m_buttons[num2].m_Times.gameObject.transform.localPosition = XGameUI.Far_Far_Away; + } + } + } + bool reloading = xskillCore.Reloading; + if (reloading) + { + float coolDown = xskillCore.GetCoolDown(); + float elapsedCD = xskillCore.GetElapsedCD(); + float num3 = (coolDown > 0f) ? (1f - elapsedCD / coolDown) : 0f; + bool flag7 = num2 > 0 || !XSingleton.singleton.Player.SkillMgr.IsPhysicalAttack(xskillCore.ID); + this.m_buttons[num2].m_skillCD.value = (flag7 ? num3 : 0f); + bool cooledDown = xskillCore.CooledDown; + if (cooledDown) + { + this.m_buttons[num2].SetCDText(false); + } + else + { + this.m_buttons[num2].SetCDText(true); + float num4 = coolDown - elapsedCD; + bool flag8 = num4 >= 1f; + if (flag8) + { + int num5 = (int)(coolDown - elapsedCD + 0.5f); + bool flag9 = this.m_buttons[num2].m_skillCDText.HasIdentityChanged(num5); + if (flag9) + { + string text = flag7 ? num5.ToString() : ""; + this.m_buttons[num2].m_skillCDText.SetText(text); + this.m_buttons[num2].m_skillCDText.SetIdentity(num5); + } + } + else + { + int num6 = (int)(num4 * 10f); + bool flag10 = this.m_buttons[num2].m_skillCDText.HasIdentityChanged(num6); + if (flag10) + { + string text = flag7 ? num4.ToString("F1") : ""; + this.m_buttons[num2].m_skillCDText.SetText(text); + this.m_buttons[num2].m_skillCDText.SetIdentity(num6); + } + } + } + } + else + { + this.m_buttons[num2].SetCDText(false); + this.m_buttons[num2].m_skillCD.value = 0f; + } + bool flag11 = this._doc.CanCast(xskillCore.ID, num2); + if (flag11) + { + this.m_buttons[num2].SetButtonStatus(true); + this.m_buttons[num2].SetNoMP((float)num < this.m_buttons[num2].m_skillCost); + bool flag12 = num2 > 1; + if (flag12) + { + this.m_buttons[num2].SetButtonInRange(xskillCore.CooledDown && this._doc.CanFind(xskillCore.ID)); + } + } + else + { + bool alwaysHot = this.m_buttons[num2].AlwaysHot; + if (alwaysHot) + { + this.m_buttons[num2].SetButtonStatus(true); + } + else + { + bool flag13 = num2 > 1; + if (flag13) + { + this.m_buttons[num2].SetButtonInRange(false); + } + this.m_buttons[num2].SetButtonStatus(false); + } + } + } + else + { + this.m_buttons[num2].m_skillCD.value = 0f; + this.m_buttons[num2].SetCDText(false); + this.m_buttons[num2].SetButtonStatus(false); + } + num2++; + } + } + } + + public void UpdateQTESkill(int idx, uint skill) + { + bool flag = skill > 0u; + if (flag) + { + this.BindSkill(idx, skill, false); + bool flag2 = !XSingleton.singleton.Player.QTE.IsInIgnorePresentState(); + if (flag2) + { + this.m_buttons[idx].SetButtonHighlight(true); + } + } + } + + private void PlayShowSkillFx(int idx) + { + this.m_buttons[idx].SetButtonStatus(true); + GameObject gameObject = XSingleton.singleton.CreateFromPrefab("UI/Common/ShowSkillFx", true, false) as GameObject; + Transform transform = this.m_buttons[idx].m_skill.gameObject.transform.Find("icon"); + bool flag = transform == null; + if (flag) + { + XSingleton.singleton.AddErrorLog("Skill Icon No Find", null, null, null, null, null); + } + else + { + XSingleton.singleton.AddChild(transform.gameObject, gameObject); + IXUISprite ixuisprite = gameObject.GetComponent("XUISprite") as IXUISprite; + ixuisprite.ResetAnimationAndPlay(); + XSingleton.singleton.SetTimer(5f, this._DestroyShowSkillFx, gameObject); + } + } + + private bool ExcuteSkill(int index, string[] skillNames) + { + bool flag = skillNames == null || skillNames.Length == 0; + bool result; + if (flag) + { + result = false; + } + else + { + bool flag2 = true; + int i = 0; + int num = skillNames.Length; + while (i < num) + { + flag2 = (flag2 && this.m_sirControl.GetButton(skillNames[i])); + bool flag3 = !flag2; + if (flag3) + { + break; + } + i++; + } + bool flag4 = flag2; + if (flag4) + { + bool flag5 = index == 0; + if (flag5) + { + this.CastNormalAttack(); + } + else + { + this.ImpCast(index); + } + } + result = flag2; + } + return result; + } + + private void UpdateGameSirControl() + { + bool flag = !base.IsVisible(); + if (!flag) + { + bool flag2 = this.m_sirControl == null || !this.m_sirControl.IsConnected() || this.mSkillSets == null; + if (!flag2) + { + bool flag3 = this.mSkillSize == 0; + if (!flag3) + { + for (int i = 0; i < this.mSkillSize; i++) + { + this.ExcuteSkill(i, this.mSkillSets[i]); + } + } + } + } + } + + public void UpdateKeyBoard() + { + bool flag = !base.IsVisible(); + if (!flag) + { + bool keyDown = Input.GetKeyDown((KeyCode)104); + if (keyDown) + { + this.CastNormalAttack(); + } + bool keyDown2 = Input.GetKeyDown((KeyCode)32); + if (keyDown2) + { + this.ImpCast(1); + } + bool keyDown3 = Input.GetKeyDown((KeyCode)106); + if (keyDown3) + { + this.ImpCast(2); + } + bool keyDown4 = Input.GetKeyDown((KeyCode)107); + if (keyDown4) + { + this.ImpCast(3); + } + bool keyDown5 = Input.GetKeyDown((KeyCode)108); + if (keyDown5) + { + this.ImpCast(4); + } + bool keyDown6 = Input.GetKeyDown((KeyCode)59); + if (keyDown6) + { + this.ImpCast(5); + } + bool keyDown7 = Input.GetKeyDown((KeyCode)117); + if (keyDown7) + { + this.ImpCast(6); + } + bool keyDown8 = Input.GetKeyDown((KeyCode)111); + if (keyDown8) + { + this.ImpCast(7); + } + bool keyDown9 = Input.GetKeyDown((KeyCode)112); + if (keyDown9) + { + this.ImpCast(8); + } + bool keyDown10 = Input.GetKeyDown((KeyCode)105); + if (keyDown10) + { + this.ImpCast(9); + } + } + } + } +} -- cgit v1.1-26-g67d0