TakeGobletGlobalInstance.ts 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import { _decorator, assetManager, Component, Node, Prefab } from 'cc';
  2. import { resLoader } from '../../core_tgx/base/ResLoader';
  3. import { ResourcePool } from './ResourcePool';
  4. const { ccclass, property } = _decorator;
  5. @ccclass('TakeGobletGlobalInstance')
  6. export class TakeGobletGlobalInstance {
  7. private static _instance: TakeGobletGlobalInstance;
  8. public static get instance() {
  9. if (this._instance) {
  10. return this._instance;
  11. }
  12. this._instance = new TakeGobletGlobalInstance();
  13. return this._instance;
  14. }
  15. /** 异步加载调酒杯预设*/
  16. async loadAsyncCocktail(height: CupHeight): Promise<Prefab> {
  17. return new Promise((resolve, reject) => {
  18. const bundle = assetManager.getBundle(resLoader.gameBundleName);
  19. if (!bundle) {
  20. console.error("module_nut is null!");
  21. reject();
  22. }
  23. let numStr = 'Two';
  24. if (height == CupHeight.Three) {
  25. numStr = 'Three';
  26. } else if (height == CupHeight.Four) {
  27. numStr = 'Four';
  28. }
  29. resLoader.loadAsync(resLoader.gameBundleName, `Prefabs/Cup/Cocktail/Cocktail${numStr}`, Prefab).then((prefab: Prefab) => {
  30. resolve(prefab);
  31. })
  32. })
  33. }
  34. /** 生成原浆杯高度*/
  35. public generateOriginCupHeight(): CupHeight {
  36. //DOTO 配置中获取概率
  37. return CupHeight.Three;
  38. }
  39. /** 异步加载调酒杯预设*/
  40. async loadAsyncOriginCup(height: CupHeight): Promise<Prefab> {
  41. return new Promise((resolve, reject) => {
  42. const bundle = assetManager.getBundle(resLoader.gameBundleName);
  43. if (!bundle) {
  44. console.error("module_nut is null!");
  45. reject();
  46. }
  47. let numStr = 'Two';
  48. if (height == CupHeight.Three) {
  49. numStr = 'Three';
  50. } else if (height == CupHeight.Four) {
  51. numStr = 'Four';
  52. }
  53. resLoader.loadAsync(resLoader.gameBundleName, `Prefabs/Cup/Original/Original${numStr}`, Prefab).then((prefab: Prefab) => {
  54. resolve(prefab);
  55. })
  56. })
  57. }
  58. public levels: Node = null;
  59. // 初始化调酒杯配置
  60. getInitialCupsConfig(): { height: CupHeight; count: number }[] {
  61. return [
  62. { height: CupHeight.Two, count: 3 },
  63. { height: CupHeight.Three, count: 5 },
  64. { height: CupHeight.Four, count: 7 }
  65. ];
  66. }
  67. // 生成随机颜色数组
  68. public getRandomColor(): WaterColors {
  69. const colors = Object.values(WaterColors).filter(v => !isNaN(Number(v))) as WaterColors[];
  70. return colors[Math.floor(Math.random() * colors.length)];
  71. }
  72. }
  73. /**道具类型
  74. * @param FillUp 补满
  75. * @param MoveOut 移出
  76. * @param Disturb 打乱
  77. */
  78. export enum TYPE_ITEM {
  79. FillUp = 1,
  80. MoveOut = 2,
  81. Refresh = 3,
  82. }
  83. export enum WaterColors {
  84. Purple = 1, // 紫
  85. Magenta = 2, // 紫红
  86. Pink = 3, // 粉
  87. Red = 4, // 红
  88. Yellow = 5, // 黄
  89. Green = 6, // 绿
  90. Cyan = 7, // 青
  91. Blue = 8, // 蓝
  92. DarkBlue = 9, // 深蓝
  93. }
  94. // 定义对应的十六进制颜色值
  95. export const WaterColorHex: Record<WaterColors, string> = {
  96. [WaterColors.Blue]: "#317EFE",
  97. [WaterColors.Green]: "#4CF02F",
  98. [WaterColors.Red]: "#FF3939",
  99. [WaterColors.Cyan]: "#37F5FD",
  100. [WaterColors.Yellow]: "#FEF344",
  101. [WaterColors.Pink]: "#FD9FD2",
  102. [WaterColors.Purple]: "#D62F9C",
  103. [WaterColors.Magenta]: "#EE60FE",
  104. [WaterColors.DarkBlue]: "#3052A1",
  105. };
  106. export const WaterColorLog: Record<WaterColors, string> = {
  107. [WaterColors.Blue]: "蓝色",
  108. [WaterColors.Green]: "绿色",
  109. [WaterColors.Red]: "红色",
  110. [WaterColors.Cyan]: "青色",
  111. [WaterColors.Yellow]: "黄色",
  112. [WaterColors.Pink]: "粉色",
  113. [WaterColors.Purple]: "紫色",
  114. [WaterColors.Magenta]: '紫红色',
  115. [WaterColors.DarkBlue]: '深蓝色'
  116. };
  117. /**杯子高度*/
  118. export enum CupHeight {
  119. One = 1,
  120. Two = 2,
  121. Three = 3,
  122. Four = 4,
  123. }