import FqLogin from "../../../../../login/FqLogin";
import BaseEvent from "../../base/BaseEvent";
import FAltar1_3 from "./FAltar1_3";

/**
 * 祭坛周围可踩的星星
 */
const {ccclass, property} = cc._decorator;

@ccclass
export default class FAltarStar extends BaseEvent {

    @property({
        displayName:'祭坛',
        type:FAltar1_3
    })
    mFaltar:FAltar1_3 = null;

    @property({
        displayName:'底部的图片',
        type:cc.Sprite
    })
    mIcon: cc.Sprite = null;

    @property({
        displayName:'点亮的图片',
        type:cc.SpriteFrame
    })
    mLight: cc.SpriteFrame = null;//点亮的图

    @property({
        displayName:'其它的祭坛开启',
        tooltip:'剩下的祭坛开启',
        type:[cc.Node]
    })
    mOtherAltarStar: Array<cc.Node> = [];//


    public isCheck = false//是否被点亮


    /**
     * 主角进入碰撞区域
     *  @param tag 碰撞组件编号
     */
     public onBegin(tag:number){
        if(this.isCheck){
            return
        }
        this.isCheck = true
        this.mIcon.spriteFrame = this.mLight
        this.checkOpen()
        FqLogin.commitEvent(this.node.name,'','');
    }

    private checkOpen(){
        for (let i = 0; i < this.mOtherAltarStar.length; i++) {
            const element = this.mOtherAltarStar[i];
            let altarStar = element.getComponent(FAltarStar)
            if(!altarStar.isCheck){
                return
            }
        }
        this.mFaltar.node.active = true;
        this.mFaltar.showAltar()
    }

    


}
