TakeGobletGlobalInstance.ts 4.1 KB

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