|
@@ -1,12 +1,13 @@
|
|
/** 2dUI 特效 血条 粒子等管理器*/
|
|
/** 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 { resLoader } from "db://assets/core_tgx/base/ResLoader";
|
|
import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
|
|
import { StormSunderGlobalInstance } from "../StormSunderGlobalInstance";
|
|
import { BloodComponent } from "../Component/BloodComponent";
|
|
import { BloodComponent } from "../Component/BloodComponent";
|
|
import { PlayerInfo, PlayerInfoComponent } from "../Component/PlayerInfoComponent";
|
|
import { PlayerInfo, PlayerInfoComponent } from "../Component/PlayerInfoComponent";
|
|
import { TornadoComponent } from "../Component/TornadoComponent";
|
|
import { TornadoComponent } from "../Component/TornadoComponent";
|
|
import { GameUtil } from "../GameUtil";
|
|
import { GameUtil } from "../GameUtil";
|
|
|
|
+import { ExpPropComponent } from "../Component/ExpPropComponent";
|
|
|
|
|
|
export class Effect2DUIMgr {
|
|
export class Effect2DUIMgr {
|
|
private static _instance: Effect2DUIMgr;
|
|
private static _instance: Effect2DUIMgr;
|
|
@@ -23,6 +24,7 @@ export class Effect2DUIMgr {
|
|
|
|
|
|
private bloodMap: Map<Node, Node> = new Map(); // 存储节点与对应血条的映射
|
|
private bloodMap: Map<Node, Node> = new Map(); // 存储节点与对应血条的映射
|
|
private playerInfoMap: 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) {
|
|
async showBlood(target: Node, hpPercent: number) {
|
|
let bloodNode = this.bloodMap.get(target) as any;
|
|
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);
|
|
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) {
|
|
removeBlood(target: Node) {
|
|
const bloodNode = this.bloodMap.get(target);
|
|
const bloodNode = this.bloodMap.get(target);
|