//--------------------------------------------------------
|
// [Author]: 第二世界
|
// [ Date ]: Saturday, October 14, 2017
|
//--------------------------------------------------------
|
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using Snxxz.UI;
|
|
public class TargetBriefInfo
|
{
|
|
public static void Init()
|
{
|
GA_NpcFightBoss.s_OnSelect += OnShowBossLifeBar;
|
GA_NpcFightBoss.s_HpRefresh += OnRefreshBossLifeBar;
|
|
GA_NpcClientFightBoss.s_OnSelect += OnShowBossLifeBar;
|
GA_NpcClientFightBoss.s_HpRefresh += OnRefreshBossLifeBar;
|
|
GA_Player.s_OnRefreshLife += OnRefreshPlayerLifeBar;
|
GA_Player.s_OnSelected += OnShowPlayerLifeBar;
|
}
|
|
static void OnShowBossLifeBar(uint _instanceId, int _npcId, bool _show)
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var dataMapId = ModelCenter.Instance.GetModel<DungeonModel>().GetDataMapIdByMapId(mapId);
|
if (dataMapId == DemonJarModel.DEMONJAR_MAPID)
|
{
|
if (_show)
|
{
|
DemonJarBossLifeBarWin win;
|
if (!WindowCenter.Instance.CheckOpen<DemonJarBossLifeBarWin>())
|
{
|
win = WindowCenter.Instance.Open<DemonJarBossLifeBarWin>(true);
|
}
|
else
|
{
|
win = WindowCenter.Instance.Get<DemonJarBossLifeBarWin>();
|
}
|
|
win.InitBossLifeBar();
|
}
|
}
|
else
|
{
|
TargetBriefInfoWin win;
|
if (!WindowCenter.Instance.CheckOpen<TargetBriefInfoWin>())
|
{
|
win = WindowCenter.Instance.Open<TargetBriefInfoWin>(true);
|
}
|
else
|
{
|
win = WindowCenter.Instance.Get<TargetBriefInfoWin>();
|
}
|
|
win.ShowBossLifeBar(_instanceId, _npcId, _show);
|
}
|
|
}
|
|
static void OnRefreshBossLifeBar(uint _instanceId, int _npcId, ulong _hp, ulong _maxHp)
|
{
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var dataMapId = ModelCenter.Instance.GetModel<DungeonModel>().GetDataMapIdByMapId(mapId);
|
if (dataMapId == DemonJarModel.DEMONJAR_MAPID)
|
{
|
DemonJarBossLifeBarWin win;
|
if (!WindowCenter.Instance.CheckOpen<DemonJarBossLifeBarWin>())
|
{
|
win = WindowCenter.Instance.Open<DemonJarBossLifeBarWin>(true);
|
}
|
else
|
{
|
win = WindowCenter.Instance.Get<DemonJarBossLifeBarWin>();
|
}
|
|
win.RefreshBossLifeBar();
|
}
|
else
|
{
|
if (PlayerDatas.Instance.hero != null && PlayerDatas.Instance.hero.SelectTarget != null
|
&& PlayerDatas.Instance.hero.SelectTarget.ServerInstID == TargetBriefInfoWin.currentBossInstanceId)
|
{
|
TargetBriefInfoWin win;
|
if (!WindowCenter.Instance.CheckOpen<TargetBriefInfoWin>())
|
{
|
win = WindowCenter.Instance.Open<TargetBriefInfoWin>(true);
|
}
|
else
|
{
|
win = WindowCenter.Instance.Get<TargetBriefInfoWin>();
|
}
|
|
win.RefreshBossLifeBar(_instanceId, _npcId, _hp, _maxHp);
|
}
|
|
}
|
|
}
|
|
static void OnShowPlayerLifeBar(uint _instanceId, bool _show)
|
{
|
TargetBriefInfoWin win;
|
if (!WindowCenter.Instance.CheckOpen<TargetBriefInfoWin>())
|
{
|
win = WindowCenter.Instance.Open<TargetBriefInfoWin>(true);
|
}
|
else
|
{
|
win = WindowCenter.Instance.Get<TargetBriefInfoWin>();
|
}
|
|
win.ShowPlayerLifeBar(_instanceId, _show);
|
}
|
|
static void OnRefreshPlayerLifeBar(uint _instanceId, ulong _hp, ulong _maxHp)
|
{
|
var win = WindowCenter.Instance.Get<TargetBriefInfoWin>();
|
if (win != null)
|
{
|
win.RefreshPlayerLifeBar(_instanceId, _hp, _maxHp);
|
}
|
}
|
}
|
|
namespace Snxxz.UI
|
{
|
|
public class TargetBriefInfoWin : Window
|
{
|
[SerializeField] Transform m_ContainerBoss;
|
[SerializeField] BossLifeBar m_BossLifeBar;
|
[SerializeField] ElderGodAngerBehaviour m_ElderGodAnger;
|
[SerializeField] Transform m_ContainerPlayer;
|
[SerializeField] PlayerLifeBar m_PlayerLifeBar;
|
|
public static uint currentBossInstanceId = 0;
|
public static uint currentPlayerInstanceId = 0;
|
|
#region Built-in
|
protected override void BindController()
|
{
|
}
|
|
protected override void AddListeners()
|
{
|
}
|
|
protected override void OnPreOpen()
|
{
|
}
|
|
protected override void OnAfterOpen()
|
{
|
}
|
|
protected override void OnPreClose()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void OnActived()
|
{
|
base.OnActived();
|
|
this.transform.SetAsFirstSibling();
|
}
|
|
#endregion
|
|
public void ShowBossLifeBar(uint _instanceId, int _npcId, bool _show)
|
{
|
if (_show)
|
{
|
if (_instanceId == currentBossInstanceId)
|
{
|
return;
|
}
|
|
currentBossInstanceId = _instanceId;
|
|
m_ContainerPlayer.gameObject.SetActive(false);
|
m_ContainerBoss.gameObject.SetActive(true);
|
|
var boss = GAMgr.Instance.GetBySID(_instanceId) as GActorNpcFight;
|
if (boss != null)
|
{
|
m_BossLifeBar.SetBaseInfo(_npcId, boss.ActorInfo.RealHp, boss.ActorInfo.RealMaxHp, boss.ActorInfo.LV);
|
}
|
|
m_ElderGodAnger.Display(_npcId);
|
}
|
else
|
{
|
m_ContainerBoss.gameObject.SetActive(false);
|
currentBossInstanceId = 0;
|
}
|
}
|
|
public void RefreshBossLifeBar(uint _instanceId, int _npcId, ulong _hp, ulong _maxHp)
|
{
|
if (_instanceId != currentBossInstanceId)
|
{
|
return;
|
}
|
|
m_BossLifeBar.Show(_hp, _maxHp);
|
}
|
|
public void ShowPlayerLifeBar(uint _instanceId, bool _show)
|
{
|
if (_show)
|
{
|
if (_instanceId != currentPlayerInstanceId)
|
{
|
currentPlayerInstanceId = _instanceId;
|
var player = GAMgr.Instance.GetBySID(currentPlayerInstanceId) as GActorPlayerBase;
|
m_ContainerPlayer.gameObject.SetActive(true);
|
m_ContainerBoss.gameObject.SetActive(false);
|
|
var job = player.ActorInfo.Job;
|
var reincarnationLv = player.ActorInfo.ReincarnationLv;
|
var playerName = player.ActorInfo.PlayerName;
|
var playerLevel = player.ActorInfo.LV;
|
var playerHp = player.ActorInfo.RealHp;
|
var playerMaxHp = player.ActorInfo.RealMaxHp;
|
|
m_PlayerLifeBar.SetBaseInfo((int)_instanceId, job, reincarnationLv, playerName, playerLevel, playerHp, playerMaxHp);
|
}
|
}
|
else
|
{
|
if (_instanceId == currentPlayerInstanceId)
|
{
|
m_ContainerPlayer.gameObject.SetActive(false);
|
currentPlayerInstanceId = 0;
|
}
|
}
|
|
}
|
|
public void RefreshPlayerLifeBar(uint _instanceId, ulong _hp, ulong _maxHp)
|
{
|
if (_instanceId != currentPlayerInstanceId)
|
{
|
return;
|
}
|
|
m_PlayerLifeBar.Show(_hp, _maxHp);
|
}
|
|
}
|
|
}
|
|
|
|
|