123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- 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;
- }
- }
|