|
@@ -3,6 +3,8 @@ import { ResLoader, resLoader } from "db://assets/core_tgx/base/ResLoader";
|
|
|
import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
|
|
|
import { TornadoComponent } from "../Component/TornadoComponent";
|
|
|
import { TornadoAIComponent } from "../Component/TornadoAIComponent";
|
|
|
+import { AttributeBonusMgr } from "./AttributeBonusMgr";
|
|
|
+import { Tableai_config } from "db://assets/module_basic/table/Tableai_config";
|
|
|
|
|
|
const res = [
|
|
|
"Prefabs/Tornado",
|
|
@@ -23,13 +25,17 @@ export class PlayerMgr {
|
|
|
}
|
|
|
|
|
|
public tornadoNode: Node = null;//玩家节点
|
|
|
+ public aiPlayersConfig: Map<number, any> = new Map();//AI玩家配置
|
|
|
+ public createAIPlayerCount: number = 3;//创建AI玩家数量
|
|
|
+ public aiConfigCount: number = 3;//AI配置数量
|
|
|
+
|
|
|
+ public pickAiMap: Map<number, Tableai_config> = new Map();//权重随机的AI
|
|
|
|
|
|
//创建AI玩家
|
|
|
public async genareatorAIPlayer(): Promise<void> {
|
|
|
return new Promise(async (resolve, reject) => {
|
|
|
- const aiCount: number = 1;
|
|
|
const aiPoints = StormSunderGlobalInstance.instance.aiPoints;
|
|
|
- for (let i = 0; i < aiCount; i++) {
|
|
|
+ for (let i = 0; i < this.createAIPlayerCount; i++) {
|
|
|
const infoPrefab = await resLoader.loadAsync(resLoader.gameBundleName, res[0], Prefab);
|
|
|
let infoNode = instantiate(infoPrefab);
|
|
|
infoNode.parent = StormSunderGlobalInstance.instance.players;
|
|
@@ -65,5 +71,27 @@ export class PlayerMgr {
|
|
|
})
|
|
|
})
|
|
|
}
|
|
|
+
|
|
|
+ /** 所有AI玩家配置数据*/
|
|
|
+ addAIPlayers() {
|
|
|
+ for (let id = 1; id <= this.aiConfigCount; id++) {
|
|
|
+ const config = AttributeBonusMgr.inst.aiConfig.getAIConfigById(id);
|
|
|
+ if (config) {
|
|
|
+ this.aiPlayersConfig.set(id, config); // 保存配置
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log("AI玩家配置数据:", this.aiPlayersConfig);
|
|
|
+ }
|
|
|
+
|
|
|
+ /** 根据权重计算 排序储存*/
|
|
|
+ weightGeneateAIConfig(): Tableai_config[] {
|
|
|
+ const result: Tableai_config[] = [];
|
|
|
+ for (let i = 0; i < this.aiConfigCount; i++) {
|
|
|
+ console.log(this.aiPlayersConfig[i].data.weight);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|