|
@@ -1,20 +1,22 @@
|
|
|
using CommonAI.ZoneClient;
|
|
|
+using FairyGUI;
|
|
|
using Sirenix.Utilities;
|
|
|
using UnityEngine;
|
|
|
|
|
|
namespace ET.Client
|
|
|
{
|
|
|
[Event(SceneType.Current)]
|
|
|
+ [FriendOfAttribute(typeof(ET.Client.UnitRenderComponet))]
|
|
|
public class OnNewZoneObjectHandler : AEvent<EventType.OnNewZoneObject>
|
|
|
{
|
|
|
protected override async ETTask Run(Scene scene, EventType.OnNewZoneObject args)
|
|
|
{
|
|
|
var obj = UnitMgr.Instance.GetUnit(args.ObjectId);
|
|
|
- if(obj is BattleUnit)
|
|
|
+ if (obj is BattleUnit)
|
|
|
{
|
|
|
await CreatUnitModel(obj as BattleUnit);
|
|
|
}
|
|
|
- else if(obj is BattleSpell)
|
|
|
+ else if (obj is BattleSpell)
|
|
|
{
|
|
|
//TODO: 性能有问题时,可以减少法术展示
|
|
|
await CreateSpellModel(obj as BattleSpell);
|
|
@@ -29,27 +31,27 @@ namespace ET.Client
|
|
|
private async ETTask CreatUnitModel(BattleUnit unit)
|
|
|
{
|
|
|
var zu = unit.ZUnit;
|
|
|
- var go = await GameObjectPool.Instance.Acquire($"Unit_{zu.Info.FileName}");
|
|
|
- go.SetActive(true);
|
|
|
if (!UnitMgr.Instance.HasUnit(zu.ObjectID))
|
|
|
{
|
|
|
//还没显示就已挂掉的单位,走好
|
|
|
Log.Debug($"ignore dead unit: {zu}@{zu.ObjectID}");
|
|
|
return;
|
|
|
}
|
|
|
- ModelViewComponent.Instance.AddChildWithId<UnitRenderComponet, GameObject>(unit.Id, go, true);
|
|
|
|
|
|
+ var go = await GameObjectPool.Instance.Acquire($"Unit_{zu.Info.FileName}");
|
|
|
+ go.SetActive(true);
|
|
|
go.transform.parent = GlobalViewComponent.Instance.Unit;
|
|
|
vecTemp.Set(zu.X, zu.Y, zu.Z);
|
|
|
go.transform.position = RenderUtils.UnityPosFromBattle(vecTemp);
|
|
|
go.transform.rotation = RenderUtils.UnityRotationFromBattle(zu.Direction);
|
|
|
|
|
|
+ var render = ModelViewComponent.Instance.AddChildWithId<UnitRenderComponet, GameObject>(unit.Id, go, true);
|
|
|
+ CreateHeadbar(render, zu).Coroutine();
|
|
|
if (unit is BattleActor)
|
|
|
{
|
|
|
CameraMgr.FollowMe(go.transform.position);
|
|
|
}
|
|
|
- Log.Debug($"unitRender({zu.ObjectID}),pos({zu.X},{zu.Y},{zu.Z}) ok.");
|
|
|
-
|
|
|
+ //Log.Debug($"unitRender({zu.ObjectID}),pos({zu.X},{zu.Y},{zu.Z}) ok.");
|
|
|
//TODO: 同步ZoneUnit status
|
|
|
}
|
|
|
|
|
@@ -57,7 +59,7 @@ namespace ET.Client
|
|
|
{
|
|
|
var zs = spell.ZoneObject as ZoneSpell;
|
|
|
var res = zs.Info.FileName;
|
|
|
- if(res.IsNullOrWhitespace())
|
|
|
+ if (res.IsNullOrWhitespace())
|
|
|
{
|
|
|
Log.Debug($"spell({zs.Info.ID}) not config fileName");
|
|
|
return;
|
|
@@ -87,5 +89,21 @@ namespace ET.Client
|
|
|
//TODO:特效不支持播放动画
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private async ETTask CreateHeadbar(UnitRenderComponet render, ZoneUnit zu)
|
|
|
+ {
|
|
|
+ var view = await GameObjectPool.Instance.AcquireHeadBar();
|
|
|
+ view.visible = true;
|
|
|
+
|
|
|
+ render.HeadBar = view;
|
|
|
+ var name = view.GetChild("text_name");
|
|
|
+ var progresshp = view.GetChild("bar_hp") as GProgressBar;
|
|
|
+ progresshp.max = 100;
|
|
|
+ progresshp.min = 0;
|
|
|
+
|
|
|
+ name.text = render.GameObject.name;
|
|
|
+ progresshp.value = zu.HP * 100 / zu.MaxHP;
|
|
|
+ render.SyncHeadBarPos();
|
|
|
+ }
|
|
|
}
|
|
|
}
|