DataModel.ts 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. import { _decorator, Component, Node } from 'cc';
  2. import { ColorDate } from './ColorDate';
  3. import { Global } from './Global';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('DataModel')
  6. export class DataModel {
  7. //颜色设置
  8. public static base_color_arr = [
  9. //深青1 0 0
  10. ColorDate.new_bean(0,238, 0 ,10009),
  11. //1
  12. ColorDate.new_bean(255,69, 0 ,10008),
  13. //171, 177, 187 灰白1
  14. ColorDate.new_bean(105,105,105,10002 ),
  15. //11, 246, 235 青1
  16. ColorDate.new_bean(202,255,112,10001),
  17. //18, 101, 246 绿1
  18. ColorDate.new_bean(162, 205, 90 ,10003),
  19. //紫色1 85
  20. ColorDate.new_bean(186,85, 211 ,10007),
  21. //5, 127, 201 浅蓝1
  22. ColorDate.new_bean(0, 154,205,10004),
  23. //255, 87, 51 橘红1
  24. ColorDate.new_bean(255, 127, 36 ,10006),
  25. //255, 195, 黄1
  26. ColorDate.new_bean(255,215,0,10005),
  27. ];
  28. //备份一下原始的设置
  29. public static base_color_arr_back = [
  30. //深青
  31. ColorDate.new_bean(13,105, 105 ,10009),
  32. //💜
  33. ColorDate.new_bean(241,24, 245 ,10008),
  34. //171, 177, 187 灰白
  35. ColorDate.new_bean(171, 177, 187,10002 ),
  36. //11, 246, 235 青
  37. ColorDate.new_bean(11,246,235,10001),
  38. //18, 101, 246 绿
  39. ColorDate.new_bean(130, 235, 93 ,10003),
  40. //紫色
  41. ColorDate.new_bean(124,87, 229 ,10007),
  42. //5, 127, 201 浅蓝
  43. ColorDate.new_bean(38, 119, 204 ,10004),
  44. //255, 87, 51 橘红
  45. ColorDate.new_bean(239, 91, 122 ,10006),
  46. //255, 195, 黄
  47. ColorDate.new_bean(208,186, 74 ,10005),
  48. ];
  49. private static lvl_color_arr = [];
  50. public static generate_lvl_color_arr(args:number){
  51. DataModel.lvl_color_arr = [];
  52. for(let i = 0;i<DataModel.base_color_arr.length;i++){
  53. DataModel.lvl_color_arr.push(DataModel.base_color_arr[i].clone());
  54. if(DataModel.lvl_color_arr.length>=args){
  55. break;
  56. }
  57. }
  58. }
  59. private static lvl_color_index: number = 0;
  60. public static get_lvl_color(): ColorDate {
  61. let ret = DataModel.lvl_color_arr[DataModel.lvl_color_index];
  62. DataModel.lvl_color_index += 1;
  63. if (DataModel.lvl_color_index >= DataModel.lvl_color_arr.length) {
  64. DataModel.lvl_color_index = 0;
  65. }
  66. return ret;
  67. }
  68. private static layer_color_index: number = 0;
  69. public static get_layer_color(): ColorDate {
  70. let ret = DataModel.base_color_arr[DataModel.layer_color_index];
  71. DataModel.layer_color_index += 1;
  72. if (DataModel.layer_color_index >= DataModel.base_color_arr.length) {
  73. DataModel.layer_color_index = 0;
  74. }
  75. return ret;
  76. }
  77. public static random_base_color() {
  78. DataModel.base_color_arr.sort(() => {
  79. return 0.5 - Math.random();
  80. });
  81. }
  82. // group_index_arr = [];
  83. private static cur_group_index = 0;
  84. public static get_new_group_index() {
  85. let temp = 1 << DataModel.cur_group_index;
  86. DataModel.cur_group_index += 1;
  87. if (DataModel.cur_group_index > 30) {
  88. DataModel.cur_group_index = 0;
  89. }
  90. // console.log("group:::::",temp);
  91. return temp;
  92. }
  93. }