TakeGobletGlobalInstance.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. public levels: Node = null;
  35. // 初始化调酒杯配置
  36. getInitialCupsConfig(): { height: CupHeight; count: number }[] {
  37. return [
  38. { height: CupHeight.Two, count: 3 },
  39. { height: CupHeight.Three, count: 5 },
  40. { height: CupHeight.Four, count: 7 }
  41. ];
  42. }
  43. // 生成随机颜色数组
  44. public getRandomColor(): WaterColors {
  45. const colors = Object.values(WaterColors).filter(v => !isNaN(Number(v))) as WaterColors[];
  46. return colors[Math.floor(Math.random() * colors.length)];
  47. }
  48. }
  49. /**道具类型
  50. * @param FillUp 补满
  51. * @param MoveOut 移出
  52. * @param Disturb 打乱
  53. */
  54. export enum TYPE_ITEM {
  55. REVOKE = 1,
  56. MoveOut = 2,
  57. Disturb = 3,
  58. }
  59. export enum WaterColors {
  60. Purple = 1, // 紫
  61. Magenta = 2, // 紫红
  62. Pink = 3, // 粉
  63. Red = 4, // 红
  64. Yellow = 5, // 黄
  65. Green = 6, // 绿
  66. Cyan = 7, // 青
  67. Blue = 8, // 蓝
  68. DarkBlue = 9, // 深蓝
  69. }
  70. // 定义对应的十六进制颜色值
  71. export const WaterColorHex: Record<WaterColors, string> = {
  72. [WaterColors.Blue]: "#317EFE",
  73. [WaterColors.Green]: "#4CF02F",
  74. [WaterColors.Red]: "#FF3939",
  75. [WaterColors.Cyan]: "#37F5FD",
  76. [WaterColors.Yellow]: "#FEF344",
  77. [WaterColors.Pink]: "#FD9FD2",
  78. [WaterColors.Purple]: "#D62F9C",
  79. [WaterColors.Magenta]: "#EE60FE",
  80. [WaterColors.DarkBlue]: "#3052A1",
  81. };
  82. /**杯子高度*/
  83. export enum CupHeight {
  84. One = 1,
  85. Two = 2,
  86. Three = 3,
  87. Four = 4,
  88. }