import { TB } from "../../../../config/data/schema";
import GRoleAttack from "../../../base/common/GRoleAttack";
import GRoleBase from "../../../base/role/GRoleBase";
import GRoleDefault from "../../../base/role/GRoleDefault";
import GSkillAngerBase from "../../GSkillAngerBase";

export default class GSkillBulbasaurDoubleHit extends GSkillAngerBase{

    role:GRoleDefault;
    info: TB.TbGRoleSkill;

    bind(role:GRoleDefault,info: TB.TbGRoleSkill):GSkillBulbasaurDoubleHit {
        //技能冷却
        this.role = role;
        this.info = info;
        this.angerMax = parseInt(info.skillArgs[0]);
        this.role.addAttackCallback(this.addAnger.bind(this))
        return this;

    }

    onRelease(): boolean {

        let enemy = this.role.fsm.enemy;
        //关闭动画管理器
        this.role.fsmAnim.close();
        
        let skill1Attack = () => {
            if(!enemy.isDie){
                GRoleAttack.onNormalAttack(this.role,enemy);
            }
        };
        let end = () => {
            this.role.fsmAnim.open();
            this.role.fsmAnim.delEventListener("skill1Attack",skill1Attack)
            this.role.fsmAnim.delEndListener("skill1",end)
        }
        //监听伤害
        this.role.fsmAnim.addEventListener("skill1Attack",skill1Attack)
        //播放妙蛙种子技能
        this.role.spine.setAnimation(0,"skill1",false);
        this.role.fsmAnim.addEndListener("skill1",end)

        return true;

    }

    //添加怒气
    addAnger(){
        this.anger++;
    }

}

