import { BattleEventManager } from "../../tower/base/BattleEventManager";
import { BattleControl } from "../../tower/control/BattleControl";
import { ZombieMapData } from "../data/ZombieMapData";
import { ZombieBuffControl } from "./ZombieBuffControl";
import { ZombieEnemyControl } from "./ZombieEnemyControl";
import { ZombieHeroControl } from "./ZombieHeroControl";
import { ZombieSkillControl } from "./ZombieSkillControl";

//战斗控制类
export class ZombieBattleControl extends BattleControl{
    map:ZombieMapData = null

    //英雄控制类
    heroControl:ZombieHeroControl = null
    //敌人控制类
    enemyControl:ZombieEnemyControl = null

    //buff控制类
    buffControl:ZombieBuffControl = null

    private static instanceZombie:ZombieBattleControl;
    static GetInstance():ZombieBattleControl{
        if(!ZombieBattleControl.instanceZombie){
            ZombieBattleControl.instanceZombie = new ZombieBattleControl();
        }
        return ZombieBattleControl.instanceZombie;
    }

    //初始化
    init(mapId:number){

        this.battleEventManager = BattleEventManager.instance
        this.map = ZombieMapData.GetInstance()
        this.heroControl = new ZombieHeroControl()
        this.enemyControl = new ZombieEnemyControl()
        this.buffControl = new ZombieBuffControl()


        this.map.init(mapId)
        this.buffControl.init()
        this.heroControl.init()
        this.enemyControl.init()
        ZombieSkillControl.GetInstance().init()
    
        // for(let i = 0; i < BattleUtil.TurnMax; i++){
        //     this.update()
        //     if(this.map.battleEnd){
        //         break;
        //     }
        // }
        // this.map.battleEnd = true
    }

    reset(mapId:number){
        this.clear()
        this.map.reset(mapId)
        this.buffControl.init()
        this.heroControl.init()
        this.enemyControl.init()
        //ZombieSkillControl.GetInstance().init()
    }

}