Procházet zdrojové kódy

加入右半场新增额外敌人

lanyunfei před 23 hodinami
rodič
revize
2916fcf869

+ 2 - 0
assets/script/ECS/components/ComRole.ts

@@ -70,4 +70,6 @@ export class ComRole {
     public fightInfo: FightInfo[] = []
     //掉落
     public drop: idNum
+    // 是否是额外投放敌人
+    public isAddEnemy: boolean
 }

+ 8 - 0
assets/script/ECS/systems/SysMovable.ts

@@ -97,7 +97,11 @@ export class SysMovable extends ECSSystem {
                 }
                 if (offsetLen <= moveLen) {
                     moveLen -= offsetLen
+                    let lastX = comTrans.x
                     comTrans.x = nextPoint.x
+                    if (comRole && comRole.group == Data.game.gFriend && lastX < 100 && comTrans.x > 100) {
+                        world.gameUI.addRightAreaFriendNum(entity)
+                    }
                     comTrans.y = nextPoint.y
                     //同步spine位置
                     if (comSpTransform) {
@@ -111,7 +115,11 @@ export class SysMovable extends ECSSystem {
                     })
                     continue
                 }
+                let lastX = comTrans.x
                 comTrans.x += (moveLen * offsetX) / offsetLen
+                if (comRole && comRole.group == Data.game.gFriend && lastX < 100 && comTrans.x > 100) {
+                    world.gameUI.addRightAreaFriendNum(entity)
+                }
                 comTrans.y += (moveLen * offsetY) / offsetLen
                 //同步spine位置
                 if (comSpTransform) {

+ 5 - 4
assets/script/ECS/systems/SysRoleState.ts

@@ -114,9 +114,10 @@ export class SysRoleState extends ECSSystem {
                         world.gameUI.endGame(isWin)
                         return
                     } else if (
-                        comRole.roleCfg.type == MONSTER_TYPE.boss ||
-                        comRole.roleCfg.type == MONSTER_TYPE.elite ||
-                        comRole.roleCfg.type == MONSTER_TYPE.normal
+                        (comRole.roleCfg.type == MONSTER_TYPE.boss ||
+                            comRole.roleCfg.type == MONSTER_TYPE.elite ||
+                            comRole.roleCfg.type == MONSTER_TYPE.normal) &&
+                        !comRole.isAddEnemy
                     ) {
                         if (comRole.roleCfg.type == MONSTER_TYPE.elite) {
                             world.gameUI.eliteNum += 1
@@ -173,7 +174,7 @@ export class SysRoleState extends ECSSystem {
                         //同步spine死亡
                         comSpineNode?.events.push(new EventDie())
                     }
-                    world.gameUI.handleDie(entity)
+                    if (!comRole.isAddEnemy) world.gameUI.handleDie(entity)
                     //移除buff特效
                     for (let buff of comRole.buffs) {
                         for (let aniEntity of buff.aniEntityArr) {

+ 1 - 1
assets/script/ECS/worlds/WorldCocosView.ts

@@ -312,7 +312,7 @@ export class WorldCocosView extends ECSWorld {
         comRole.lastHP = comRole.HP
         comRole.shieldHP = 0
         comRole.lastShieldHP = 0
-
+        comRole.isAddEnemy = isAddEnemy
         //处理gameUI显示
         if (this.gameUI) {
             let entities = this.gameUI.roleEntityMap.get(roleCfg.ID)

+ 47 - 8
assets/script/ui/GameUI.ts

@@ -239,6 +239,8 @@ export default class GameUI extends BaseUI {
     private timeRolesPos: number[]
     private timeRolesDrop: idNum[]
     private createEnemyNum: number
+    private addEnemyArr: boolean[]
+    private rightAreaFriend: number[] = []
 
     protected onLoad() {
         this.skillArea = cc.find('skillArea', this.node)
@@ -295,6 +297,7 @@ export default class GameUI extends BaseUI {
         this.skillPop.active = false
         this.createEnemyNum = 0
         this.curStage = Data.game.stageID
+        this.rightAreaFriend.length = 0
         ccUtils.setLabel('0', this.goods, 'lb')
         let cfg = this.getStageInfoCfg()
         this.stageInfo = cfg
@@ -669,7 +672,7 @@ export default class GameUI extends BaseUI {
     showGameResult(result: IGameResult) {
         this.scheduleOnce(() => {
             Mgr.ui.show(UI.GameResultUI, result)
-        }, 1)
+        }, 0.5)
     }
 
     async getGameResSync(url, type) {
@@ -763,6 +766,16 @@ export default class GameUI extends BaseUI {
         return cfg
     }
 
+    getRolePos(pos: number) {
+        if (pos == 0) {
+            return Math.randomRangeInt(1, 19)
+        } else if (pos == 100) {
+            return Math.randomRangeInt(101, 109)
+        } else {
+            return pos
+        }
+    }
+
     startStageGame() {
         let cfg = this.getRoundCfg()
         if (this.curStage > 0 && cfg) {
@@ -985,13 +998,7 @@ export default class GameUI extends BaseUI {
                 for (let k = 0; k < tmpRoles.length; k++) {
                     let cfgPos = this.curRoundCfg.rolesPos[i][k]
                     for (let j = 0; j < this.curRoundCfg.rolesTime[i][k]; j++) {
-                        let pos = cfgPos
-                        if (cfgPos == 0) {
-                            pos = Math.randomRangeInt(1, 19)
-                        }
-                        if (cfgPos == 100) {
-                            pos = Math.randomRangeInt(101, 109)
-                        }
+                        let pos = this.getRolePos(cfgPos)
                         tmpObj.push({
                             id: tmpRoles[k],
                             pos,
@@ -1016,6 +1023,9 @@ export default class GameUI extends BaseUI {
         }
 
         this.roundNextRoleTime = this.timeRolesTime[this.curRoundCreateIndex]
+        if ('additional' in this.curRoundCfg) {
+            this.addEnemyArr = new Array(this.curRoundCfg.additional.map(v => v).length).fill(false)
+        }
     }
 
     startNextSmallRound() {
@@ -1473,6 +1483,11 @@ export default class GameUI extends BaseUI {
             let comTransform = this.world.getComponent(entity, ComTransform)
             this.dropClickGoods(cc.v3(comTransform.x, comTransform.y, 0), comRole.drop)
         }
+        //移除右半场已经死亡的友军
+        if (comRole.group == Data.game.gFriend) {
+            let inRightIndex = this.rightAreaFriend.indexOf(entity)
+            if (inRightIndex >= 0) this.rightAreaFriend.splice(inRightIndex, 1)
+        }
     }
 
     initGameSpeed() {
@@ -1596,6 +1611,30 @@ export default class GameUI extends BaseUI {
         this.bossHPNode.active = false
     }
 
+    //我方右半区友军大于一定数量增加刷怪
+    addRightAreaFriendNum(entity) {
+        //处理下容错,刚好这一帧死亡,下一次推入新的友军可以过滤掉
+        this.rightAreaFriend = this.rightAreaFriend.filter(v => !this.world.isDie(v))
+        this.rightAreaFriend.push(entity)
+        if ('extraRoles' in this.curRoundCfg) {
+            for (let i = 0; i < this.addEnemyArr.length; i++) {
+                if (!this.addEnemyArr[i] && this.rightAreaFriend.length >= this.curRoundCfg.additional[i]) {
+                    for (let j = 0; j < this.curRoundCfg.addNum[i]; j++) {
+                        this.world.createRoleEntity(
+                            this.getRoleCfgByCfgID(this.curRoundCfg.extraRoles[i]),
+                            true,
+                            this.getRolePos(this.curRoundCfg.position[i]),
+                            null,
+                            null,
+                            true,
+                        )
+                    }
+                    this.addEnemyArr[i] = true
+                }
+            }
+        }
+    }
+
     onClickAdAddCost() {
         Mgr.platform.playVideoAD(AD_ID.energy, () => {
             this.adCost.active = false