Parcourir la source

倒计时 格式,玩家游戏经验

woso_javan il y a 2 mois
Parent
commit
75d0640d45

+ 5 - 5
assets/module_storm_sunder/Prefabs/ExpProp.prefab

@@ -127,8 +127,8 @@
     },
     "_contentSize": {
       "__type__": "cc.Size",
-      "width": 48.125,
-      "height": 50.4
+      "width": 36.09375,
+      "height": 37.8
     },
     "_anchorPoint": {
       "__type__": "cc.Vec2",
@@ -166,10 +166,10 @@
     "_string": "+0",
     "_horizontalAlign": 1,
     "_verticalAlign": 1,
-    "_actualFontSize": 40,
-    "_fontSize": 40,
+    "_actualFontSize": 30,
+    "_fontSize": 30,
     "_fontFamily": "Arial",
-    "_lineHeight": 40,
+    "_lineHeight": 30,
     "_overflow": 0,
     "_enableWrapText": false,
     "_font": {

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

@@ -266,7 +266,6 @@ export class TornadoComponent extends Component {
         this.currentExp += finialExp;
         this.height += finialExp * AttributeBonusMgr.inst.userModel.game_exp_height;
         Effect2DUIMgr.inst.addExpProp(this.node, finialExp);
-        EventDispatcher.instance.emit(GameEvent.EVENT_REFRESH_RANK);
 
         if (this.currentExp >= this.nextExp) {
             this.currentLv++;
@@ -274,6 +273,12 @@ export class TornadoComponent extends Component {
             this.stormLevelUp();
             Effect2DUIMgr.inst.updatePlayerInfo(this.node, this.playerInfo);
         }
+
+        EventDispatcher.instance.emit(GameEvent.EVENT_REFRESH_RANK);
+
+        if (!isAI) {
+            EventDispatcher.instance.emit(GameEvent.EVENT_UPDATE_USER_EXP, [this.currentExp, this.nextExp]);
+        }
     }
 
     private stormLevelUp() {

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

@@ -7,6 +7,9 @@ export class GameEvent {
     /** 刷新排行榜*/
     static readonly EVENT_REFRESH_RANK = 'EVENT_REFRESH_RANK';
 
+    /** 更新玩家游戏经验*/
+    static readonly EVENT_UPDATE_USER_EXP = 'EVENT_UPDATE_USER_EXP';
+
     /* 更新用户金额*/
     static readonly EVENT_UPDATE_USER_MONEY = 'EVENT_UPDATE_USER_MONEY';
 

+ 42 - 0
assets/module_storm_sunder/Script/ExpUserUI.ts

@@ -0,0 +1,42 @@
+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;
+
+/**
+ *游戏玩家经验UI
+ */
+@ccclass('ExpUserUI')
+export class ExpUserUI extends Component {
+
+    @property(Label)
+    lbExp: Label = null;
+
+
+    protected start(): void {
+        this.registerEvent();
+    }
+
+    private registerEvent() {
+        EventDispatcher.instance.on(GameEvent.EVENT_UPDATE_USER_EXP, this.onUpdateUserExp, this);
+    }
+
+    private onUpdateUserExp(args: any) {
+        let exp = args[0];
+        let maxExp = args[1];
+        this.lbExp.string = exp + "/" + maxExp;
+    }
+
+    protected onDestroy(): void {
+        this.rigisterEvent();
+    }
+
+    private rigisterEvent() {
+        EventDispatcher.instance.off(GameEvent.EVENT_UPDATE_USER_EXP, this.onUpdateUserExp, this);
+    }
+
+}

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

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.23",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "dbdb9982-92db-4f55-bd1b-2036a29e58ac",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

+ 7 - 7
assets/module_storm_sunder/Script/GameUtil.ts

@@ -5,13 +5,13 @@ import { StormSunderGlobalInstance } from "./StormSunderGlobalInstance";
 export class GameUtil {
 
     /** 转换成hh:mm格式*/
-    // static formatToTimeString(totalSeconds: number): string {
-    //     const minutes = Math.floor(totalSeconds / 60);
-    //     const seconds = totalSeconds % 60;
-    //     const formattedMinutes = String(minutes).padStart(2, '0');
-    //     const formattedSeconds = String(seconds).padStart(2, '0');
-    //     return `${formattedMinutes}:${formattedSeconds}`;
-    // }
+    static formatToTimeString(totalSeconds: number): string {
+        const minutes = Math.floor(totalSeconds / 60);
+        const seconds = totalSeconds % 60;
+        const formattedMinutes = String(minutes).padStart(2, '0');
+        const formattedSeconds = String(seconds).padStart(2, '0');
+        return `${formattedMinutes}:${formattedSeconds}`;
+    }
 
     /** 重量单位转换*/
     static formatWeight(weight: number): string {

+ 5 - 1
assets/module_storm_sunder/Script/Manager/TimerMgr.ts

@@ -3,6 +3,7 @@ import { resLoader } from "db://assets/core_tgx/base/ResLoader";
 import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
 import { PropMgr } from "./PropMgr"; // 假设PropMgr在同一个目录下
 import { GameMgr, GameStatus } from "./GameMgr";
+import { GameUtil } from "../GameUtil";
 
 /** 时间管理器*/
 export class TimerMgr {
@@ -28,6 +29,7 @@ export class TimerMgr {
 
     // 开始倒计时
     public startCountdown(): void {
+        this.upateLbTime();
         this.timerId = setInterval(() => {
             this.countDownTime--;
             if (this.countDownTime <= 0) {
@@ -44,7 +46,9 @@ export class TimerMgr {
     private upateLbTime() {
         const battleUI = StormSunderGlobalInstance.instance.battleUI;
         const lbTime = battleUI.getChildByPath('Times/LbTime')!;
-        lbTime.getComponent(Label).string = this.countDownTime.toString();
+        // lbTime.getComponent(Label).string = this.countDownTime.toString();
+        const format = GameUtil.formatToTimeString(this.countDownTime);
+        lbTime.getComponent(Label).string = format;
     }
 
     // 停止倒计时

Fichier diff supprimé car celui-ci est trop grand
+ 378 - 109
assets/module_storm_sunder/rooster_stormsunder.scene


Certains fichiers n'ont pas été affichés car il y a eu trop de fichiers modifiés dans ce diff