import { LevelMgr } from "../../levelMgr";
import { Barrage } from "../nest/barrage";
import player from "../player";
import { GameLogicMgr } from "../update/logic";

const {ccclass, property} = cc._decorator;

@ccclass
export default class debug extends cc.Component {

    /*===========================自动绑定组件开始===========================*/
	/*自动生成*/
    @property({type:cc.Button, displayName:""})
    private $gamePlay_btn:cc.Button = null;
	/*自动生成*/
    @property({type:cc.Button, displayName:""})
    private $decLevel_btn:cc.Button = null;
	/*自动生成*/
    @property({type:cc.Button, displayName:""})
    private $addLevel_btn:cc.Button = null;
	/*自动生成*/
    @property({type:cc.Button, displayName:""})
    private $levelSkip_btn:cc.Button = null;
	/*自动生成*/
    @property({type:cc.Button, displayName:""})
    private $attck_btn:cc.Button = null;
	/*自动生成*/
    @property({type:cc.EditBox, displayName:""})
    private $level_edit:cc.EditBox = null;

    /*自动生成*/
    @property({type:cc.Button, displayName:""})
    private $left_btn:cc.Button = null;
    
    /*自动生成*/
    @property({type:cc.Button, displayName:""})
    private $right_btn:cc.Button = null;
    
	/*===========================自动绑定组件结束===========================*/

    /*===========================自动生成按钮事件开始==========================*/

	onGameplayTouchEnd(){
        GameLogicMgr.inst.switch();
    }
	onDeclevelTouchEnd(){
        LevelMgr.inst.pre();
    }
	onAddlevelTouchEnd(){
        LevelMgr.inst.next();
    }
	onLevelskipTouchEnd(){
        let str = this.$level_edit.string;
        LevelMgr.inst.skip(Number(str));
    }
	onAttckTouchEnd(){
        player.PlayerAttack = !player.PlayerAttack;
    }
	onLeftTouchEnd(){
        Barrage.skillNum--;
        Barrage.skillNum = Math.max(Barrage.skillNum, 1);
    }

	onRightTouchEnd(){
        Barrage.skillNum++;
        Barrage.skillNum = Math.min(Barrage.skillNum, 4);
    }


	/*===========================自动生成按钮事件结束==========================*/

    protected onLoad(): void {
        this.$level_edit.string = LevelMgr.inst.getMax().toString();
    }
}