瀏覽代碼

战斗系统

chenwb10023 2 天之前
父節點
當前提交
afad123e21

+ 12 - 1
assets/script/data/model/Battle/BattleModel.ts

@@ -1,5 +1,9 @@
+import FguiMgr from "../../../frameWork/fgui/FguiMgr";
 import UEBattleRole from "../../../logic/battle/UEBattleRole";
+import { BattleMainView } from "../../../logic/fgui/Battle/BattleMain/BattleMainView";
+import { FightBase } from "../../../shared/base";
 import { ResFightTest } from "../../../shared/fight/PtlFightTest";
+import { ViewZOrder } from "../../const/ViewZOrder";
 import GameDataCenter from "../../GameDataCenter";
 import { BattleModelData } from "./BattleModelData";
 
@@ -13,6 +17,13 @@ export default class BattleModel extends BattleModelData {
 		this.realBattleSpeed = 1.8;
 	}
 
+	//发起战斗
+    startFight(fightInfo: FightBase) {
+    	
+        FguiMgr.Instance.openUI(BattleMainView, ViewZOrder.Battle, () => {
+
+		}, {fightInfo: fightInfo});
+    }
 	
     addRole(id: string, role: UEBattleRole) {
 		this.battleRoleList[id] = role
@@ -26,7 +37,7 @@ export default class BattleModel extends BattleModelData {
 		let ret = await GameDataCenter.gameServer.ReqApi("fight/FightTest", {});
         if (ret?.res) {
             this.setFightInfo(ret.res);
-            cb();
+            cb(ret.res);
         }
 	}
 }

+ 10 - 11
assets/script/logic/battle/UEBattleView.ts

@@ -3,7 +3,7 @@ import { BattleTeamId, FightType } from "../../data/const/TypeConst";
 import GameDataCenter from "../../data/GameDataCenter";
 import UEBase from "../../frameWork/compment/UEBase";
 import { eg } from "../../frameWork/eg";
-import { ActionType, fightLogOne, FightStart } from "../../shared/fight/PtlFightTest";
+import { ActionType, FightBase, fightLogOne, FightStart } from "../../shared/base";
 import AssetMgr from "../../utils/AssetMgr";
 import { BattleGridConstant } from "./BattleGridConstant";
 import UEBattleRole from "./UEBattleRole";
@@ -96,16 +96,15 @@ export default class UEBattleView extends UEBase {
         return this.subHpPrefab;
     }
     //开始战斗
-    async onStartFight() {
-        GameDataCenter.battle.SendTestFight(async () => {
-            eg.poolManager.GetPool("subHPPool").clear();
-            this.huihe = 1;
-            this.curIndex = 0;
-            this.fightStart = GameDataCenter.battle.fightInfo?.fightStart;
-            this.fightLogList = GameDataCenter.battle.fightInfo?.log;
-            await this.produceRole();
-            this.playLog();
-        })
+    async onStartFight(fightInfo: FightBase) {
+        GameDataCenter.battle.setFightInfo(fightInfo); //设置战斗数据
+        eg.poolManager.GetPool("subHPPool").clear();
+        this.huihe = 1;
+        this.curIndex = 0;
+        this.fightStart = GameDataCenter.battle.fightInfo?.fightStart;
+        this.fightLogList = GameDataCenter.battle.fightInfo?.log;
+        await this.produceRole();
+        this.playLog();
     }
     async produceRole() {
         //生产角色

+ 1 - 1
assets/script/logic/fgui/Battle/BattleMain/BattleMainCtrl.ts

@@ -26,7 +26,7 @@ export class BattleMainCtrl extends FguiViewCtrl<BattleMainVM> {
     }
     OnShow(intent?: any): void {
         this.AddListeners();
-        this.ueBattle.onStartFight();
+        this.ueBattle.onStartFight(intent?.fightInfo);
     }
     OnHide(): void {
         this.RemoveListeners();

+ 4 - 1
assets/script/logic/fgui/Home/Home/HomeCtrl.ts

@@ -15,6 +15,7 @@ import { ListUtil } from "../../../../frameWork/fgui/ListUtil";
 import { FguiViewCtrl } from "../../../../frameWork/fgui/mvc/FguiViewCtrl";
 import { GameServerConfig } from "../../../../network/GameServerConfig";
 import { TsrpcNet } from "../../../../network/TsrpcNet";
+import { FightBase } from "../../../../shared/base";
 import AssetMgr from "../../../../utils/AssetMgr";
 import AssetsBundleMgr from "../../../../utils/AssetsBundleMgr";
 import { GridEvent } from "../../../gridMap/GridEvent";
@@ -81,7 +82,9 @@ export class HomeCtrl extends FguiViewCtrl<HomeVM> {
     }
 
     private OnClickBtnPlays(): void {
-        FguiMgr.Instance.openUI(BattleMainView, ViewZOrder.Battle);
+        GameDataCenter.battle.SendTestFight(async (fightInfo: FightBase) => {
+            GameDataCenter.battle.startFight(fightInfo);
+        })
     }
 
     private OnClickBtnWing(): void {