|
@@ -13,6 +13,9 @@ import { Puppet } from "../../puppet/puppet";
|
|
|
import { PuppetModelComp } from "../../puppet/model/PuppetModelComp";
|
|
import { PuppetModelComp } from "../../puppet/model/PuppetModelComp";
|
|
|
import { ObstacleModelComp } from "../../obstacle/model/ObstacleModelComp";
|
|
import { ObstacleModelComp } from "../../obstacle/model/ObstacleModelComp";
|
|
|
import { PathFindComp } from "../../common/ecs/path/PathFind";
|
|
import { PathFindComp } from "../../common/ecs/path/PathFind";
|
|
|
|
|
+import { oops } from "../../../../../extensions/oops-plugin-framework/assets/core/Oops";
|
|
|
|
|
+import { Vehicle } from "../../vehicle/Vehicle";
|
|
|
|
|
+import { VehicleModelComp } from "../../vehicle/model/VehicleModelComp";
|
|
|
|
|
|
|
|
/** 初始化游戏公共资源 */
|
|
/** 初始化游戏公共资源 */
|
|
|
@ecs.register('InitCheckpoint')
|
|
@ecs.register('InitCheckpoint')
|
|
@@ -27,13 +30,30 @@ export class InitCheckpointSystem extends ecs.ComblockSystem implements ecs.IEnt
|
|
|
|
|
|
|
|
entityEnter(e: Checkpoint): void {
|
|
entityEnter(e: Checkpoint): void {
|
|
|
const levelConfig = e.get(CheckpointModelLevelComp)?.rtluCurrent
|
|
const levelConfig = e.get(CheckpointModelLevelComp)?.rtluCurrent
|
|
|
- const { gridCount, levelColor, peopleCount, levelObstacle, obstacleCount } = levelConfig
|
|
|
|
|
|
|
+ const { gridCount, levelColor, peopleCount, levelObstacle, obstacleCount, stationCount } = levelConfig
|
|
|
|
|
|
|
|
|
|
+ this.resetCheckpoint(e)
|
|
|
|
|
+
|
|
|
|
|
+ // 关卡数据
|
|
|
|
|
+ e.CheckpointModel.vmAdd();
|
|
|
|
|
+
|
|
|
|
|
+ // 添加关卡到场景
|
|
|
|
|
+ e.load(oops.game.root, v3(0, 0, 0));
|
|
|
this.createGrid(e, gridCount, gridCount, levelColor, levelObstacle, peopleCount, obstacleCount)
|
|
this.createGrid(e, gridCount, gridCount, levelColor, levelObstacle, peopleCount, obstacleCount)
|
|
|
- this.createStation(e, levelConfig.stationCount)
|
|
|
|
|
|
|
+ this.createStation(e, stationCount)
|
|
|
|
|
+ this.createVehicle(e, peopleCount,levelColor)
|
|
|
e.remove(InitCheckpointComp)
|
|
e.remove(InitCheckpointComp)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ resetCheckpoint(e: Checkpoint) {
|
|
|
|
|
+ e.remove(CheckpointViewComp);
|
|
|
|
|
+ e.add(CheckpointModelComp, true)
|
|
|
|
|
+ e.children.forEach(child => {
|
|
|
|
|
+ e.removeChild(child);
|
|
|
|
|
+ child.destroy();
|
|
|
|
|
+ });
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 生成棋盘相关
|
|
// 生成棋盘相关
|
|
|
createGrid(e: Checkpoint, row: number, col: number, colors: string[], obstacles: number[], peopleCount: number, obstacleCount: number) {
|
|
createGrid(e: Checkpoint, row: number, col: number, colors: string[], obstacles: number[], peopleCount: number, obstacleCount: number) {
|
|
|
const checkpoint_root = e.get(CheckpointViewComp).node
|
|
const checkpoint_root = e.get(CheckpointViewComp).node
|
|
@@ -126,8 +146,20 @@ export class InitCheckpointSystem extends ecs.ComblockSystem implements ecs.IEnt
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 生成交通工具
|
|
// 生成交通工具
|
|
|
- createVehicle(e: Checkpoint) {
|
|
|
|
|
-
|
|
|
|
|
|
|
+ createVehicle(e: Checkpoint, peopleCount: number, colors: string[]) {
|
|
|
|
|
+ const checkpoint_root = e.get(CheckpointViewComp).node
|
|
|
|
|
+ const checkpoint_model = e.get(CheckpointModelComp)
|
|
|
|
|
+ const start_point = v3(0, 0, -5)
|
|
|
|
|
+ const vechicleCount = Math.ceil(peopleCount / 3)
|
|
|
|
|
+ for (let index = 0; index < vechicleCount; index++) {
|
|
|
|
|
+ const vehicle = ecs.getEntity<Vehicle>(Vehicle);
|
|
|
|
|
+ const vehicleModel = vehicle.get(VehicleModelComp)
|
|
|
|
|
+ vehicleModel.color = colors[index % 3]
|
|
|
|
|
+ // 添加车到场景
|
|
|
|
|
+ vehicle.load(checkpoint_root, vehicleModel.color, start_point);
|
|
|
|
|
+ e.addChild(vehicle)
|
|
|
|
|
+ checkpoint_model.vehicles.push(vehicle)
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// 生成人物
|
|
// 生成人物
|