woso_javan 2 mesi fa
parent
commit
7fc84f2d50

+ 289 - 0
assets/module_storm_sunder/Prefabs/ExpProp.prefab

@@ -0,0 +1,289 @@
+[
+  {
+    "__type__": "cc.Prefab",
+    "_name": "ExpProp",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_native": "",
+    "data": {
+      "__id__": 1
+    },
+    "optimizationPolicy": 0,
+    "persistent": false
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "ExpProp",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": null,
+    "_children": [
+      {
+        "__id__": 2
+      }
+    ],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 8
+      },
+      {
+        "__id__": 10
+      }
+    ],
+    "_prefab": {
+      "__id__": 12
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.Node",
+    "_name": "Label",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "_parent": {
+      "__id__": 1
+    },
+    "_children": [],
+    "_active": true,
+    "_components": [
+      {
+        "__id__": 3
+      },
+      {
+        "__id__": 5
+      }
+    ],
+    "_prefab": {
+      "__id__": 7
+    },
+    "_lpos": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_lrot": {
+      "__type__": "cc.Quat",
+      "x": 0,
+      "y": 0,
+      "z": 0,
+      "w": 1
+    },
+    "_lscale": {
+      "__type__": "cc.Vec3",
+      "x": 1,
+      "y": 1,
+      "z": 1
+    },
+    "_mobility": 0,
+    "_layer": 33554432,
+    "_euler": {
+      "__type__": "cc.Vec3",
+      "x": 0,
+      "y": 0,
+      "z": 0
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 4
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 48.125,
+      "height": 50.4
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "a0PiNRmOpMAZTCyFpS3pni"
+  },
+  {
+    "__type__": "cc.Label",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 2
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 6
+    },
+    "_customMaterial": null,
+    "_srcBlendFactor": 2,
+    "_dstBlendFactor": 4,
+    "_color": {
+      "__type__": "cc.Color",
+      "r": 255,
+      "g": 255,
+      "b": 255,
+      "a": 255
+    },
+    "_string": "+0",
+    "_horizontalAlign": 1,
+    "_verticalAlign": 1,
+    "_actualFontSize": 40,
+    "_fontSize": 40,
+    "_fontFamily": "Arial",
+    "_lineHeight": 40,
+    "_overflow": 0,
+    "_enableWrapText": false,
+    "_font": {
+      "__uuid__": "23a47957-4ba6-41f7-999f-a5fbf8a48aed",
+      "__expectedType__": "cc.TTFFont"
+    },
+    "_isSystemFontUsed": false,
+    "_spacingX": 0,
+    "_isItalic": false,
+    "_isBold": false,
+    "_isUnderline": false,
+    "_underlineHeight": 2,
+    "_cacheMode": 0,
+    "_enableOutline": false,
+    "_outlineColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_outlineWidth": 2,
+    "_enableShadow": false,
+    "_shadowColor": {
+      "__type__": "cc.Color",
+      "r": 0,
+      "g": 0,
+      "b": 0,
+      "a": 255
+    },
+    "_shadowOffset": {
+      "__type__": "cc.Vec2",
+      "x": 2,
+      "y": 2
+    },
+    "_shadowBlur": 2,
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "29cqZQQW9Fv58zY/9z96Yw"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "22pEyK2qxD5Yd5oj78R1kW",
+    "instance": null,
+    "targetOverrides": null,
+    "nestedPrefabInstanceRoots": null
+  },
+  {
+    "__type__": "cc.UITransform",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 9
+    },
+    "_contentSize": {
+      "__type__": "cc.Size",
+      "width": 100,
+      "height": 100
+    },
+    "_anchorPoint": {
+      "__type__": "cc.Vec2",
+      "x": 0.5,
+      "y": 0.5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "2chk2UNTRLhb+NjhfWPMwt"
+  },
+  {
+    "__type__": "d1955jzh+tMW6GdzvRm/xA0",
+    "_name": "",
+    "_objFlags": 0,
+    "__editorExtras__": {},
+    "node": {
+      "__id__": 1
+    },
+    "_enabled": true,
+    "__prefab": {
+      "__id__": 11
+    },
+    "lb": {
+      "__id__": 5
+    },
+    "_id": ""
+  },
+  {
+    "__type__": "cc.CompPrefabInfo",
+    "fileId": "01Ti6PWOhPYZjOXPdaEcZJ"
+  },
+  {
+    "__type__": "cc.PrefabInfo",
+    "root": {
+      "__id__": 1
+    },
+    "asset": {
+      "__id__": 0
+    },
+    "fileId": "c46/YsCPVOJYA4mWEpNYRx",
+    "instance": null,
+    "targetOverrides": null
+  }
+]

+ 13 - 0
assets/module_storm_sunder/Prefabs/ExpProp.prefab.meta

@@ -0,0 +1,13 @@
+{
+  "ver": "1.1.50",
+  "importer": "prefab",
+  "imported": true,
+  "uuid": "4d8538c7-ec73-4bb0-ad16-7ebfea1ea28c",
+  "files": [
+    ".json"
+  ],
+  "subMetas": {},
+  "userData": {
+    "syncNodeName": "ExpProp"
+  }
+}

+ 36 - 0
assets/module_storm_sunder/Script/Component/ExpPropComponent.ts

@@ -0,0 +1,36 @@
+import { _decorator, Component, isValid, Label, Node, tween, Tween, Vec3 } from 'cc';
+const { ccclass, property } = _decorator;
+
+@ccclass('ExpPropComponent')
+export class ExpPropComponent extends Component {
+
+    @property(Label)
+    lb: Label = null;
+
+    start() {
+
+    }
+
+    //显示经验动画 
+    showExp(exp: number) {
+        this.lb.string = `+${exp}`;
+        this.lb.node.active = true;
+
+        Tween.stopAllByTarget(this.node);
+        //当前节点位置 向上移动 然后销毁
+        const worldPos = this.node.worldPosition.clone();
+        tween(this.node)
+            .to(0.5, { worldPosition: new Vec3(worldPos.x, worldPos.y + 100, worldPos.z) }, { easing: 'quadOut' })
+            .call(() => {
+                this.node.removeFromParent();
+                this.node.destroy();
+            })
+            .start();
+    }
+
+    update(deltaTime: number) {
+
+    }
+}
+
+

+ 9 - 0
assets/module_storm_sunder/Script/Component/ExpPropComponent.ts.meta

@@ -0,0 +1,9 @@
+{
+  "ver": "4.0.23",
+  "importer": "typescript",
+  "imported": true,
+  "uuid": "d19558f3-87eb-4c5b-a19d-cef466ff1034",
+  "files": [],
+  "subMetas": {},
+  "userData": {}
+}

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

@@ -249,6 +249,7 @@ export class TornadoComponent extends Component {
         const finialExp = AttributeBonusMgr.inst.getExpBonus(objExp, isAI);
         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) {

+ 25 - 3
assets/module_storm_sunder/Script/Manager/Effect2DUIMgr.ts

@@ -1,12 +1,13 @@
 /** 2dUI 特效 血条 粒子等管理器*/
 
-import { assetManager, instantiate, Prefab, Node, UITransform, Vec3, Vec2, view } from "cc";
+import { assetManager, instantiate, Prefab, Node, UITransform, Vec3, Vec2, view, Game } from "cc";
 import { resLoader } from "db://assets/core_tgx/base/ResLoader";
 import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
 import { BloodComponent } from "../Component/BloodComponent";
 import { PlayerInfo, PlayerInfoComponent } from "../Component/PlayerInfoComponent";
 import { TornadoComponent } from "../Component/TornadoComponent";
 import { GameUtil } from "../GameUtil";
+import { ExpPropComponent } from "../Component/ExpPropComponent";
 
 export class Effect2DUIMgr {
     private static _instance: Effect2DUIMgr;
@@ -23,6 +24,7 @@ export class Effect2DUIMgr {
 
     private bloodMap: Map<Node, Node> = new Map(); // 存储节点与对应血条的映射
     private playerInfoMap: Map<Node, Node> = new Map(); // 存储节点与玩家信息的映射
+    private expInfoMap: Map<Node, Node> = new Map(); // 存储节点与经验条信息的映射
 
     async showBlood(target: Node, hpPercent: number) {
         let bloodNode = this.bloodMap.get(target) as any;
@@ -92,9 +94,9 @@ export class Effect2DUIMgr {
         }
     }
 
-    private setPlayerInfoPosition(infoNode: Node, target: Node, parentUI: Node) {
+    private setPlayerInfoPosition(infoNode: Node, target: Node, parentUI: Node, distance = 150) {
         const uiPos = GameUtil.worldToScreenLocal(target, parentUI);
-        infoNode.setPosition(uiPos.x, uiPos.y + 150);
+        infoNode.setPosition(uiPos.x, uiPos.y + distance);
     }
 
     //更新对应玩家信息
@@ -108,6 +110,26 @@ export class Effect2DUIMgr {
         }
     }
 
+    //目标节点添加经验渐隐显示
+    async addExpProp(target: Node, exp: number) {
+        const expPrefab = await resLoader.loadAsync(
+            resLoader.gameBundleName,
+            "Prefabs/ExpProp",
+            Prefab
+        );
+
+        if (expPrefab) {
+            const expNode = instantiate(expPrefab);
+            const effectUI = StormSunderGlobalInstance.instance.effectUI;
+            expNode.parent = effectUI;
+
+            const targetLocal = GameUtil.worldToScreenLocal(target, effectUI);
+            this.setPlayerInfoPosition(expNode, target, effectUI, 0);
+            expNode.getComponent(ExpPropComponent).showExp(exp);
+            // console.log("targetLocal:", targetLocal);
+        }
+    }
+
     // 清理血条
     removeBlood(target: Node) {
         const bloodNode = this.bloodMap.get(target);

+ 1 - 1
assets/module_storm_sunder/Script/RankUI.ts

@@ -47,7 +47,7 @@ export class RankUI extends Component {
 
     private onRefreshRank() {
         const rankList = PlayerMgr.inst.getRanking();
-        console.log('rankList:', rankList);
+        // console.log('rankList:', rankList);
 
         // Hide all rank nodes first
         this.rank1.active = false;

+ 1 - 0
assets/start/Start.ts

@@ -20,6 +20,7 @@ const _preloadRes = [
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/Map', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/Blood', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/PlayerInfo', type: 'prefab' },
+    { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/ExpProp', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Prefabs/Levels/lvl_1', type: 'prefab' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/bgm_1.mp3', type: 'audio' },
     { bundle: ModuleDef.MODULE_STORM_SUNDER, url: 'Audio/bgm_2.mp3', type: 'audio' },