
import i18n from "../../i18n/i18n";
import Area, { Zone,History_Role } from "../Area";

const {ccclass, property} = cc._decorator;

@ccclass
export default class MyZoneItem extends cc.Component {

    @property(cc.Label)
    mZoneName: cc.Label = null;

    @property(cc.Label)
    mRoleName: cc.Label = null;

    @property(cc.Node)
    mRoleNode: cc.Node = null;

    @property(cc.Node)
    mNullNode: cc.Node = null;

    public area:Area;
    public zone:Zone;
    public role:History_Role;

    public callback:(item:MyZoneItem)=>void;
    onLoad () {

        if(this.role != null){
            this.zone = this.area.getZoneById(this.role.zoneId);
            this.mRoleNode.active = true;
            this.mNullNode.active = false;

            this.mRoleName.string = this.role.name;
        }else{
            this.mRoleNode.active = false;
            this.mNullNode.active = true;
        }

        this.mZoneName.string = i18n.t(this.zone.name);

    }
    public setCallback(callback:(item:MyZoneItem)=>void){
        this.callback = callback;
    }

    public onclick(){
        this.callback(this);
    }
   
}
