GameModel.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. import { _decorator, Component, Node, Prefab } from 'cc';
  2. import { EventDispatcher } from '../../engines/events/EventDispatcher';
  3. import { DataModel } from '../../engines/models/DataModel';
  4. import { GamePropertys } from './GamePropertys';
  5. const { ccclass, property } = _decorator;
  6. export class GameModel extends DataModel{
  7. constructor(){
  8. super();
  9. }
  10. /**
  11. * 当前武器ID
  12. */
  13. get currentWeaponId():number{
  14. return this.GetProperty(GamePropertys.currentWeaponId);
  15. }
  16. set currentWeaponId(value:number){
  17. this.SetProperty(GamePropertys.currentWeaponId,value);
  18. }
  19. /**
  20. * 当前关卡
  21. */
  22. get currentLevel():number{
  23. return this.GetProperty(GamePropertys.currentLevel);
  24. }
  25. set currentLevel(value:number){
  26. this.SetProperty(GamePropertys.currentLevel,value);
  27. }
  28. /**
  29. * 当前栅栏ID
  30. */
  31. get currentFenceId():number{
  32. return this.GetProperty(GamePropertys.currentFenceId);
  33. }
  34. set currentFenceId(value:number){
  35. this.SetProperty(GamePropertys.currentFenceId,value);
  36. }
  37. /**
  38. * 最大关卡数
  39. */
  40. get maxLevel():number{
  41. return this.GetProperty(GamePropertys.maxLevel);
  42. }
  43. set maxLevel(value:number){
  44. this.SetProperty(GamePropertys.maxLevel,value);
  45. }
  46. /**
  47. * 金币
  48. */
  49. get gold():number{
  50. return this.GetProperty(GamePropertys.gold);
  51. }
  52. set gold(value:number){
  53. this.SetProperty(GamePropertys.gold,value);
  54. }
  55. /**
  56. * 积分
  57. */
  58. get integral():number{
  59. return this.GetProperty(GamePropertys.integral);
  60. }
  61. set integral(value:number){
  62. this.SetProperty(GamePropertys.integral,value);
  63. }
  64. /**
  65. * 钻石
  66. */
  67. get diamond():number{
  68. return this.GetProperty(GamePropertys.diamond);
  69. }
  70. set diamond(value:number){
  71. this.SetProperty(GamePropertys.diamond,value);
  72. }
  73. /**
  74. * 击杀数量
  75. */
  76. get killCount():number{
  77. return this.GetProperty(GamePropertys.killCount);
  78. }
  79. set killCount(value:number){
  80. this.SetProperty(GamePropertys.killCount,value);
  81. }
  82. /**
  83. * 怒气值
  84. */
  85. get angerCount():number{
  86. return this.GetProperty(GamePropertys.angerCount);
  87. }
  88. set angerCount(value:number){
  89. this.SetProperty(GamePropertys.angerCount,value);
  90. }
  91. /**
  92. * 设置默认属性
  93. */
  94. SetDefaultPropertys():void{
  95. this.currentWeaponId=1;
  96. this.currentLevel=1;
  97. this.currentFenceId=1;
  98. this.gold=0;
  99. this.diamond=0;
  100. //保存到本地
  101. this.SaveToLoacl();
  102. }
  103. private static instance:GameModel;
  104. public static get single():GameModel{
  105. if(this.instance==null){
  106. this.instance=new GameModel();
  107. }
  108. return this.instance;
  109. }
  110. }