woso_javan před 2 měsíci
rodič
revize
cecad6f735

+ 2 - 1
assets/module_storm_sunder/Script/Component/TornadoAIComponent.ts

@@ -48,7 +48,8 @@ export class TornadoAIComponent extends TornadoComponent {
         //text:名称 range:检测半径 move_juge:移动概率 move_time:移动时间 escape_time:逃跑时间 pursuit_1:追击玩家概率 pursuit_2:追击AI概率 pursuit_time:追击时间
         const { text, range, move_judge, move_time, escape_time, pursuit_1, pursuit_2, pursuit_time } = aiConfig.data;
         this.playerInfo.nickName = text;
-        this.currentLv = 3;
+        this.nickName = text;
+        this.currentLv = 1;
         this.playerInfo.level = this.currentLv;
 
         this.moveDuration = Math.floor(move_time[0] + Math.random() * (move_time[1] - move_time[0] + 1));

+ 6 - 2
assets/module_storm_sunder/Script/Component/TornadoComponent.ts

@@ -30,7 +30,8 @@ export class TornadoComponent extends Component {
     attack: number = 20;
     speed: number = 50;
     currentExp: number = 0;
-    currentLv: number = 1;
+    height: number = 0; //龙卷风高度
+    currentLv: number = 2;
     giveExp: number = 10; //被吃掉给予经验
     nextExp: number = 100;
     nickName: string = null;
@@ -77,6 +78,7 @@ export class TornadoComponent extends Component {
         this.attack = this.attributeBonusMgr.getStormSunderAttack(this.currentLv);
         this.speed = this.attributeBonusMgr.getStormSunderSpeed(this.currentLv);
         this.nickName = userModel.nickName;
+        this.height = userModel.game_tornado_base_height;
 
         console.log(`玩家的攻击力 :${this.attack}} 速度:${this.speed}`)
 
@@ -99,7 +101,7 @@ export class TornadoComponent extends Component {
     }
 
     protected setPositionByObstacle(event: ITriggerEvent, cb?: Function) {
-        console.log('离开碰撞物 isColliding:', this.isColliding);
+        // console.log('离开碰撞物 isColliding:', this.isColliding);
         if (this.isColliding) return; // 防止重复触发
 
         let _originalPosition = this.node.position.clone();
@@ -246,6 +248,8 @@ export class TornadoComponent extends Component {
         objExp = AttributeBonusMgr.inst.getStormSunderExp(objExp);
         const finialExp = AttributeBonusMgr.inst.getExpBonus(objExp, isAI);
         this.currentExp += finialExp;
+        this.height += finialExp * AttributeBonusMgr.inst.userModel.game_exp_height;
+        EventDispatcher.instance.emit(GameEvent.EVENT_REFRESH_RANK);
 
         if (this.currentExp >= this.nextExp) {
             this.currentLv++;

+ 3 - 0
assets/module_storm_sunder/Script/Enum/GameEvent.ts

@@ -4,6 +4,9 @@ export class GameEvent {
     /** 游戏开始*/
     static readonly EVENT_GAME_START = 'EVENT_GAME_START';
 
+    /** 刷新排行榜*/
+    static readonly EVENT_REFRESH_RANK = 'EVENT_REFRESH_RANK';
+
     /* 更新用户金额*/
     static readonly EVENT_UPDATE_USER_MONEY = 'EVENT_UPDATE_USER_MONEY';
 

+ 49 - 0
assets/module_storm_sunder/Script/Manager/PlayerMgr.ts

@@ -137,5 +137,54 @@ export class PlayerMgr {
         this.aiIndex = 0;
     }
 
+    /** 排行榜*/
+    public getRanking() {
+        const playersUI = StormSunderGlobalInstance.instance.players!;
+
+        // Get all players and their heights
+        const rankings = playersUI.children.map((node, index) => {
+            const tornadoComp = node.getComponent(TornadoComponent);
+            const isPlayer = !node.getComponent(TornadoAIComponent);
+            return {
+                index,
+                height: tornadoComp ? tornadoComp.height : 0,
+                nickName: tornadoComp ? tornadoComp.nickName : '',
+                isPlayer
+            };
+        });
+
+        // Sort by height in descending order
+        rankings.sort((a, b) => b.height - a.height);
+
+        // Add rank information
+        const rankedPlayers = rankings.map((player, rank) => ({
+            rank: rank + 1,
+            height: player.height,
+            nickName: player.nickName,
+            isPlayer: player.isPlayer
+        }));
+
+        if (rankings.length < 3) {
+            // If less than 3 players, return all rankings
+            return rankedPlayers;
+        }
+
+        // Find player rank if exists
+        const playerRank = rankedPlayers.find(p => p.isPlayer);
+
+        if (!playerRank) {
+            // No player found, return top 3
+            return rankedPlayers.slice(0, 3);
+        }
+
+        if (playerRank.rank <= 3) {
+            // Player is in top 3, return top 3
+            return rankedPlayers.slice(0, 3);
+        }
+
+        // Player is not in top 3, return top 3 + player rank
+        return [...rankedPlayers.slice(0, 3), playerRank];
+    }
+
 }
 

+ 87 - 0
assets/module_storm_sunder/Script/RankUI.ts

@@ -0,0 +1,87 @@
+import { Button, Component, Label, Node, NodeEventType, _decorator, find } from 'cc';
+import { AttributeBonusMgr } from './Manager/AttributeBonusMgr';
+import { EventDispatcher } from '../../core_tgx/easy_ui_framework/EventDispatcher';
+import { GameEvent } from './Enum/GameEvent';
+import { GameUtil } from './GameUtil';
+import { PlayerMgr } from './Manager/PlayerMgr';
+
+const { ccclass, property } = _decorator;
+
+/**
+ *排行面板
+ */
+@ccclass('RankUI')
+export class RankUI extends Component {
+
+    rank1: Node = null;
+    rank2: Node = null;
+    rank3: Node = null;
+    rank4: Node = null;
+
+    protected async onLoad() {
+        this.rank1 = this.node.getChildByName("Rank1");
+        this.rank2 = this.node.getChildByName("Rank2");
+        this.rank3 = this.node.getChildByName("Rank3");
+        this.rank4 = this.node.getChildByName("Rank4");
+
+        await GameUtil.delay(0.2);
+        this.initUI();
+        this.rigisterEvent();
+    }
+
+    private initUI() {
+        this.rank1.active = true;
+        this.rank2.active = false;
+        this.rank3.active = false;
+        this.rank4.active = false;
+
+        const lbName = this.rank1.getChildByName("LbName").getComponent(Label);
+        console.log('AttributeBonusMgr.inst.userModel.nickName:', AttributeBonusMgr.inst.userModel.nickName);
+        lbName.string = `${AttributeBonusMgr.inst.userModel.nickName}`;
+        const lbHeight = this.rank1.getChildByName("LbHeight").getComponent(Label);
+        lbHeight.string = `${AttributeBonusMgr.inst.userModel.game_tornado_base_height} m`;
+    }
+
+    protected start(): void {
+    }
+
+    private onRefreshRank() {
+        const rankList = PlayerMgr.inst.getRanking();
+        console.log('rankList:', rankList);
+
+        // Hide all rank nodes first
+        this.rank1.active = false;
+        this.rank2.active = false;
+        this.rank3.active = false;
+        this.rank4.active = false;
+
+        // Display top 3 rankings
+        for (let i = 0; i < Math.min(3, rankList.length); i++) {
+            const rankNode = this[`rank${i + 1}`];
+            const playerData = rankList[i];
+
+            rankNode.active = true;
+            rankNode.getChildByName("LbName").getComponent(Label).string = playerData.nickName;
+            rankNode.getChildByName("LbHeight").getComponent(Label).string = `${playerData.height} m`;
+        }
+
+        // Check if current player is not in top 3 and there are more than 3 players
+        if (rankList.length > 3) {
+            const currentPlayerIndex = rankList.findIndex(player =>
+                player.nickName === AttributeBonusMgr.inst.userModel.nickName
+            );
+
+            if (currentPlayerIndex >= 3) {
+                this.rank4.active = true;
+                const playerData = rankList[currentPlayerIndex];
+                this.rank4.getChildByName("LbName").getComponent(Label).string = playerData.nickName;
+                this.rank4.getChildByName("LbHeight").getComponent(Label).string = `${playerData.height} m`;
+            }
+        }
+    }
+
+    private rigisterEvent() {
+        EventDispatcher.instance.on(GameEvent.EVENT_REFRESH_RANK, this.onRefreshRank, this);
+    }
+
+}

+ 9 - 0
assets/module_storm_sunder/Script/RankUI.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.23",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "0e759108-94a3-411a-ab4f-d322a03ea489",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 2205 - 144
assets/module_storm_sunder/rooster_stormsunder.scene


Některé soubory nejsou zobrazeny, neboť je v těchto rozdílových datech změněno mnoho souborů