import FqLogin from "../../../../login/FqLogin";
import FF from "../../FF";
import FMap from "../../map/FMap";
import FSprite from "../../object/FSprite";
import BaseEvent from "../base/BaseEvent";

/**
 * 点亮祭坛的火
 */
const { ccclass, property } = cc._decorator;

@ccclass
export default class FAltarFire extends BaseEvent {

    @property({
        displayName: '对应的地图物件'
    })
    public mapGoodId: string = '27';

    @property({
        displayName: '捡起的物品id'
    })
    public goodId = 2002;

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

    onLoad() {
        super.onLoad()
        this.node.zIndex = 9999;
    }
    private isCheck = false
    /**
     * 主角进入碰撞区域
     */
    public onBegin(tag: number) {
        if (this.isCheck) {
            return
        }
        this.isCheck = true

        if(this.mGuideMark){
            this.mGuideMark.active = false;
            this.ff.firstGetGoodsTips();
        }

        this.node.removeComponent(cc.PhysicsBoxCollider);
        let header = this.ff.mFFheader;
        header.addTmpGood(this.goodId, 1);
        cc.tween(this.node).sequence(
            cc.spawn(
                cc.moveBy(1, cc.v2(0, 200)).easing(cc.easeSineOut()),
                cc.fadeOut(1)
            ),
            cc.callFunc(() => {
                FqLogin.commitEvent(this.node.name,'','');
                this.node.removeFromParent(true);
                this.node.destroy();
            })
        ).start();
    }
}
