import { AudioMgr, GameViewType } from "../../../main/ViewManage";
import ViewObject from "../../../main/ViewObject";
import FObject from "../object/FObject";
import BaseEvent from "./base/BaseEvent";

/**
 * 金币
 */
const { ccclass, property } = cc._decorator;

@ccclass
export default class FGold extends BaseEvent {

    @property({
        type:cc.Node,
        displayName: '引导箭头标识'
    })
    mGuideMark: cc.Node = null;

    onLoad() {
        super.onLoad()
        this.node.zIndex = -9999;
    }
    /**
       * 主角进入碰撞区域
       */
    public onBegin(tag:number) {
        if(this.mGuideMark){
            this.mGuideMark.active = false;
        }
        if(this.node.getChildByName("ani_zuanshi")){
            this.ff.main.playerEffectByPath(AudioMgr.amethyst);
        }
        this.node.removeComponent(cc.PhysicsBoxCollider);
        let moveBy = cc.moveBy(1, cc.v2(0, 200)).easing(cc.easeSineOut());
        let fadeout = cc.fadeOut(1);
        let spawn = null
        if (true) {
            let seq = cc.sequence(cc.scaleTo(0.1, 1.8), cc.scaleTo(0.2, 2));
            spawn = cc.spawn(moveBy, fadeout, seq);
        } else {
            spawn = cc.spawn(moveBy, fadeout);
        }
        let seq = cc.sequence(cc.delayTime(0.1), spawn, cc.callFunc(() => {
            this.node.removeFromParent(true);
            this.node.destroy();

            if(this.node.name == '109'){
                let main = this.ff.main
                main.viewManage.loadFunc(GameViewType.fight_zsj_tips,(viewObject:ViewObject)=>{
                    viewObject.show();
                });
            }
        }));
        this.node.runAction(seq);

        this.ff.getMapObject(this.node.name);
    }
    /**
     * 主角离开碰撞区域
     */
    public onEnd(tag:number) {
    }
}
