Browse Source

修改bug

DESKTOP-FB72PO8\Administrator 3 weeks ago
parent
commit
905b86e035

+ 10 - 0
Assets/Scripts/GameLogic/Combat/CombatState/CombatIdleState.cs

@@ -1,4 +1,5 @@
 using GameLogic.Combat.CombatTool;
 using GameLogic.Combat.CombatTool;
+using GameLogic.Combat.Hero;
 
 
 namespace GameLogic.Combat.CombatState
 namespace GameLogic.Combat.CombatState
 {
 {
@@ -7,5 +8,14 @@ namespace GameLogic.Combat.CombatState
         public CombatIdleState(CombatController combatController) : base(combatController)
         public CombatIdleState(CombatController combatController) : base(combatController)
         {
         {
         }
         }
+
+        protected override void ProEnter()
+        {
+            CombatHeroEntity playerHeroEntity = CombatController.currActiveCombat.CombatHeroController.playerHeroEntity;
+            if (playerHeroEntity != null)
+            {
+                playerHeroEntity.PlayAnim(CombatHeroStateType.idle, true, 0, false, 1);
+            }
+        }
     }
     }
 }
 }

+ 11 - 1
Assets/Scripts/GameLogic/Combat/CombatTool/CombatController.cs

@@ -20,6 +20,10 @@ namespace GameLogic.Combat.CombatTool
 {
 {
     public class CombatController : ITimeLineAudio, IDisposable
     public class CombatController : ITimeLineAudio, IDisposable
     {
     {
+        public static string idle = "idle";
+        public static string update = "update";
+        public static string fight = "fight";
+
         public static CombatController currActiveCombat;
         public static CombatController currActiveCombat;
         public CombatHeroController CombatHeroController;
         public CombatHeroController CombatHeroController;
         public CombatCameraControllder CombatCameraControllder;
         public CombatCameraControllder CombatCameraControllder;
@@ -46,6 +50,8 @@ namespace GameLogic.Combat.CombatTool
         public bool IsGameOver;
         public bool IsGameOver;
         public bool IsFightState;
         public bool IsFightState;
 
 
+        public System.Action<bool> combatFinish;
+
         public CombatStateBasic CurrState
         public CombatStateBasic CurrState
         {
         {
             get { return stateControl.CurrIState as CombatStateBasic; }
             get { return stateControl.CurrIState as CombatStateBasic; }
@@ -93,7 +99,6 @@ namespace GameLogic.Combat.CombatTool
             CombatEventManager.Instance.Dispatch(CombatEventType.GameStart, null);
             CombatEventManager.Instance.Dispatch(CombatEventType.GameStart, null);
         }
         }
 
 
-    
 
 
         private void RefreshFull(IEventData eventData)
         private void RefreshFull(IEventData eventData)
         {
         {
@@ -141,6 +146,11 @@ namespace GameLogic.Combat.CombatTool
             return await AudioManager.Instance.PlayAudio(audioName, isLoop);
             return await AudioManager.Instance.PlayAudio(audioName, isLoop);
         }
         }
 
 
+        public void GameOver(bool isWin)
+        {
+            combatFinish?.Invoke(isWin);
+        }
+
         public void Dispose()
         public void Dispose()
         {
         {
             TimeLineSingletonEventManager.Instance.RemoveTimeLineBasic(this);
             TimeLineSingletonEventManager.Instance.RemoveTimeLineBasic(this);

+ 15 - 12
Assets/Scripts/GameLogic/Combat/CombatType/LevelBattleCombatType.cs

@@ -40,18 +40,21 @@ namespace GameLogic.Combat.CombatType
 
 
         protected override void ProHeroDie(CombatHeroEntity combatHeroEntity, HarmReturnInfo harmReturnInfo)
         protected override void ProHeroDie(CombatHeroEntity combatHeroEntity, HarmReturnInfo harmReturnInfo)
         {
         {
-            CombatItemShowEventData combatItemShowEventData = CombatItemShowEventData.Create();
-            combatItemShowEventData.count = Random.Range(3, 5);
-            combatItemShowEventData.startPos_WorldPos = combatHeroEntity.combatHeroGameObject.position;
-            EventManager.Instance.Dispatch(CustomEventType.Combat_ItemShow, combatItemShowEventData);
-
-
-            ShowTextEventData showTextEventData = ShowTextEventData.Create();
-            showTextEventData.text = "+金币 20";
-            showTextEventData.Color = new Color(1f, 0.64f, 0.22f);
-            showTextEventData.worldPos = combatHeroEntity.combatHeroGameObject.position;
-            EventManager.Instance.Dispatch(CustomEventType.ShowText, showTextEventData);
             CombatHeroEntity[] allHero = combatController.CombatHeroController.GetHero(true);
             CombatHeroEntity[] allHero = combatController.CombatHeroController.GetHero(true);
+            if (allHero.Length <= 0)
+            {
+                //胜利
+                CombatController.currActiveCombat.GameOver(true);
+                return;
+            }
+
+            allHero = combatController.CombatHeroController.GetHero(false);
+            if (allHero.Length <= 0)
+            {
+                //失败
+                CombatController.currActiveCombat.GameOver(false);
+                return;
+            }
         }
         }
 
 
 
 
@@ -65,7 +68,7 @@ namespace GameLogic.Combat.CombatType
         }
         }
 
 
 
 
-        public async CTask LoadCombat(int levelBattleId)
+        public async CTask LoadCombat(int levelBattleId, System.Action<bool> caombatFinish)
         {
         {
             LevelbattleConfig levelbattleConfig = ConfigComponent.Instance.Get<LevelbattleConfig>(levelBattleId);
             LevelbattleConfig levelbattleConfig = ConfigComponent.Instance.Get<LevelbattleConfig>(levelBattleId);
             CTaskAwaitBuffer cTaskAwaitBuffer = new CTaskAwaitBuffer();
             CTaskAwaitBuffer cTaskAwaitBuffer = new CTaskAwaitBuffer();

+ 7 - 1
Assets/Scripts/GameLogic/EventManager/DialogueManager.cs

@@ -52,7 +52,8 @@ public class DialogueManager : Singleton<DialogueManager>
         //挂机事件 弹出简单气泡对话
         //挂机事件 弹出简单气泡对话
         if (eventConfig.EventTriggerType != 2)
         if (eventConfig.EventTriggerType != 2)
         {
         {
-            dialogue.OpenDialoguePanel(dialogueConfig.ID, null, ShowDialogueEventData.MessageShowType.Verbatim, FishDialogue);
+            dialogue.OpenDialoguePanel(dialogueConfig.ID, null, ShowDialogueEventData.MessageShowType.Verbatim,
+                FishDialogue);
         }
         }
         else
         else
         {
         {
@@ -98,6 +99,11 @@ public class DialogueManager : Singleton<DialogueManager>
             //进入战斗
             //进入战斗
             case 2:
             case 2:
                 LogTool.Log("对话结束,进入战斗");
                 LogTool.Log("对话结束,进入战斗");
+                dialogue.StartCombat(dialogueConfig.optionPara1[0],
+                    delegate(bool isWin)
+                    {
+                        LogTool.Log("战斗完成" + isWin);
+                    });
                 break;
                 break;
             //获得奖励
             //获得奖励
             case 3:
             case 3:

+ 1 - 0
Assets/Scripts/GameLogic/EventManager/DialogueMono.cs

@@ -12,4 +12,5 @@ public interface IDialogueMono
     CTask OpenRewardsPanel(List<ItemInfo> rewardsDic, Action onClose = null, int titleId = 0);
     CTask OpenRewardsPanel(List<ItemInfo> rewardsDic, Action onClose = null, int titleId = 0);
 
 
     CTask OpenDialoguePanel(int id, Action<int?> finish);
     CTask OpenDialoguePanel(int id, Action<int?> finish);
+    void StartCombat(int levelBattle,System.Action<bool> finishCombat);
 }
 }

+ 21 - 2
Assets/Scripts/GameUI/Combat/CombatDrive.cs

@@ -17,6 +17,8 @@ namespace GameLogic.Combat
 
 
         private CombatMonoBaisc combatMonoBaisc;
         private CombatMonoBaisc combatMonoBaisc;
 
 
+        private System.Action<bool> caombatFinish;
+
         public async CTask Init()
         public async CTask Init()
         {
         {
             string name = "CombatRoot.prefab";
             string name = "CombatRoot.prefab";
@@ -50,14 +52,31 @@ namespace GameLogic.Combat
             StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
             StaticUpdater.Instance.AddRenderUpdateCallBack(Update);
         }
         }
 
 
-        public async CTask LoadLevelBattleCombat(int levelBattleId)
+        public async CTask LoadLevelBattleCombat(int levelBattleId, System.Action<bool> caombatFinish)
         {
         {
+            this.caombatFinish = caombatFinish;
+            CombatController.ChangeState(CombatController.idle);
             LevelBattleCombatType levelBattleCombatType = CombatController.CombatTypeBasic as LevelBattleCombatType;
             LevelBattleCombatType levelBattleCombatType = CombatController.CombatTypeBasic as LevelBattleCombatType;
             if (levelBattleCombatType != null)
             if (levelBattleCombatType != null)
             {
             {
-                await levelBattleCombatType.LoadCombat(levelBattleId);
+                CombatController.combatFinish = CombatFinish;
+                await levelBattleCombatType.LoadCombat(levelBattleId, caombatFinish);
             }
             }
+
             await CombatPanel.OpenCombatPanel();
             await CombatPanel.OpenCombatPanel();
+            ///播放动画
+            MainPanel mainPanel = UIManager.Instance.GetComponent<MainPanel>();
+            mainPanel.transform.gameObject.SetActive(false);
+            CombatController.ChangeState(CombatController.update);
+        }
+
+        protected void CombatFinish(bool isWin)
+        {
+            caombatFinish?.Invoke(isWin);
+            ///播放动画
+            MainPanel mainPanel = UIManager.Instance.GetComponent<MainPanel>();
+            mainPanel.transform.gameObject.SetActive(false);
+            UIManager.Instance.HideUIUIPanel<CombatPanel>();
         }
         }
 
 
         public void Update()
         public void Update()

+ 11 - 6
Assets/Scripts/GameUI/DialogueMono.cs

@@ -4,29 +4,34 @@ using Common.Utility.CombatEvent;
 using Fort23.Core;
 using Fort23.Core;
 using Fort23.Mono;
 using Fort23.Mono;
 using GameLogic.Bag;
 using GameLogic.Bag;
+using GameLogic.Combat;
 
 
 namespace GameUI
 namespace GameUI
 {
 {
     public class DialogueMono : IDialogueMono
     public class DialogueMono : IDialogueMono
     {
     {
-        public void OpenDialoguePanel(int id, string[] icon, ShowDialogueEventData.MessageShowType messageShowType, Action<int?> finish)
+        public void OpenDialoguePanel(int id, string[] icon, ShowDialogueEventData.MessageShowType messageShowType,
+            Action<int?> finish)
         {
         {
-            DialoguePanel.OpenDialoguePanel(id, icon,messageShowType,finish);
+            DialoguePanel.OpenDialoguePanel(id, icon, messageShowType, finish);
         }
         }
 
 
         public async CTask OpenRewardsPanel(List<ItemInfo> rewardsDic, Action onClose = null, int titleId = 0)
         public async CTask OpenRewardsPanel(List<ItemInfo> rewardsDic, Action onClose = null, int titleId = 0)
         {
         {
             CTask cTask = CTask.Create();
             CTask cTask = CTask.Create();
-            RewardsPanel rewardsPanel = await RewardsPanel.OpenPanel(rewardsDic,onClose,titleId);
+            RewardsPanel rewardsPanel = await RewardsPanel.OpenPanel(rewardsDic, onClose, titleId);
             await rewardsPanel.UIClosed();
             await rewardsPanel.UIClosed();
             cTask.SetResult();
             cTask.SetResult();
         }
         }
 
 
-        public async CTask OpenDialoguePanel(int id,  Action<int?> finish)
+        public async CTask OpenDialoguePanel(int id, Action<int?> finish)
         {
         {
-           await DialogueBubblePanel.OpenDialoguePanel(id, finish);
+            await DialogueBubblePanel.OpenDialoguePanel(id, finish);
         }
         }
 
 
-     
+        public void StartCombat(int levelBattle, Action<bool> finishCombat)
+        {
+            CombatDrive.Instance.LoadLevelBattleCombat(levelBattle, finishCombat);
+        }
     }
     }
 }
 }

+ 1 - 1
Assets/Scripts/GameUI/UI/CombatPanel/CombatPanel.cs

@@ -105,7 +105,7 @@ namespace Fort23.Mono
         protected override void DelEvent()
         protected override void DelEvent()
         {
         {
             CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddRandomEvent, AddRandomEventEventData);
             CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddRandomEvent, AddRandomEventEventData);
-            CombatEventManager.Instance.RemoveEventListener(CombatEventType.GameStart, GameStart);
+            
             CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddMagicWeaponHeroEntity,
             CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddMagicWeaponHeroEntity,
                 AddMagicWeaponHeroEntity);
                 AddMagicWeaponHeroEntity);
             StaticUpdater.Instance.RemoveLateUpdateCallBack(Update);
             StaticUpdater.Instance.RemoveLateUpdateCallBack(Update);