AccountModelComp.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /*
  2. * @Author: dgflash
  3. * @Date: 2021-11-12 10:02:31
  4. * @LastEditors: mojunshou 1637302775@qq.com
  5. * @LastEditTime: 2025-04-09 14:12:47
  6. */
  7. import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
  8. /**
  9. * 游戏账号数据
  10. */
  11. interface CurLevelInfo {
  12. level: number;
  13. score: number;
  14. }
  15. interface CurLevelConfig {
  16. level: number; //当前关卡
  17. score: number; //当前关卡目标分数
  18. skipCount: number; //当前关卡跳过次数
  19. eliminateScope: []; //消除配置
  20. eventType: string //消除配置
  21. }
  22. //费用配置
  23. interface CostInfo {
  24. handlingCharge: number; //处理费
  25. giftNum: number; //赠送金
  26. }
  27. @ecs.register('AccountModel')
  28. export class AccountModelComp extends ecs.Comp {
  29. /** 账号名 */
  30. accountName: string = null!;
  31. /**玩家UID */
  32. uid: number = -1;
  33. /**玩家头像*/
  34. headUrl: string = null!
  35. /**当前关卡--默认从0开始*/
  36. curLevel: number = 0;
  37. /**游戏币*/
  38. gameCoin: number = 0;
  39. /**红包币*/
  40. cashCoin: number = 0;
  41. /**目标分数*/
  42. targetScore: number = 0;
  43. /**协议类型 1隐私 2用户*/
  44. protocolType: number = 1;
  45. //当前关卡信息
  46. curLevelInfo: CurLevelInfo = null!;
  47. /**当前关卡配置*/
  48. curLevelConfig: CurLevelConfig = null!;
  49. /**游戏费用配置*/
  50. costInfo: CostInfo = null!;
  51. /**是否登录过*/
  52. isLogined: boolean = false;
  53. reset() {
  54. this.accountName = null!;
  55. this.uid = -1;
  56. this.headUrl = null!;
  57. this.curLevel = 0;
  58. this.gameCoin = 0;
  59. this.cashCoin = 0;
  60. this.protocolType = 1;
  61. this.curLevelInfo = null!;
  62. this.curLevelConfig = null!;
  63. this.costInfo = null!;
  64. }
  65. //保存微信数据
  66. setWechatInfo(data: any) {
  67. this.accountName = data.nickname;
  68. this.uid = data.uid;
  69. this.headUrl = data.headImgUrl;
  70. }
  71. //设置账号数据
  72. setAccountInfo(data: any) {
  73. // this.AccountName = data.accountName;
  74. this.uid = data.uid;
  75. this.curLevelInfo = data.currentLevelInfo;
  76. this.curLevelConfig = data.currentLevelConfig;
  77. this.costInfo = data.handlingChargeConf;
  78. this.isLogined = data.logined;
  79. }
  80. }