AccountModelComp.ts 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
  2. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  3. import { VM } from "../../../../../extensions/oops-plugin-framework/assets/libs/model-view/ViewModel";
  4. import { Checkpoint } from "../../checkpoint/Checkpoint";
  5. /**
  6. * 游戏玩家数据
  7. */
  8. @ecs.register('AccountModel')
  9. export class AccountModelComp extends ecs.Comp {
  10. /** 提供 VM 组件使用的数据 */
  11. private vm: any = {};
  12. checkpoint: Checkpoint = null!;
  13. private _name: string = "";
  14. private _lv: number = 1;
  15. private _skin: number = 1
  16. private _reward: boolean = false
  17. /** 昵称 */
  18. get name(): string {
  19. return this._name;
  20. }
  21. set name(value: string) {
  22. this._name = value;
  23. this.vm.name = value;
  24. }
  25. /** 关卡 */
  26. get lv(): number {
  27. return this._lv;
  28. }
  29. set lv(value: number) {
  30. this._lv = value;
  31. this.vm.lv = value;
  32. oops.storage.set("lv", value);
  33. }
  34. /** 关卡 */
  35. get skin(): number {
  36. return this._skin;
  37. }
  38. set skin(value: number) {
  39. this._skin = value;
  40. this.vm.skin = value;
  41. oops.storage.set("skin", value);
  42. }
  43. /** 关卡 */
  44. get reward(): boolean {
  45. return this._reward;
  46. }
  47. set reward(value: boolean) {
  48. this._reward = value;
  49. this.vm.reward = value;
  50. oops.storage.set("reward", value);
  51. }
  52. vmAdd() {
  53. VM.add(this.vm, "Account");
  54. }
  55. vmRemove() {
  56. VM.remove("Account");
  57. }
  58. reset() {
  59. this.vmRemove();
  60. this.name = "";
  61. }
  62. }