Эх сурвалжийг харах

原浆杯刷新概率权重

woso_javan 3 сар өмнө
parent
commit
47c0fb1b31

+ 1 - 1
assets/module_basic/config/levels_config.json

@@ -1 +1 @@
-{"1":{"level":1,"color":9,"wineglass":[4,45,1],"wineglass_color":[9,7],"measuringcup":[5,95,5],"measuringcup_number":10,"measuringcup_color":7,"query_probability":15,"query_ceiling":4}}
+{"1":{"level":1,"color":9,"wineglass":[4,45,1],"wineglass_color":[9,7],"measuringcup":[40,10,50],"measuringcup_number":10,"measuringcup_color":7,"query_probability":15,"query_ceiling":4,"ice_probability":10,"ice_ceiling":1,"ice_thelimit":30,"change_ceiling":15,"change_thelimit":4}}

+ 20 - 0
assets/module_basic/table/Tablelevels_config.ts

@@ -51,5 +51,25 @@ export class Tablelevels_config {
     get query_ceiling(): number {
         return this.data.query_ceiling;
     }
+    /** 冰冻水刷新率 */
+    get ice_probability(): number {
+        return this.data.ice_probability;
+    }
+    /** 冰冻水上限 */
+    get ice_ceiling(): number {
+        return this.data.ice_ceiling;
+    }
+    /** 冰冻水极限 */
+    get ice_thelimit(): number {
+        return this.data.ice_thelimit;
+    }
+    /** 万能水刷新率 */
+    get change_ceiling(): number {
+        return this.data.change_ceiling;
+    }
+    /** 万能水上限 */
+    get change_thelimit(): number {
+        return this.data.change_thelimit;
+    }
 }
     

+ 7 - 6
assets/module_take_goblet/Script/LevelAction.ts

@@ -38,7 +38,7 @@ export class LevelAction extends Component {
     }
 
     start() {
-        this.generateInitialCups();
+        // this.generateInitialCups();
         this.registerListener();
     }
 
@@ -126,12 +126,12 @@ export class LevelAction extends Component {
             tgxUITips.show('我知道你很急,但你先别急!');
             return;
         }
-
+        const levelModel = LevelManager.instance.levelModel;
         const outCups = this.outArea.getCups() as Node[];
         const waitCups = this.waitArea.getCups() as Node[];
 
-        // DOTO 取前7个杯子颜色后期修改
-        const allCups = [...outCups, ...waitCups].slice(0, 7);
+        const measuringcup_number = levelModel.levelConfig.measuringcup_number;
+        const allCups = [...outCups, ...waitCups].slice(0, measuringcup_number);
         const colors = allCups.map(cup => {
             const comp = cup.getComponent(CocktailCup);
             return comp ? comp.cupColor : WaterColors.Blue;
@@ -399,8 +399,9 @@ export class LevelAction extends Component {
     }
 
     private async spawnNewOriginCup(targetPos: Vec3) {
-        // DOTO 获取颜色配置
-        const colors = this.getAvailableColors(5); // 获取前5个颜色
+        const levelModel = LevelManager.instance.levelModel;
+        const measuringcup_number = levelModel.levelConfig.measuringcup_number;//获取调酒和等待区前面数量
+        const colors = this.getAvailableColors(measuringcup_number);
         if (colors.length <= 0) return;
 
         // 创建新原浆杯

+ 0 - 3
assets/module_take_goblet/Script/Manager/LevelMgr.ts

@@ -3,10 +3,7 @@ import { resLoader } from 'db://assets/core_tgx/base/ResLoader';
 import { EventDispatcher } from 'db://assets/core_tgx/easy_ui_framework/EventDispatcher';
 import { GlobalConfig } from '../../../start/Config/GlobalConfig';
 import { GameEvent } from '../Enum/GameEvent';
-import { LevelAction } from '../LevelAction';
 import { LevelModel } from '../Model/LevelModel';
-import { GameUtil } from '../GameUtil';
-import { TakeGobletGlobalInstance, WaterColors } from '../TakeGobletGlobalInstance';
 import { CocktailCup } from '../Component/CocktailCup';
 const { ccclass, property } = _decorator;
 

+ 21 - 1
assets/module_take_goblet/Script/TakeGobletGlobalInstance.ts

@@ -63,7 +63,27 @@ export class TakeGobletGlobalInstance {
 
     /** 生成原浆杯高度*/
     public generateOriginCupHeight(): CupHeight {
-        //DOTO 配置中获取概率
+        const { measuringcup } = LevelManager.instance.levelModel.levelConfig;
+        if (!measuringcup || measuringcup.length < 3) return CupHeight.Three;
+
+        const totalWeight = measuringcup.reduce((a, b) => a + b, 0);
+        if (totalWeight <= 0) return CupHeight.Three;
+
+        const randomValue = Math.random() * totalWeight;
+        let accumulated = 0;
+
+        for (let i = 0; i < measuringcup.length; i++) {
+            accumulated += measuringcup[i];
+            if (randomValue <= accumulated) {
+                // 根据索引映射到正确的CupHeight值
+                switch (i) {
+                    case 0: return CupHeight.Two;
+                    case 1: return CupHeight.Three;
+                    case 2: return CupHeight.Four;
+                    default: return CupHeight.Three;
+                }
+            }
+        }
         return CupHeight.Three;
     }