using System; using System.Collections.Generic; using Common.Utility.CombatEvent; using Core.Utility; using Fort23.Core; using Fort23.UTool; using GameLogic.Combat.CombatTool; using GameLogic.Combat.Hero; using GameLogic.Combat.Hero.Turntable; using GameLogic.Combat.Skill; using GameLogic.Player; using UnityEngine; using Utility; namespace Fort23.Mono { [UIBinding(prefab = "ZhuanPanPanel")] public partial class ZhuanPanPanel : UIComponent { private List _gfWidgets = new List(); // List _wuXingGongFaWidgets = new List(); private Map _wuXingGongFaWidgets = new Map(); public async CTask ShowPanel() { for (_wuXingGongFaWidgets.Begin(); _wuXingGongFaWidgets.Next();) { UIManager.Instance.DormancyGComponent(_wuXingGongFaWidgets.Value); } _wuXingGongFaWidgets.Clear(); for (int i = 0; i < 5; i++) { double hd = i * 72 * Math.PI / 180f; double a = Math.Cos(hd); double b = -Math.Sin(hd); double c = Math.Sin(hd); double d = a; double x = a * 0 + b * 103; double y = c * 0 + d * 103; int index = i; WuXingGongFaWidget widget = await UIManager.Instance.CreateGComponentForObject( WuXingGongFaWidget, null, root: pan, isInstance: true); widget.transform.anchoredPosition = new Vector2((float)x, (float)y); widget.ShowWidget(index); _wuXingGongFaWidgets.Add(widget.huangDaoWuXingType, widget); } ExercisesAlter(null); } private void SetSkillFxMovePlay(SkillSlots skillSlots) { WuXingType wuXingType = skillSlots.SkillBasic.wuXingType; Vector2 startPos = Vector2.zero; for (int i = 0; i < _gfWidgets.Count; i++) { if (_gfWidgets[i].SkillSlots == skillSlots) { startPos= _gfWidgets[i].transform.position; } } // double hd = skillSlots.angle * Math.PI / 180f; // double a = Math.Cos(hd); // double b = -Math.Sin(hd); // double c = Math.Sin(hd); // double d = a; // double x = a * 0 + b * 150; // double y = c * 0 + d * 150; Vector2 endPos = _wuXingGongFaWidgets[wuXingType].transform.position; Vector2 center = endPos - startPos; center = startPos + (center * 0.5f); BesselPath besselPath = new BesselPath(); besselPath.controlPoints.Add(startPos); besselPath.controlPoints.Add(new Vector3(center.x, center.y, -0.5f)); besselPath.controlPoints.Add(endPos); besselPath.controlPoints.Add(endPos); Vector2 startPos2 = endPos; Vector2 endPos2 = currUseSkillRoot.transform.position; Vector2 center2 = endPos2 - startPos2; center2 = startPos2 + (center2 * 0.5f); BesselPath besselPath2 = new BesselPath(); besselPath2.controlPoints.Add(startPos2); besselPath2.controlPoints.Add(new Vector3(center2.x, center2.y, -0.5f)); besselPath2.controlPoints.Add(endPos2); besselPath2.controlPoints.Add(endPos2); BesselPathGroup besselPathGroup = new BesselPathGroup(); besselPathGroup.AddBesselPath(besselPath); besselPathGroup.AddBesselPath(besselPath2); GameObject fxObject = null; switch (wuXingType) { case WuXingType.Gold: fxObject = fx_skill_jing; break; case WuXingType.Water: fxObject = fx_skill_shui; break; case WuXingType.Wood: fxObject = fx_skill_huo; break; case WuXingType.Fire: fxObject = fx_skill_huo; break; case WuXingType.Earth: fxObject = fx_skill_shui; break; } UseSkillShowFxMono useSkillShowFxMono = CObjectPool.Instance.Fetch(); ParticleSystemPool particleSystemPool = GObjectPool.Instance.FetchAsyncForGameObject(fxObject, fxObject.name); particleSystemPool.transform.parent = fxObject.transform.parent; useSkillShowFxMono.Init(besselPathGroup, particleSystemPool); } private void Init() { } public override void AddEvent() { StaticUpdater.Instance.AddLateUpdateCallBack(Update); CombatEventManager.Instance.AddEventListener(CombatEventType.ExercisesAlter, ExercisesAlter); CombatEventManager.Instance.AddEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter); CombatEventManager.Instance.AddEventListener(CombatEventType.AddUseGongFa, AddUseGongFa); CombatEventManager.Instance.AddEventListener(CombatEventType.UseSkill, UseSkill); CombatEventManager.Instance.AddEventListener(CombatEventType.UseSkillFinish, UseSkillFinish); } public override void DelEvent() { StaticUpdater.Instance.RemoveLateUpdateCallBack(Update); CombatEventManager.Instance.RemoveEventListener(CombatEventType.ExercisesAlter, ExercisesAlter); CombatEventManager.Instance.RemoveEventListener(CombatEventType.TaoismSkillAlter, TaoismSkillAlter); CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddUseGongFa, AddUseGongFa); CombatEventManager.Instance.RemoveEventListener(CombatEventType.UseSkillFinish, UseSkillFinish); } private async void UseSkillFinish(IEventData ieveData) { UseSkillFinishEventData eventData = ieveData as UseSkillFinishEventData; if (eventData.SkillBasic.CombatHeroEntity.IsEnemy) { return; } CombatHeroSkillControl combatHeroSkillControl = eventData.SkillBasic.CombatHeroEntity.CombatHeroSkillControl.This(); if (combatHeroSkillControl.useSkillCount <= 0) { currUseSkillRoot.SetActive(false); } } private async void UseSkill(IEventData ieveData) { CombatUseSkillEventData eventData = ieveData as CombatUseSkillEventData; if (eventData.useSkill.CombatHeroEntity.IsEnemy) { return; } currUseSkillRoot.SetActive(true); currUseSkillIcon.icon_name = eventData.useSkill.SelfSkillConfig.icon; } private async void AddUseGongFa(IEventData ieveData) { AddUseGongFaEventData eventData = ieveData as AddUseGongFaEventData; SkillBasic skillBasic = eventData.SkillBasic; if (skillBasic.CombatHeroEntity.IsEnemy) { return; } SetSkillFxMovePlay(eventData.SkillSlots); CombatHeroSkillControl combatHeroSkillControl = skillBasic.CombatHeroEntity.CombatHeroSkillControl.This(); if (combatHeroSkillControl.useSkillCount > 0 || combatHeroSkillControl.currUseSkill != null) { UseQuqueSkill useQuqueSkill = await UIManager.Instance.CreateGComponentForObject(UseQuqueSkill, null, UseQuqueSkillRoot, isInstance: true); useQuqueSkill.ShowWidget(skillBasic); useQuqueSkill.transform.SetAsLastSibling(); } } public override void AddButtonEvent() { lanLiang_button.onClick.AddListener(() => { SkillSelectPanel.OpenSkillSelectPanel(); }); } private void TaoismSkillAlter(IEventData iEventData) { } private async void ExercisesAlter(IEventData iEventData) { _gfWidgets.Clear(); UIManager.Instance.DormancyAllGComponent(); CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat .playerHeroEntity.CombatHeroSkillControl .This(); for (int i = 0; i < combatHeroSkillControl.SkillTurntable.allSkillSlots.Count; i++) { SkillSlots skillBasic = combatHeroSkillControl.SkillTurntable.allSkillSlots[i]; if (skillBasic == null) { continue; } gf_widget gfWidget = await UIManager.Instance.CreateGComponentForObject(this.gf_widget, null, Gf_root, isInstance: true); gfWidget.SkillSlots = skillBasic; gfWidget.InitWidget(skillBasic, CombatController.currActiveCombat .playerHeroEntity); _gfWidgets.Add(gfWidget); } } public void Update() { if (CombatController.currActiveCombat == null || CombatController.currActiveCombat.CombatHeroController == null || CombatController.currActiveCombat.playerHeroEntity == null || CombatController .currActiveCombat.playerHeroEntity.CombatHeroSkillControl == null) { return; } CombatHeroSkillControl combatHeroSkillControl = CombatController.currActiveCombat .playerHeroEntity.CombatHeroSkillControl .This(); if (combatHeroSkillControl.taoismSkillBasic != null) { DS60101 ds60101 = combatHeroSkillControl.taoismSkillBasic as DS60101; if (ds60101 != null) { lanLiang.fillAmount = ds60101.currEnergy / ds60101.SelfSkillConfig.effectValue[1]; lanLiang.color = !ds60101._updateTime ? new Color(1f, 0.96f, 0f) : new Color(0.96f, 0f, 1f); } } for (int i = 0; i < _gfWidgets.Count; i++) { gf_widget gfWidget = _gfWidgets[i]; gfWidget.Update(); double hd = gfWidget.SkillSlots.angle * Math.PI / 180f; double a = Math.Cos(hd); double b = -Math.Sin(hd); double c = Math.Sin(hd); double d = a; double x = a * 0 + b * 150; double y = c * 0 + d * 150; gfWidget.transform.anchoredPosition = new Vector2((float)x, (float)y); } } } }