|
|
|
@ -20,10 +20,14 @@ namespace Game
|
|
|
|
private readonly Dictionary<int, List<UIPoolItem<ViewHitBuff>>> _hitBuffDict =
|
|
|
|
private readonly Dictionary<int, List<UIPoolItem<ViewHitBuff>>> _hitBuffDict =
|
|
|
|
new Dictionary<int, List<UIPoolItem<ViewHitBuff>>>();
|
|
|
|
new Dictionary<int, List<UIPoolItem<ViewHitBuff>>>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private readonly Dictionary<int, UIPoolItem<ViewInteract>> _interactDict =
|
|
|
|
|
|
|
|
new Dictionary<int, UIPoolItem<ViewInteract>>();
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnCreate()
|
|
|
|
protected override void OnCreate()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
CreateUI(false);
|
|
|
|
CreateUI(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnOpen()
|
|
|
|
protected override void OnOpen()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//打开时创建所有非主角实体的血条
|
|
|
|
//打开时创建所有非主角实体的血条
|
|
|
|
@ -37,6 +41,7 @@ namespace Game
|
|
|
|
|
|
|
|
|
|
|
|
SetHpBar(entity.ID(), true);
|
|
|
|
SetHpBar(entity.ID(), true);
|
|
|
|
SetHitNum(entity.ID(), true);
|
|
|
|
SetHitNum(entity.ID(), true);
|
|
|
|
|
|
|
|
SetInteract(entity.ID(), true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EventManager.Instance.AddEvent<PEntityAlive>(EEvent.EntityAlive, OnEntityAlive);
|
|
|
|
EventManager.Instance.AddEvent<PEntityAlive>(EEvent.EntityAlive, OnEntityAlive);
|
|
|
|
@ -93,7 +98,7 @@ namespace Game
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var headBarItem = kvp.Value;
|
|
|
|
var headBarItem = kvp.Value;
|
|
|
|
var posScreen = GetScreenPos(Util.EntityViewPos(entity));
|
|
|
|
var posScreen = GetScreenPos(Util.EntityViewPos(entity));
|
|
|
|
headBarItem.MComponent.SetPosition(posScreen.x, posScreen.y - 80, posScreen.z);
|
|
|
|
headBarItem.Component.SetPosition(posScreen.x, posScreen.y - 80, posScreen.z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -106,7 +111,7 @@ namespace Game
|
|
|
|
var posScreen = GetScreenPos(Util.EntityViewPos(entity));
|
|
|
|
var posScreen = GetScreenPos(Util.EntityViewPos(entity));
|
|
|
|
foreach (var item in hitNumList)
|
|
|
|
foreach (var item in hitNumList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.MComponent.SetPosition(posScreen.x, posScreen.y, posScreen.z);
|
|
|
|
item.Component.SetPosition(posScreen.x, posScreen.y, posScreen.z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -120,10 +125,20 @@ namespace Game
|
|
|
|
var posScreen = GetScreenPos(Util.EntityViewPos(entity));
|
|
|
|
var posScreen = GetScreenPos(Util.EntityViewPos(entity));
|
|
|
|
foreach (var item in hitNumList)
|
|
|
|
foreach (var item in hitNumList)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.MComponent.SetPosition(posScreen.x, posScreen.y - 40, posScreen.z);
|
|
|
|
item.Component.SetPosition(posScreen.x, posScreen.y - 40, posScreen.z);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
foreach (var kvp in _interactDict)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var entity = Util.GetEntity(kvp.Key);
|
|
|
|
|
|
|
|
if (entity != null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var interactItem = kvp.Value;
|
|
|
|
|
|
|
|
var posScreen = GetScreenPos(Util.EntityViewPos(entity));
|
|
|
|
|
|
|
|
interactItem.Component.SetPosition(posScreen.x, posScreen.y - 80, posScreen.z);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
@ -157,7 +172,7 @@ namespace Game
|
|
|
|
if (hp.DmgShowTime <= 0)
|
|
|
|
if (hp.DmgShowTime <= 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hp.DmgShowTime = 0;
|
|
|
|
hp.DmgShowTime = 0;
|
|
|
|
var lastItem = hitNumList[hitNumList.Count - 1].MComponent as ViewHitNum;
|
|
|
|
var lastItem = hitNumList[hitNumList.Count - 1].Component as ViewHitNum;
|
|
|
|
lastItem.m_step2.Play();
|
|
|
|
lastItem.m_step2.Play();
|
|
|
|
if (GameRandom.Roll(0.5f))
|
|
|
|
if (GameRandom.Roll(0.5f))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@ -178,7 +193,7 @@ namespace Game
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var item = hitNumList[i];
|
|
|
|
var item = hitNumList[i];
|
|
|
|
var hitInfo = hitNumList[i].MComponent as ViewHitNum;
|
|
|
|
var hitInfo = hitNumList[i].Component as ViewHitNum;
|
|
|
|
if (!hitInfo.m_step2.playing)
|
|
|
|
if (!hitInfo.m_step2.playing)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
item.Destroy();
|
|
|
|
item.Destroy();
|
|
|
|
@ -212,7 +227,7 @@ namespace Game
|
|
|
|
for (int i = hitNumList.Count - 1; i >= 0; i--)
|
|
|
|
for (int i = hitNumList.Count - 1; i >= 0; i--)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var item = hitNumList[i];
|
|
|
|
var item = hitNumList[i];
|
|
|
|
var hitInfo = hitNumList[i].MComponent as ViewHitBuff;
|
|
|
|
var hitInfo = hitNumList[i].Component as ViewHitBuff;
|
|
|
|
if (entity.pause.IsPause)
|
|
|
|
if (entity.pause.IsPause)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hitInfo.m_step1.SetPaused(true);
|
|
|
|
hitInfo.m_step1.SetPaused(true);
|
|
|
|
@ -239,6 +254,43 @@ namespace Game
|
|
|
|
|
|
|
|
|
|
|
|
SetHpBar(param.Entity, param.IsAlive);
|
|
|
|
SetHpBar(param.Entity, param.IsAlive);
|
|
|
|
SetHitNum(param.Entity, param.IsAlive);
|
|
|
|
SetHitNum(param.Entity, param.IsAlive);
|
|
|
|
|
|
|
|
SetInteract(param.Entity, param.IsAlive);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void SetInteract(int entityID, bool isAlive = true)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var entity = Util.GetEntity(entityID);
|
|
|
|
|
|
|
|
if (!entity.hasInteract)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isAlive)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!_interactDict.ContainsKey(entityID))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var interactBar = UIManager.Instance.Creator.CreateUIItem<ViewInteract>(ViewInteract.URL);
|
|
|
|
|
|
|
|
_interactDict[entityID] = interactBar;
|
|
|
|
|
|
|
|
var interactComp = interactBar.Component;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var interact = entity.interact;
|
|
|
|
|
|
|
|
BindData(interact.IsActive,
|
|
|
|
|
|
|
|
(_, now) => { interactComp.m_showInteract.selectedIndex = now ? 1 : 0; });
|
|
|
|
|
|
|
|
BindData(interact.IsTarget,
|
|
|
|
|
|
|
|
(_, now) => { interactComp.m_isTarget.selectedIndex = now ? 1 : 0; });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (_interactDict.ContainsKey(entityID))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
_interactDict[entityID].Destroy();
|
|
|
|
|
|
|
|
_interactDict.Remove(entityID);
|
|
|
|
|
|
|
|
var interact = entity.interact;
|
|
|
|
|
|
|
|
UnbindData(interact.IsActive);
|
|
|
|
|
|
|
|
UnbindData(interact.IsTarget);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void SetHitNum(int entityID, bool isAlive = true)
|
|
|
|
private void SetHitNum(int entityID, bool isAlive = true)
|
|
|
|
@ -274,9 +326,8 @@ namespace Game
|
|
|
|
private void SetHpBar(int entityID, bool isAlive = true)
|
|
|
|
private void SetHpBar(int entityID, bool isAlive = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var entity = Util.GetEntity(entityID);
|
|
|
|
var entity = Util.GetEntity(entityID);
|
|
|
|
if (entity.IsMaster())
|
|
|
|
if (!entity.hasHp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//排除主角
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -287,7 +338,7 @@ namespace Game
|
|
|
|
//创建血条UI
|
|
|
|
//创建血条UI
|
|
|
|
var hpBar = UIManager.Instance.Creator.CreateUIItem<Viewc_blood>(Viewc_blood.URL);
|
|
|
|
var hpBar = UIManager.Instance.Creator.CreateUIItem<Viewc_blood>(Viewc_blood.URL);
|
|
|
|
_hpBarDict[entityID] = hpBar;
|
|
|
|
_hpBarDict[entityID] = hpBar;
|
|
|
|
var hpComp = hpBar.MComponent;
|
|
|
|
var hpComp = hpBar.Component;
|
|
|
|
if (entity.hasHp)
|
|
|
|
if (entity.hasHp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
var hp = entity.hp;
|
|
|
|
var hp = entity.hp;
|
|
|
|
@ -352,14 +403,6 @@ namespace Game
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.hasInteract)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var interact = entity.interact;
|
|
|
|
|
|
|
|
BindData(interact.IsActive, (_, now) => { hpComp.m_showInteract.selectedIndex = now ? 1 : 0; });
|
|
|
|
|
|
|
|
BindData(interact.IsTarget,
|
|
|
|
|
|
|
|
(_, now) => { hpComp.m_Interact.m_isTarget.selectedIndex = now ? 1 : 0; });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
@ -387,13 +430,6 @@ namespace Game
|
|
|
|
UnbindData(ai.IsHungryFull);
|
|
|
|
UnbindData(ai.IsHungryFull);
|
|
|
|
UnbindData(ai.AttackPermit);
|
|
|
|
UnbindData(ai.AttackPermit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.hasInteract)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
var interact = entity.interact;
|
|
|
|
|
|
|
|
UnbindData(interact.IsActive);
|
|
|
|
|
|
|
|
UnbindData(interact.IsTarget);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -422,14 +458,14 @@ namespace Game
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hp.LastDmg = dmg;
|
|
|
|
hp.LastDmg = dmg;
|
|
|
|
var hitNum = UIManager.Instance.Creator.CreateUIItem<ViewHitNum>(ViewHitNum.URL);
|
|
|
|
var hitNum = UIManager.Instance.Creator.CreateUIItem<ViewHitNum>(ViewHitNum.URL);
|
|
|
|
var item = hitNum.MComponent as ViewHitNum;
|
|
|
|
var item = hitNum.Component as ViewHitNum;
|
|
|
|
hitList.Add(hitNum);
|
|
|
|
hitList.Add(hitNum);
|
|
|
|
targetItem = item;
|
|
|
|
targetItem = item;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
hp.LastDmg += dmg;
|
|
|
|
hp.LastDmg += dmg;
|
|
|
|
targetItem = hitList[hitList.Count - 1].MComponent as ViewHitNum;
|
|
|
|
targetItem = hitList[hitList.Count - 1].Component as ViewHitNum;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
targetItem.m_num.text = $"{hp.LastDmg}";
|
|
|
|
targetItem.m_num.text = $"{hp.LastDmg}";
|
|
|
|
@ -447,7 +483,7 @@ namespace Game
|
|
|
|
var hitList = _hitBuffDict[entityID];
|
|
|
|
var hitList = _hitBuffDict[entityID];
|
|
|
|
var hitNum = UIManager.Instance.Creator.CreateUIItem<ViewHitBuff>(ViewHitBuff.URL);
|
|
|
|
var hitNum = UIManager.Instance.Creator.CreateUIItem<ViewHitBuff>(ViewHitBuff.URL);
|
|
|
|
hitList.Add(hitNum);
|
|
|
|
hitList.Add(hitNum);
|
|
|
|
var item = hitNum.MComponent as ViewHitBuff;
|
|
|
|
var item = hitNum.Component as ViewHitBuff;
|
|
|
|
item.m_name.text = text;
|
|
|
|
item.m_name.text = text;
|
|
|
|
item.m_step1.Play();
|
|
|
|
item.m_step1.Play();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|