import { _decorator, Component, Node, Prefab } from 'cc';
import { EventDispatcher } from '../../engines/events/EventDispatcher';
import { DataModel } from '../../engines/models/DataModel';
import { GamePropertys } from './GamePropertys';
const { ccclass, property } = _decorator;


export class GameModel extends DataModel{
    
    constructor(){
        super();
    }

    /**
     * 当前武器ID
     */
    get currentWeaponId():number{
        return this.GetProperty(GamePropertys.currentWeaponId);
    }

    set currentWeaponId(value:number){
        this.SetProperty(GamePropertys.currentWeaponId,value);
    }

    /**
     * 当前关卡
     */
    get currentLevel():number{
        return this.GetProperty(GamePropertys.currentLevel);
    }

    set currentLevel(value:number){
        this.SetProperty(GamePropertys.currentLevel,value);
    }

    /**
     * 当前栅栏ID
     */
    get currentFenceId():number{
        return this.GetProperty(GamePropertys.currentFenceId);
    }

    set currentFenceId(value:number){
        this.SetProperty(GamePropertys.currentFenceId,value);
    }
    
    /**
     * 最大关卡数
     */
    get maxLevel():number{
        return this.GetProperty(GamePropertys.maxLevel);
    }

    set maxLevel(value:number){
        this.SetProperty(GamePropertys.maxLevel,value);
    }

    /**
     * 金币
     */
    get gold():number{
        return this.GetProperty(GamePropertys.gold);
    }

    set gold(value:number){
        this.SetProperty(GamePropertys.gold,value);
    }

     /**
     * 积分
     */
    get integral():number{
        return this.GetProperty(GamePropertys.integral);
    }

    set integral(value:number){
        this.SetProperty(GamePropertys.integral,value);
    }

    /**
     * 钻石
     */
    get diamond():number{
        return this.GetProperty(GamePropertys.diamond);
    }

    set diamond(value:number){
        this.SetProperty(GamePropertys.diamond,value);
    }

    /**
     * 击杀数量
     */
    get killCount():number{
        return this.GetProperty(GamePropertys.killCount);
    }

    set killCount(value:number){
        this.SetProperty(GamePropertys.killCount,value);
    }
    
    /**
     * 怒气值
     */
    get angerCount():number{
        return this.GetProperty(GamePropertys.angerCount);
    }

    set angerCount(value:number){
        this.SetProperty(GamePropertys.angerCount,value);
    }

    /**
     * 设置默认属性
     */
    SetDefaultPropertys():void{
        this.currentWeaponId=1;
        this.currentLevel=1;
        this.currentFenceId=1;
        this.gold=0;
        this.diamond=0;

        //保存到本地
        this.SaveToLoacl();
    }
    
    private static instance:GameModel;
    public static get single():GameModel{
        if(this.instance==null){
            this.instance=new GameModel();
        }
        return this.instance;
    }
}