Ver Fonte

feat:修复游戏bug

zouwuqiang há 2 anos atrás
pai
commit
da72bb0009

Diff do ficheiro suprimidas por serem muito extensas
+ 0 - 0
assets/bundle/config/game/CheckpointLevel.json


+ 2 - 6
assets/bundle/game/model/vehicle/car1.fbx.meta

@@ -313,9 +313,7 @@
         },
         "_techIdx": 0,
         "_defines": [
-          {
-            "USE_INSTANCING": true
-          },
+          {},
           {},
           {},
           {}
@@ -754,9 +752,7 @@
         },
         "_techIdx": 0,
         "_defines": [
-          {
-            "USE_INSTANCING": true
-          },
+          {},
           {},
           {},
           {}

+ 1 - 1
assets/script/game/checkpoint/bll/ClearCellOperation.ts

@@ -33,10 +33,10 @@ export class ClearCellOperationSystem extends ecs.ComblockSystem implements ecs.
                 findVehicle.VehicleModel.useSit += 1
                 val.StationModel.puppet.PuppetView.animator.onRunComplete = () => {
                     findVehicle.VehicleView.createPuppet()
-                    e.CheckpointModel.peopleCount-=1
                     e.removeChild(val.StationModel.puppet)
                     val.StationModel.puppet.destroy()
                     val.StationModel.puppet = null
+                    e.CheckpointModel.peopleCount-=1
                 }
                 val.StationModel.puppet.PuppetView.animator.moveToTarget(findVehicle.VehicleView.node.position.clone())
             }

+ 48 - 6
assets/script/game/checkpoint/bll/FullVehicleOperation.ts

@@ -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
+    }
+
 }

+ 17 - 8
assets/script/game/checkpoint/bll/InitCheckpoint.ts

@@ -387,11 +387,26 @@ export class InitCheckpointSystem extends ecs.ComblockSystem implements ecs.IEnt
 
     // 生成交通工具
     createVehicle(e: Checkpoint, count: number, pcolor: number[], colorCount: any, colors: string[]) {
+        const copyColorCount = {...colorCount}
         const checkpoint_root = e.CheckpointView.node
         const checkpoint_model = e.CheckpointModel
         const availablePositions = Array.from({ length: count }, (_, i) => i)
         checkpoint_model.vehicles = Array(count).fill(null)
         const start_point = v3(-5, 0, 0)
+        pcolor.forEach((v,i)=>{
+            const color = colors[pcolor[i] - 1]
+            if (copyColorCount[color] > 0) {
+                const vehicle = ecs.getEntity<Vehicle>(Vehicle);
+                availablePositions.splice(i, 1)[0];
+                copyColorCount[color]-=3;
+                // 添加车到场景
+                vehicle.VehicleModel.color = color
+                const vehicleType = e.CheckpointModelLevel.rtluCurrent.vehicleType
+                vehicle.load(checkpoint_root, color, start_point, vehicleType);
+                e.addChild(vehicle)
+                checkpoint_model.vehicles[i] = vehicle
+            }
+        })
         while (availablePositions.length > 0) {
             let randomIndex = Math.floor(Math.random() * availablePositions.length);
 
@@ -399,19 +414,13 @@ export class InitCheckpointSystem extends ecs.ComblockSystem implements ecs.IEnt
             let colorIndex = Math.floor(Math.random() * colors.length);
             let color = colors[colorIndex];
 
-            if (colorCount[color] > 0) {
+            if (copyColorCount[color] > 0) {
                 // if (randomIndex < pcolor.length) {
                 //     availablePositions.splice(randomIndex, 1);
                 // }
                 const vehicle = ecs.getEntity<Vehicle>(Vehicle);
                 let index = availablePositions.splice(randomIndex, 1)[0];
-                if (pcolor && index < pcolor.length && colorCount[colors[pcolor[index] - 1]] > 0) {
-                    color = colors[pcolor[index] - 1]
-                    colorCount[color]--
-                } else {
-
-                    colorCount[color]--;
-                }
+                copyColorCount[color]-=3;
                 // 添加车到场景
                 vehicle.VehicleModel.color = color
                 const vehicleType = e.CheckpointModelLevel.rtluCurrent.vehicleType

+ 1 - 1
assets/script/game/checkpoint/bll/StationOperation.ts

@@ -26,12 +26,12 @@ export class StationOperationSystem extends ecs.ComblockSystem implements ecs.IE
             if (val.StationModel.puppet && val.StationModel.puppet.PuppetModel.color === e.CheckpointModel.curVehicle.VehicleModel.color) {
                 if (!e.CheckpointModel.curVehicle.VehicleModel.isFull) {
                     e.CheckpointModel.curVehicle.VehicleModel.useSit += 1
-                    e.CheckpointModel.peopleCount-=1
                     val.StationModel.puppet.PuppetView.animator.onRunComplete = () => {
                         e.CheckpointModel.curVehicle.VehicleView.createPuppet()
                         e.removeChild(val.StationModel.puppet)
                         val.StationModel.puppet.destroy()
                         val.StationModel.puppet = null
+                        e.CheckpointModel.peopleCount-=1
                     }
                     val.StationModel.puppet.PuppetView.animator.moveToTarget()
                 }

+ 4 - 0
assets/script/game/checkpoint/model/CheckpointModel.ts

@@ -108,6 +108,10 @@ export class CheckpointModelComp extends ecs.Comp {
         const flatArr = this.flattenArray(this.cells)
         return flatArr.filter(val => val instanceof Puppet && val.PuppetModel)
     }
+    get subways(): Subway[] {
+        const flatArr = this.flattenArray(this.cells)
+        return flatArr.filter(val => val instanceof Subway && val.SubwayModel)
+    }
 
     flattenArray(arr) {
         const result = [];

+ 6 - 0
assets/script/game/checkpoint/view/CheckpointAddCellViewComp.ts

@@ -44,6 +44,12 @@ export class CheckpointAddCellViewComp extends CCComp {
                 oops.gui.remove(UIID.AddCell);
                 break;
             case "btn_get":
+                const checkpoint = ecs.getSingleton(SingletonModuleComp).account.checkpoint
+                if (checkpoint.CheckpointModelBase.vm.addCellCount >= 3) {
+                    oops.gui.toast('该关卡使用次数已满')
+                    oops.gui.remove(UIID.AddCell);
+                    return
+                }
                 // ecs.getSingleton(SingletonModuleComp).account.checkpoint.add(AddCellOperationComp)
                 // ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.addCellCount+=1
                 AdManager.getInstance().showRewardVideoAd(()=>{

+ 6 - 0
assets/script/game/checkpoint/view/CheckpointClearViewComp.ts

@@ -43,6 +43,12 @@ export class CheckpointClearViewComp extends CCComp {
                 oops.gui.remove(UIID.ClearCell);
                 break;
             case "btn_get":
+                const checkpoint = ecs.getSingleton(SingletonModuleComp).account.checkpoint
+                if (checkpoint.CheckpointModelBase.vm.clearCount >= 3) {
+                    oops.gui.toast('该关卡使用次数已满')
+                    oops.gui.remove(UIID.ClearCell);
+                    return
+                }
                 // ecs.getSingleton(SingletonModuleComp).account.checkpoint.add(ClearCellOperationComp)
                 // ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.clearCount+=1
                 AdManager.getInstance().showRewardVideoAd(()=>{

+ 6 - 0
assets/script/game/checkpoint/view/CheckpointLeaveViewComp.ts

@@ -43,6 +43,12 @@ export class CheckpointLeaveViewComp extends CCComp {
                 oops.gui.remove(UIID.VehicleLeave);
                 break;
             case "btn_get":
+                const checkpoint = ecs.getSingleton(SingletonModuleComp).account.checkpoint
+                if (checkpoint.CheckpointModelBase.vm.leaveCount >= 3) {
+                    oops.gui.toast('该关卡使用次数已满')
+                    oops.gui.remove(UIID.VehicleLeave);
+                    return
+                }
                 // ecs.getSingleton(SingletonModuleComp).account.checkpoint.add(FullVehicleOperationComp)
                 // ecs.getSingleton(SingletonModuleComp).account.checkpoint.CheckpointModelBase.vm.leaveCount += 1
                 AdManager.getInstance().showRewardVideoAd(() => {

+ 2 - 2
assets/script/game/puppet/view/PuppetViewController.ts

@@ -58,9 +58,9 @@ export class PuppetViewController extends Component {
                             // end = v3(0, 0, 0)
                             this.puppet.PuppetView.animator.onRunPathComplete = () => {
                                 checkpoint.CheckpointModel.curVehicle.VehicleView.createPuppet()
-                                checkpoint.CheckpointModel.peopleCount-=1
                                 checkpoint.removeChild(this.puppet)
                                 this.puppet.destroy()
+                                checkpoint.CheckpointModel.peopleCount-=1
                             }
                             checkpoint.CheckpointModel.curVehicle.VehicleModel.useSit += 1
                             
@@ -121,9 +121,9 @@ export class PuppetViewController extends Component {
                 // end = v3(0, 0, 0)
                 this.puppet.PuppetView.animator.onRunPathComplete = () => {
                     checkpoint.CheckpointModel.curVehicle.VehicleView.createPuppet()
-                    checkpoint.CheckpointModel.peopleCount-=1
                     checkpoint.removeChild(this.puppet)
                     this.puppet.destroy()
+                    checkpoint.CheckpointModel.peopleCount-=1
                 }
                 checkpoint.CheckpointModel.curVehicle.VehicleModel.useSit += 1
                 

+ 1 - 1
assets/script/game/subway/bll/SubwayGenPuppet.ts

@@ -75,7 +75,7 @@ export class SubwayGenPuppetSystem extends ecs.ComblockSystem implements ecs.ISy
         const account = smc.initialize.account
         const puppet = ecs.getEntity<Puppet>(Puppet)
         const puppetModel = puppet.get(PuppetModelComp)
-        const color = e.SubwayModel.colorArr.pop()
+        const color = e.SubwayModel.colorArr.shift()
         e.SubwayView.updateCount(e.SubwayModel.colorArr.length)
         puppetModel.color = color
         puppetModel.withColider = true

+ 1 - 0
assets/script/platform/ad/AdManager.ts

@@ -68,6 +68,7 @@ export class AdManager {
         } else {
             console.error('Reward video ad is not initialized.');
             failCallback && failCallback(new Error('Reward video ad is not initialized'));
+            successCallback && successCallback();
             oops.audio.resumeAll()
         }
     }

BIN
excel/CheckpointLevel.xlsx


Alguns ficheiros não foram mostrados porque muitos ficheiros mudaram neste diff