
cc.Class({
    extends: cc.Component,

    properties: {
        GameMode: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        SwichOnVoice: {
            default: null,
            type: cc.AudioClip,
            serializable: true,
        },
        Girl: {
            default: null,
            type: cc.Node,
            serializable: true,
        },
        ChiVoice: {
            default: null,
            type: cc.AudioClip,
            serializable: true,
        },
    },
    start()
    {
        this.StoryController = this.GameMode.getComponent('StoryController');
    },
   startRobot(event,customData) {
       cc.audioEngine.playEffect(this.SwichOnVoice, false);
       this.StoryController.Conversation.active = false;
       this.SwitchFadeOutAnim();
   },
   SwitchFadeOutAnim()
   {
       let action = cc.fadeOut(2);
       let CallF = cc.callFunc(function(){
           // this.EnableTouch = true;
           // this.node.active=false;
           this.GirlFadeInAnim();
       }.bind(this));
       let FadeInAnim = cc.sequence(action,CallF);
       this.node.runAction(FadeInAnim);
   },
    GirlFadeInAnim()
    {
        let action = cc.fadeIn(1);
        let CallF = cc.callFunc(function(){

            this.StoryController.EnableTouch = true;
            this.StoryController.Conversation.active = true;
            this.StoryController.PlayConversation();

            cc.audioEngine.playEffect(this.ChiVoice, false);
            //close block touch node
            this.node.destroy();
            this.Girl.getChildByName('GameTouchHead').active = false;
            this.Girl.getChildByName('GameTouchChest').active = false;
        }.bind(this));
        let FadeInAnim = cc.sequence(action,CallF);
        this.Girl.active=true;
        this.Girl.opacity = 0;
        this.Girl.runAction(FadeInAnim);
    }
});
