Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,6 @@ public override void NetworkStart()
m_NetState.OnPerformHitReaction += OnPerformHitReaction;
m_NetState.OnStopChargingUpClient += OnStoppedChargingUp;
m_NetState.IsStealthy.OnValueChanged += OnStealthyChanged;
// With this call, players connecting to a game with down imps will see all of them do the "dying" animation.
// we should investigate for a way to have the imps already appear as down when connecting.
// todo gomps-220
OnLifeStateChanged(m_NetState.NetworkLifeState.Value, m_NetState.NetworkLifeState.Value);

//we want to follow our parent on a spring, which means it can't be directly in the transform hierarchy.
Parent.GetComponent<ClientCharacter>().ChildVizObject = this;
Expand All @@ -88,9 +84,6 @@ public override void NetworkStart()
transform.position = parentMovement.NetworkPosition.Value;
transform.rotation = Quaternion.Euler(0, parentMovement.NetworkRotationY.Value, 0);

// sync our animator to the most up to date version received from server
SyncEntryAnimation(m_NetState.NetworkLifeState.Value);

// listen for char-select info to change (in practice, this info doesn't
// change, but we may not have the values set yet) ...
m_NetState.CharacterAppearance.OnValueChanged += OnCharacterAppearanceChanged;
Expand All @@ -101,6 +94,9 @@ public override void NetworkStart()
// ...and visualize the current char-select value that we know about
SetAppearanceSwap();

// sync our animator to the most up to date version received from server
SyncEntryAnimation(m_NetState.NetworkLifeState.Value);

if (!m_NetState.IsNpc)
{
// track health for heroes
Expand Down
19 changes: 15 additions & 4 deletions Assets/BossRoom/Scripts/Shared/Game/UI/UIStateDisplayHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ void OnEnable()
}

Assert.IsTrue(m_DisplayHealth || m_DisplayName, "Neither display fields are toggled on!");
if (m_DisplayHealth)
Assert.IsNotNull(m_NetworkHealthState, "A NetworkHealthState component needs to be attached!");
if (m_DisplayName)
Assert.IsNotNull(m_NetworkNameState, "A NetworkNameState component needs to be attached!");
Assert.IsTrue(m_Camera != null && m_CanvasTransform != null);

m_VerticalOffset = new Vector3(0f, m_VerticalScreenOffset, 0f);
Expand Down Expand Up @@ -109,6 +113,12 @@ void OnEnable()
CharacterTypeChanged(m_NetworkCharacterTypeState.CharacterType.Value,
m_NetworkCharacterTypeState.CharacterType.Value);
}

if (m_NetworkHealthState != null)
{
m_NetworkHealthState.HitPointsReplenished += DisplayUIHealth;
m_NetworkHealthState.HitPointsDepleted += RemoveUIHealth;
}
}
}

Expand Down Expand Up @@ -137,7 +147,11 @@ void CharacterTypeChanged(CharacterTypeEnum previousValue, CharacterTypeEnum new
if (characterClass)
{
m_BaseHP = characterClass.BaseHP;
DisplayUIHealth();

if (m_NetworkHealthState != null && m_NetworkHealthState.HitPoints.Value > 0)
{
DisplayUIHealth();
}
}
}

Expand Down Expand Up @@ -171,9 +185,6 @@ void DisplayUIHealth()

m_UIState.DisplayHealth(m_NetworkHealthState.HitPoints, m_BaseHP.Value);
m_UIStateActive = true;

m_NetworkHealthState.HitPointsReplenished += DisplayUIHealth;
m_NetworkHealthState.HitPointsDepleted += RemoveUIHealth;
}

void SpawnUIState()
Expand Down