/*
 * @Author: mojunshou 1637302775@qq.com
 * @Date: 2025-04-18 15:09:04
 * @LastEditors: mojunshou 1637302775@qq.com
 * @LastEditTime: 2025-04-29 17:30:33
 * @Description: 金砖道具
 */
import { _decorator, Component, Label, Node, Sprite, SpriteFrame } from 'cc';
import VMParent from 'db://oops-framework/libs/model-view/VMParent';
import { smc } from '../common/SingletonModuleComp';
const { ccclass, property } = _decorator;

@ccclass('BricsItem')
export class BricsItem extends VMParent {
    @property(Node)
    private brickNode: Node = null!;
    //完成Node
    @property(Node)
    private completeNode: Node = null!;

    @property(Label)
    private levelLabel: Label = null!;

    @property([SpriteFrame])
    private iconList: SpriteFrame[] = [];

    //
    @property(Sprite)
    private iconSprite: Sprite = null!;

    @property(Node)
    private iconNode: Node = null!;

    @property(Node)
    private icon2Node: Node = null!;

    @property(Node)
    private circleNode: Node = null!;

    data: any = {
        level: 0,
        eventType: "",
        withdraw: false,
        position: 0, //位置
        isFirstNotWithdraw: false, //是否第一个没提现
        isAllWithdrawBeforeSecondLast: false, //是否所有提现点都提现
    }
    start() {

    }

    //更新数据
    updateData(data: any) {
        this.data = data;
        this.levelLabel.string = `${this.data.level}`;
        this.iconNode.active = false;
        this.icon2Node.active = false;

        this.brickNode.active = !this.data.withdraw;
        this.completeNode.active = this.data.withdraw;
        if (this.data.eventType === "SIGN_POINT") {
            this.iconSprite.spriteFrame = this.iconList[0];
            //
            this.iconNode.active = true;
        } else {
            this.iconSprite.spriteFrame = this.iconList[1];
        }
        //是否提现了
        if (!this.data.withdraw) {
            //
            if (this.data.isFirstNotWithdraw) {
                //展示状态其他不展示
                this.iconNode.active = true;
            } else if (this.data.isAllWithdrawBeforeSecondLast) {
                //展示特殊状态
                this.icon2Node.active = true;
                this.iconNode.active = false;
            }
        }
        //显示光圈
        if (this.data.level === smc.account.AccountModel.curLevel) {
            this.circleNode.active = true;
        } else {
            this.circleNode.active = false;
        }
    }
}


