|
|
@@ -1,7 +1,10 @@
|
|
|
import { ecs } from "../../../../../extensions/oops-plugin-framework/assets/libs/ecs/ECS";
|
|
|
import { SingletonModuleComp, smc } from "../../common/SingletonModuleComp";
|
|
|
+import { PuppetAnimatorType } from "../../puppet/model/PuppetEnum";
|
|
|
+import { PuppetModelComp } from "../../puppet/model/PuppetModelComp";
|
|
|
import { Puppet } from "../../puppet/puppet";
|
|
|
import { PuppetViewComp } from "../../puppet/view/PuppetViewComp";
|
|
|
+import { Subway } from "../../subway/Subway";
|
|
|
import { Checkpoint } from "../Checkpoint";
|
|
|
import { CheckpointModelComp } from "../model/CheckpointModel";
|
|
|
|
|
|
@@ -23,31 +26,70 @@ export class FullVehicleOperationSystem extends ecs.ComblockSystem implements ec
|
|
|
}
|
|
|
|
|
|
entityEnter(e: Checkpoint): void {
|
|
|
- const curVehicleModel = e.CheckpointModel.curVehicle.VehicleModel
|
|
|
+ const curVehicleModel = e.CheckpointModel.curVehicle.VehicleModel
|
|
|
const needCount = curVehicleModel.capcity - curVehicleModel.useSit
|
|
|
const color = curVehicleModel.color
|
|
|
const puppets = e.CheckpointModel.puppets
|
|
|
let count = 0
|
|
|
for (let index = 0; index < puppets.length; index++) {
|
|
|
const element = puppets[index];
|
|
|
- if(element.PuppetModel.color===color){
|
|
|
- count+=1
|
|
|
+ if (element.PuppetModel.color === color) {
|
|
|
+ count += 1
|
|
|
element.PuppetView.animator.onRunComplete = () => {
|
|
|
e.CheckpointModel.curVehicle.VehicleView.createPuppet()
|
|
|
e.removeChild(element)
|
|
|
element.destroy()
|
|
|
- e.CheckpointModel.peopleCount-=1
|
|
|
+ e.CheckpointModel.peopleCount -= 1
|
|
|
}
|
|
|
const cell = e.CheckpointModel.cells
|
|
|
- cell[element.PuppetModel.x][element.PuppetModel.y] = null
|
|
|
+ const { x, y } = element.PuppetModel
|
|
|
+ cell[x][y] = null
|
|
|
+ e.CheckpointModel.path_grid[x][y].fill = null
|
|
|
e.CheckpointModel.curVehicle.VehicleModel.useSit += 1
|
|
|
element.PuppetView.animator.moveToTarget(e.CheckpointModel.curVehicle.VehicleView.node.position.clone())
|
|
|
}
|
|
|
- if(count>=needCount){
|
|
|
+ if (count >= needCount) {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
+ if (count < needCount) {
|
|
|
+ const subways = e.CheckpointModel.subways
|
|
|
+ for (let index = 0; index < subways.length; index++) {
|
|
|
+ const subway = subways[index];
|
|
|
+ const peopleIndex = subway.SubwayModel.colorArr.findIndex(val => val === color)
|
|
|
+ if (peopleIndex > -1) {
|
|
|
+ count += 1
|
|
|
+ subway.SubwayModel.colorArr.splice(peopleIndex, 1)
|
|
|
+ subway.SubwayView.updateCount(subway.SubwayModel.colorArr.length)
|
|
|
+ const tempPuppet = this.creatPuppet(color)
|
|
|
+ const account = smc.initialize.account
|
|
|
+ tempPuppet.load(account.checkpoint.CheckpointView.node, color, subway.SubwayView.node.position.clone(), account.AccountModel.skin);
|
|
|
+ e.addChild(tempPuppet)
|
|
|
+
|
|
|
+ tempPuppet.PuppetView.animator.onRunComplete = () => {
|
|
|
+ e.CheckpointModel.curVehicle.VehicleView.createPuppet()
|
|
|
+ e.removeChild(tempPuppet)
|
|
|
+ tempPuppet.destroy()
|
|
|
+ e.CheckpointModel.peopleCount -= 1
|
|
|
+ }
|
|
|
+ e.CheckpointModel.curVehicle.VehicleModel.useSit += 1
|
|
|
+ tempPuppet.PuppetView.animator.moveToTarget(e.CheckpointModel.curVehicle.VehicleView.node.position.clone())
|
|
|
+
|
|
|
+ }
|
|
|
+ if (count >= needCount) {
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
e.remove(FullVehicleOperationComp)
|
|
|
}
|
|
|
|
|
|
+ creatPuppet(color: string) {
|
|
|
+ const puppet = ecs.getEntity<Puppet>(Puppet)
|
|
|
+ const puppetModel = puppet.get(PuppetModelComp)
|
|
|
+ puppetModel.color = color
|
|
|
+ puppetModel.withColider = true
|
|
|
+ return puppet
|
|
|
+ }
|
|
|
+
|
|
|
}
|