cc.Class({
    extends: cc.Component,

    properties: {
        gameStates: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        topHole: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        leftHole: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        rightHole: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        avatar: {
            default: null,
            type: cc.Sprite,
            serializable: true,
        },
        playerName: {
            default: null,
            type: cc.Label,
            serializable: true,
        },
        score: {
            default: null,
            type: cc.Label,
            serializable: true,
        },
        gender: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        bAi:true
    },
    onLoad () {
        this.init();
    },
    init()
    {
        this.topHoleScpt = this.topHole.getComponent('Actor');
        this.leftHoleScpt = this.leftHole.getComponent('Actor');
        this.rightHoleScpt = this.rightHole.getComponent('Actor');
        this.gameStatesScpt = this.gameStates.getComponent('GameStates');
    },
    left()
    {
        if(this.leftHoleScpt.bDie) return;

        this.leftHoleScpt.leftPunch(this.bAi);
        this.hit();
    },
    top()
    {
        if(this.topHoleScpt.bDie) return;

        this.topHoleScpt.punch(this.bAi);
        this.hit();
    },
    right()
    {
        if(this.rightHoleScpt.bDie) return;

        this.rightHoleScpt.rightPunch(this.bAi);
        this.hit();
    },
});
