import { _decorator, assetManager, Component, Node, Prefab } from 'cc'; import { resLoader } from '../../core_tgx/base/ResLoader'; import { ResourcePool } from './ResourcePool'; const { ccclass, property } = _decorator; @ccclass('TakeGobletGlobalInstance') export class TakeGobletGlobalInstance { private static _instance: TakeGobletGlobalInstance; public static get instance() { if (this._instance) { return this._instance; } this._instance = new TakeGobletGlobalInstance(); return this._instance; } /** 异步加载调酒杯预设*/ async loadAsyncCocktail(height: CupHeight): Promise { return new Promise((resolve, reject) => { const bundle = assetManager.getBundle(resLoader.gameBundleName); if (!bundle) { console.error("module_nut is null!"); reject(); } let numStr = 'Two'; if (height == CupHeight.Three) { numStr = 'Three'; } else if (height == CupHeight.Four) { numStr = 'Four'; } resLoader.loadAsync(resLoader.gameBundleName, `Prefabs/Cup/Cocktail/Cocktail${numStr}`, Prefab).then((prefab: Prefab) => { resolve(prefab); }) }) } public levels: Node = null; // 初始化调酒杯配置 getInitialCupsConfig(): { height: CupHeight; count: number }[] { return [ { height: CupHeight.Two, count: 3 }, { height: CupHeight.Three, count: 5 }, { height: CupHeight.Four, count: 7 } ]; } // 生成随机颜色数组 public getRandomColor(): WaterColors { const colors = Object.values(WaterColors).filter(v => !isNaN(Number(v))) as WaterColors[]; return colors[Math.floor(Math.random() * colors.length)]; } } /**道具类型 * @param FillUp 补满 * @param MoveOut 移出 * @param Disturb 打乱 */ export enum TYPE_ITEM { REVOKE = 1, MoveOut = 2, Disturb = 3, } export enum WaterColors { Purple = 1, // 紫 Magenta = 2, // 紫红 Pink = 3, // 粉 Red = 4, // 红 Yellow = 5, // 黄 Green = 6, // 绿 Cyan = 7, // 青 Blue = 8, // 蓝 DarkBlue = 9, // 深蓝 } // 定义对应的十六进制颜色值 export const WaterColorHex: Record = { [WaterColors.Blue]: "#317EFE", [WaterColors.Green]: "#4CF02F", [WaterColors.Red]: "#FF3939", [WaterColors.Cyan]: "#37F5FD", [WaterColors.Yellow]: "#FEF344", [WaterColors.Pink]: "#FD9FD2", [WaterColors.Purple]: "#D62F9C", [WaterColors.Magenta]: "#EE60FE", [WaterColors.DarkBlue]: "#3052A1", }; /**杯子高度*/ export enum CupHeight { One = 1, Two = 2, Three = 3, Four = 4, }