AccountModelComp.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /** 昵称 */
  17. get name(): string {
  18. return this._name;
  19. }
  20. set name(value: string) {
  21. this._name = value;
  22. this.vm.name = value;
  23. }
  24. /** 关卡 */
  25. get lv(): number {
  26. return this._lv;
  27. }
  28. set lv(value: number) {
  29. this._lv = value;
  30. this.vm.lv = value;
  31. oops.storage.set("lv", value);
  32. }
  33. /** 关卡 */
  34. get skin(): number {
  35. return this._skin;
  36. }
  37. set skin(value: number) {
  38. this._skin = value;
  39. this.vm.skin = value;
  40. oops.storage.set("skin", value);
  41. }
  42. vmAdd() {
  43. VM.add(this.vm, "Account");
  44. }
  45. vmRemove() {
  46. VM.remove("Account");
  47. }
  48. reset() {
  49. this.vmRemove();
  50. this.name = "";
  51. }
  52. }