伤害系统 + 战斗管理系统
This commit is contained in:
26
assets/script/game/map/MapView.ts
Normal file
26
assets/script/game/map/MapView.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// 开始战斗
|
||||
function startBattle() {
|
||||
const battle = new BattleManager();
|
||||
battle.add(BattleManagerComp);
|
||||
oops.message.dispatchEvent("BattleStart");
|
||||
}
|
||||
|
||||
// 结束战斗
|
||||
function endBattle() {
|
||||
const battle = ecs.query(ecs.allOf(BattleManager))[0];
|
||||
if (battle) {
|
||||
battle.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
// 点击开始战斗按钮
|
||||
function onBattleStartClick(missionId: number) {
|
||||
BattleManager.instance.startBattle(missionId);
|
||||
}
|
||||
|
||||
// 角色死亡时检测
|
||||
function checkHeroDeath() {
|
||||
if (heroView.hp <= 0) {
|
||||
BattleManager.instance.endBattle();
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,7 @@ import { UIID } from "../common/config/GameUIConfig";
|
||||
import { CardControllerComp } from "./CardController";
|
||||
import { MissionHomeComp } from "./MissionHomeComp";
|
||||
import { GameEvent } from "../common/config/GameEvent";
|
||||
import { BattleState } from "../battle/BattleStateComp";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
/** 视图层对象 */
|
||||
@@ -102,10 +103,10 @@ export class MissionComp extends CCComp {
|
||||
monsters[i].HeroView.reset()
|
||||
monsters[i].HeroView.ent.destroy()
|
||||
}
|
||||
|
||||
// this.to_mission_home()
|
||||
this.open_victory()
|
||||
}
|
||||
|
||||
open_victory(){
|
||||
this.node.getChildByName("victory").active=true
|
||||
this.node.getChildByName("victory").getComponent(VictoryComp).open()
|
||||
|
||||
Reference in New Issue
Block a user