Data.ts 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. /*
  2. ***********************************************************************************
  3. * 姓名:xxj
  4. * 功能:数据
  5. * 日期:2021.2.1
  6. * 备注:
  7. ***********************************************************************************
  8. */
  9. let dataName = 'tBall_';
  10. /**
  11. * 用户数据
  12. */
  13. export class UserData {
  14. public userId: string = ""; //本地用户唯一标识
  15. public isAgree: boolean = false; //
  16. public coinNum: number = 0; //金币数量
  17. public gemNum: number = 0; //宝石数量
  18. public sound: boolean = true; //是否播放声音
  19. public vibration: boolean = true; //震动
  20. public currentDate: number = 0; //当前日期
  21. public createTime: number = 0; //用户创建时间
  22. public awardTime: number = 0; //登陆奖励时间
  23. public roleId: number = 1; //使用到角色id
  24. public roleList: number[] = []; //
  25. public roleAds: number[] = []; // 角色广告计数
  26. public dressId: number = 101; //装饰ID
  27. public itemId: number = 201; //装饰ID
  28. //大招技能等级
  29. public bigSkills = [1, 1, 1, 1, 1];
  30. //金币
  31. public coin: number = 4000;//金币
  32. public diamond: number = 0;//钻石
  33. public skillSuccessTimes = 0;//大招模式连胜次数
  34. public skillGuide: number = 0;//大招模式新手引导
  35. public skillAccTimes = 0;//大招模式累计胜利次数
  36. //摆球达人关卡通关情况
  37. public placeBallData: Array<any> = [];
  38. //每日分享钻石次数
  39. public shareDiamondTimes: number = 0;
  40. //每日录屏分享次数
  41. public dailyVideoShareTimes: number = 0;
  42. //小秘书
  43. public secretary: Array<number> = [1, 0];
  44. //当前选中的秘书
  45. public curSecretary: number = 0;
  46. //球杆
  47. public ballRod: Array<number> = [1, 0, 0, 0, 0, 1];
  48. //当前使用的球杆
  49. public curBallRod: number = 5;
  50. //签到天数
  51. public signData: number = 0;
  52. //签到时间戳
  53. public signTime: number = 0;
  54. //转盘转动次数
  55. public drawTimes: number = 0;
  56. //转盘中奖励领取次数
  57. public drawAwardTimes: number = 0;
  58. //每日免费转盘
  59. public dailyfreeDrawTimes: number = 1;
  60. //体力
  61. public power: number = 5;
  62. public powerTime: number = 0; //体力计时
  63. //挑战赛次数
  64. public challengeTimes = 0;
  65. //每日是否额外领取签到奖励
  66. public extraSign = 0;
  67. //经典模式胜利场次
  68. public classicTimes = 0;
  69. //引导看广告延长辅助线
  70. public guideHelpLine = 0;
  71. //是否是新用户
  72. public newUser = true;
  73. //首次白球进洞
  74. rootBallFoul = 0;
  75. //首次超时犯规
  76. timeoutFoul = 0;
  77. constructor() {
  78. this.roleList = [1];
  79. }
  80. public saveData() {
  81. let data = {};
  82. for (let k in this) {
  83. data[k.toString()] = this[k];
  84. }
  85. // console.log('zh:savedata start ');
  86. Laya.LocalStorage.setItem(dataName + "userdata", JSON.stringify(data));
  87. // console.log('zh:savedata end ');
  88. }
  89. public getData() {
  90. let ld = Laya.LocalStorage.getItem(dataName + "userdata");
  91. if (ld) {
  92. let localData = JSON.parse(ld);
  93. if (localData) {
  94. for (let k in this) {
  95. let key = k.toString();
  96. let data = localData[key];
  97. if (data != undefined) {
  98. this[k] = data;
  99. }
  100. }
  101. }
  102. }
  103. }
  104. }
  105. export class ItemData {
  106. public itemList: {}; //获得的道具
  107. constructor() {
  108. this.itemList = {};
  109. //添加默认道具
  110. this.itemList[101] = { id: 101, count: 1, adnum: 0, active: true };
  111. this.itemList[201] = { id: 201, count: 1, adnum: 0, active: true };
  112. }
  113. public saveData(): void {
  114. Laya.LocalStorage.setItem(dataName + "itemdata", JSON.stringify(this.itemList));
  115. }
  116. public getData(): void {
  117. let ld = Laya.LocalStorage.getItem(dataName + "itemdata");
  118. if (ld) {
  119. let localData = JSON.parse(ld);
  120. if (localData) {
  121. this.itemList = localData;
  122. }
  123. }
  124. }
  125. }
  126. /**
  127. * 游戏数据
  128. */
  129. export class GameData {
  130. public curLevel: number = 0; //当前关卡
  131. public gameType: number = 1; //游戏类别
  132. public signIdx: number = 0; //签到序号
  133. public signMax: number = 0; //可签序号
  134. public rotaryTime: number = 0; //抽奖时间
  135. public rotaryCount: number = 0; //抽奖次数
  136. public rotaryList: number[] = []; //当前轮已抽取了的
  137. public diyCount: number = 3; //
  138. public awardIdx: number = 0; //当前奖励进度
  139. //public adGem:number=10; //获得钻石次数
  140. public shareNum: number = 2; //分享奖励次数
  141. public rankWeek: number = 0; //周排行榜记录
  142. public rankScore: number = 0; //排行榜本地数据
  143. public gameCount: number = 0; //大招模式游戏次数
  144. public trySkill: number = -1; //试用技能
  145. public tryTime: number = 0; //大招试用时间点
  146. constructor() {
  147. }
  148. public saveData(): void {
  149. let data = {};
  150. for (let k in this) {
  151. data[k.toString()] = this[k];
  152. }
  153. Laya.LocalStorage.setItem(dataName + "gamedata", JSON.stringify(data));
  154. }
  155. public getData(): void {
  156. let ld = Laya.LocalStorage.getItem(dataName + "gamedata");
  157. if (ld) {
  158. let localData = JSON.parse(ld);
  159. if (localData) {
  160. for (let k in this) {
  161. let key = k.toString();
  162. let data = localData[key];
  163. if (data != undefined) {
  164. this[k] = data;
  165. }
  166. }
  167. }
  168. }
  169. }
  170. }