From 83dec2efe4ef9d56a98c374256d3c8aadef27ef0 Mon Sep 17 00:00:00 2001
From: client_Wu Xijin <364452445@qq.com>
Date: 星期六, 02 二月 2019 13:03:16 +0800
Subject: [PATCH] 3335 重构窗口管理
---
System/Pet/PetAttributeMethods.cs | 1
Core/GameEngine/Login/LoginStage.cs | 1
System/FindPrecious/DemonJarBossLifeBarWin.cs | 20 ++++
System/WindowBase/Windows.cs | 12 +-
System/Dungeon/TargetBriefInfoWin.cs | 164 +++++++++++++++++++++++++++++-----------
System/FakeDungeon/FakeDemonJarDungeonStage.cs | 6 -
System/Message/MessageWin.cs | 3
System/NetLink/NetLinkWin.cs | 10 --
8 files changed, 148 insertions(+), 69 deletions(-)
diff --git a/Core/GameEngine/Login/LoginStage.cs b/Core/GameEngine/Login/LoginStage.cs
index 9ec4dc9..cd6a5c3 100644
--- a/Core/GameEngine/Login/LoginStage.cs
+++ b/Core/GameEngine/Login/LoginStage.cs
@@ -13,6 +13,7 @@
checkClientTimer = Time.time + 60f;
checkAssetVersionTimer = Time.time + 70f;
+ WindowCenter.Instance.Open<MessageWin>();
WindowCenter.Instance.Close<FightingPKWin>();
WindowCenter.Instance.Open<LaunchBackGroundWin>(true);
diff --git a/System/Dungeon/TargetBriefInfoWin.cs b/System/Dungeon/TargetBriefInfoWin.cs
index c51a2d7..90716f7 100644
--- a/System/Dungeon/TargetBriefInfoWin.cs
+++ b/System/Dungeon/TargetBriefInfoWin.cs
@@ -34,11 +34,23 @@
return;
}
- bossInfo = new MonsterInfo()
+ if (_show)
{
- instanceId = _show ? _instanceId : 0,
- npcId = _show ? _npcId : 0,
- };
+ bossInfo = new MonsterInfo()
+ {
+ instanceId = _instanceId,
+ npcId = _npcId,
+ };
+
+ playerInfo = default(PlayerInfo);
+ }
+ else
+ {
+ if (bossInfo.instanceId == _instanceId)
+ {
+ bossInfo = default(MonsterInfo);
+ }
+ }
var mapId = PlayerDatas.Instance.baseData.MapID;
var dataMapId = ModelCenter.Instance.GetModel<DungeonModel>().GetDataMapIdByMapId(mapId);
@@ -58,13 +70,14 @@
}
- static void OnRefreshBossLifeBar(uint _instanceId, int _npcId, ulong _hp, ulong _maxHp)
+ public static void OnRefreshBossLifeBar(uint _instanceId, int _npcId, ulong _hp, ulong _maxHp)
{
if (CrossServerUtility.IsCrossServerOneVsOne())
{
return;
}
+ playerInfo = default(PlayerInfo);
bossInfo = new MonsterInfo()
{
instanceId = _instanceId,
@@ -86,13 +99,9 @@
}
else
{
- if (PlayerDatas.Instance.hero != null && PlayerDatas.Instance.hero.SelectTarget != null
- && PlayerDatas.Instance.hero.SelectTarget.ServerInstID == TargetBriefInfoWin.currentBossInstanceId)
+ if (!WindowCenter.Instance.IsOpen("TargetBriefInfoWin"))
{
- if (!WindowCenter.Instance.IsOpen("TargetBriefInfoWin"))
- {
- WindowCenter.Instance.Open<TargetBriefInfoWin>(true);
- }
+ WindowCenter.Instance.Open<TargetBriefInfoWin>(true);
}
}
@@ -105,10 +114,22 @@
return;
}
- playerInfo = new PlayerInfo()
+ if (_show)
{
- instanceId = _show ? _instanceId : 0,
- };
+ playerInfo = new PlayerInfo()
+ {
+ instanceId = _instanceId,
+ };
+
+ bossInfo = default(MonsterInfo);
+ }
+ else
+ {
+ if (playerInfo.instanceId == _instanceId)
+ {
+ playerInfo = default(PlayerInfo);
+ }
+ }
if (WindowCenter.Instance.IsOpen("DemonJarBossLifeBarWin"))
{
@@ -125,6 +146,7 @@
return;
}
+ bossInfo = default(MonsterInfo);
playerInfo = new PlayerInfo()
{
instanceId = _instanceId,
@@ -144,6 +166,16 @@
public int npcId;
public ulong hp;
public ulong maxHp;
+
+ public static bool operator ==(MonsterInfo lhs, MonsterInfo rhs)
+ {
+ return lhs.instanceId == rhs.instanceId && lhs.npcId == rhs.npcId && lhs.hp == rhs.hp && lhs.maxHp == rhs.maxHp;
+ }
+
+ public static bool operator !=(MonsterInfo lhs, MonsterInfo rhs)
+ {
+ return lhs.instanceId != rhs.instanceId || lhs.npcId != rhs.npcId || lhs.hp != rhs.hp || lhs.maxHp != rhs.maxHp;
+ }
}
public struct PlayerInfo
@@ -151,6 +183,16 @@
public uint instanceId;
public ulong hp;
public ulong maxHp;
+
+ public static bool operator ==(PlayerInfo lhs, PlayerInfo rhs)
+ {
+ return lhs.instanceId == rhs.instanceId && lhs.hp == rhs.hp && lhs.maxHp == rhs.maxHp;
+ }
+
+ public static bool operator !=(PlayerInfo lhs, PlayerInfo rhs)
+ {
+ return lhs.instanceId != rhs.instanceId || lhs.hp != rhs.hp || lhs.maxHp != rhs.maxHp;
+ }
}
}
@@ -167,8 +209,8 @@
[SerializeField] PlayerLifeBar m_PlayerLifeBar;
[SerializeField] FairyGrabBossBuffTip m_FairyGrabBossBuffTip;
- public static uint currentBossInstanceId = 0;
- public static uint currentPlayerInstanceId = 0;
+ TargetBriefInfo.PlayerInfo playerInfo;
+ TargetBriefInfo.MonsterInfo bossInfo;
#region Built-in
protected override void BindController()
@@ -202,21 +244,67 @@
base.OnActived();
this.transform.SetAsFirstSibling();
+
+ playerInfo = TargetBriefInfo.playerInfo;
+ bossInfo = TargetBriefInfo.bossInfo;
+
+ if (playerInfo.instanceId != 0)
+ {
+ ShowPlayerLifeBar(playerInfo.instanceId, true);
+ }
+ else
+ {
+ ShowPlayerLifeBar(0, false);
+
+ if (bossInfo.instanceId != 0)
+ {
+ ShowBossLifeBar(bossInfo.instanceId, bossInfo.npcId, true);
+ }
+ else
+ {
+ ShowBossLifeBar(0, 0, false);
+ }
+ }
+ }
+
+ protected override void LateUpdate()
+ {
+ base.LateUpdate();
+
+ if (TargetBriefInfo.bossInfo != bossInfo)
+ {
+ bossInfo = TargetBriefInfo.bossInfo;
+ if (bossInfo.instanceId == 0)
+ {
+ ShowBossLifeBar(0, 0, false);
+ }
+ else
+ {
+ RefreshBossLifeBar(bossInfo.instanceId, bossInfo.npcId, bossInfo.hp, bossInfo.maxHp);
+ }
+ }
+
+ if (TargetBriefInfo.playerInfo != playerInfo)
+ {
+ playerInfo = TargetBriefInfo.playerInfo;
+ if (playerInfo.instanceId == 0)
+ {
+ ShowPlayerLifeBar(0, false);
+ }
+ else
+ {
+ RefreshPlayerLifeBar(playerInfo.instanceId, playerInfo.hp, playerInfo.maxHp);
+ }
+ }
+
}
#endregion
- public void ShowBossLifeBar(uint _instanceId, int _npcId, bool _show)
+ 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);
m_FairyGrabBossBuffTip.Init();
@@ -234,31 +322,22 @@
{
m_ContainerBoss.gameObject.SetActive(false);
m_FairyGrabBossBuffTip.UnInit();
- currentBossInstanceId = 0;
}
}
- public void RefreshBossLifeBar(uint _instanceId, int _npcId, ulong _hp, ulong _maxHp)
+ void RefreshBossLifeBar(uint _instanceId, int _npcId, ulong _hp, ulong _maxHp)
{
- if (_instanceId != currentBossInstanceId)
- {
- return;
- }
-
m_ContainerBoss.gameObject.SetActive(true);
m_BossLifeBar.Show(_hp, _maxHp);
}
- public void ShowPlayerLifeBar(uint _instanceId, bool _show)
+ void ShowPlayerLifeBar(uint _instanceId, bool _show)
{
if (_show)
{
var player = GAMgr.Instance.GetBySID(_instanceId) as GActorPlayerBase;
-
- if (_instanceId != currentPlayerInstanceId && player != null)
+ if (player != null)
{
- currentPlayerInstanceId = _instanceId;
-
m_ContainerPlayer.gameObject.SetActive(true);
m_ContainerBoss.gameObject.SetActive(false);
m_FairyGrabBossBuffTip.UnInit();
@@ -275,22 +354,13 @@
}
else
{
- if (_instanceId == currentPlayerInstanceId)
- {
- m_ContainerPlayer.gameObject.SetActive(false);
- currentPlayerInstanceId = 0;
- }
+ m_ContainerPlayer.gameObject.SetActive(false);
}
}
- public void RefreshPlayerLifeBar(uint _instanceId, ulong _hp, ulong _maxHp)
+ void RefreshPlayerLifeBar(uint _instanceId, ulong _hp, ulong _maxHp)
{
- if (_instanceId != currentPlayerInstanceId)
- {
- return;
- }
-
m_ContainerPlayer.gameObject.SetActive(true);
m_PlayerLifeBar.Show(_hp, _maxHp);
}
diff --git a/System/FakeDungeon/FakeDemonJarDungeonStage.cs b/System/FakeDungeon/FakeDemonJarDungeonStage.cs
index 70726d8..25a5d1d 100644
--- a/System/FakeDungeon/FakeDemonJarDungeonStage.cs
+++ b/System/FakeDungeon/FakeDemonJarDungeonStage.cs
@@ -349,11 +349,7 @@
if (_victimId == boss.ServerInstID)
{
- var lifeBar = WindowCenter.Instance.Get<DemonJarBossLifeBarWin>();
- if (lifeBar != null)
- {
- lifeBar.RefreshBossLifeBar();
- }
+ TargetBriefInfo.OnRefreshBossLifeBar(_victimId, 0, 0, 0);
}
}
diff --git a/System/FindPrecious/DemonJarBossLifeBarWin.cs b/System/FindPrecious/DemonJarBossLifeBarWin.cs
index d7a9094..66f02a3 100644
--- a/System/FindPrecious/DemonJarBossLifeBarWin.cs
+++ b/System/FindPrecious/DemonJarBossLifeBarWin.cs
@@ -18,17 +18,22 @@
const long BOSSHP_TOTAL = 1000000000;
[SerializeField] BossLifeBar m_BossLifeBar;
+ TargetBriefInfo.MonsterInfo bossInfo;
+
DungeonModel model { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
DemonJarModel demonJarModel { get { return ModelCenter.Instance.GetModel<DemonJarModel>(); } }
bool inited = false;
long m_CurrentHp = BOSSHP_TOTAL;
- long currentHp {
- get {
+ long currentHp
+ {
+ get
+ {
return m_CurrentHp;
}
- set {
+ set
+ {
if (value <= 0)
{
m_CurrentHp = 0;
@@ -86,6 +91,15 @@
CloseClick();
}
}
+
+ if (TargetBriefInfo.bossInfo != bossInfo)
+ {
+ bossInfo = TargetBriefInfo.bossInfo;
+ if (bossInfo.instanceId != 0)
+ {
+ RefreshBossLifeBar();
+ }
+ }
}
#endregion
diff --git a/System/Message/MessageWin.cs b/System/Message/MessageWin.cs
index c116b36..fc66fe4 100644
--- a/System/Message/MessageWin.cs
+++ b/System/Message/MessageWin.cs
@@ -18,8 +18,9 @@
{
if (_inst == null)
{
- _inst = WindowCenter.Instance.Open<MessageWin>(true);
+ _inst = WindowCenter.Instance.Get<MessageWin>();
}
+
return _inst;
}
}
diff --git a/System/NetLink/NetLinkWin.cs b/System/NetLink/NetLinkWin.cs
index 92393d1..25a10d1 100644
--- a/System/NetLink/NetLinkWin.cs
+++ b/System/NetLink/NetLinkWin.cs
@@ -20,18 +20,12 @@
{
linkOverTime = _delay;
- if (!WindowCenter.Instance.IsOpen<NetLinkWin>())
- {
- WindowCenter.Instance.Open<NetLinkWin>(true);
- }
+ WindowCenter.Instance.Open<NetLinkWin>(true);
}
public static void Hide()
{
- if (WindowCenter.Instance.IsOpen<NetLinkWin>())
- {
- WindowCenter.Instance.Close<NetLinkWin>();
- }
+ WindowCenter.Instance.Close<NetLinkWin>();
}
diff --git a/System/Pet/PetAttributeMethods.cs b/System/Pet/PetAttributeMethods.cs
index 1d448d8..ff5cf4e 100644
--- a/System/Pet/PetAttributeMethods.cs
+++ b/System/Pet/PetAttributeMethods.cs
@@ -615,6 +615,7 @@
CreateCurPetSkill();
curPetNameText.text = petInfoConfig.Name;
AllPetAttrCtrl();
+
if (WindowCenter.Instance.Get<PetAttributeWin>().AchievementGuideEffect2 != null)
{
AchievementGuideEffectPool.Recycle(WindowCenter.Instance.Get<PetAttributeWin>().AchievementGuideEffect2);
diff --git a/System/WindowBase/Windows.cs b/System/WindowBase/Windows.cs
index 9ea7f04..d98016a 100644
--- a/System/WindowBase/Windows.cs
+++ b/System/WindowBase/Windows.cs
@@ -553,8 +553,10 @@
private void LateUpdate()
{
- foreach (var command in closeCommands)
+ while (closeCommands.Count > 0)
{
+ var command = closeCommands[0];
+ closeCommands.RemoveAt(0);
Window window = null;
if (windows.TryGetValue(command.name, out window))
{
@@ -567,10 +569,10 @@
asyncLoad.StopTask(command.name);
}
- closeCommands.Clear();
-
- foreach (var command in openCommands)
+ while (openCommands.Count > 0)
{
+ var command = openCommands[0];
+ openCommands.RemoveAt(0);
Window window = null;
if (windows.TryGetValue(command.name, out window))
{
@@ -589,9 +591,9 @@
{
ExecuteFirstOpen(command);
}
+
}
- openCommands.Clear();
}
private void ExecuteFirstOpen(OpenCommand command)
--
Gitblit v1.8.0