diff --git a/Assets/Interface Assets/GameOver.uxml b/Assets/Interface Assets/GameOver.uxml
new file mode 100644
index 0000000..b7bf54d
--- /dev/null
+++ b/Assets/Interface Assets/GameOver.uxml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/Assets/Interface Assets/GameOver.uxml.meta b/Assets/Interface Assets/GameOver.uxml.meta
new file mode 100644
index 0000000..e527fbe
--- /dev/null
+++ b/Assets/Interface Assets/GameOver.uxml.meta
@@ -0,0 +1,10 @@
+fileFormatVersion: 2
+guid: 027f1a2de6bbc4ecbafa99b6b0e54ead
+ScriptedImporter:
+ internalIDToNameTable: []
+ externalObjects: {}
+ serializedVersion: 2
+ userData:
+ assetBundleName:
+ assetBundleVariant:
+ script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}
diff --git a/Assets/Scenes/Game.unity b/Assets/Scenes/Game.unity
index d8994c0..9abd4ad 100644
--- a/Assets/Scenes/Game.unity
+++ b/Assets/Scenes/Game.unity
@@ -38,7 +38,7 @@ RenderSettings:
m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 705507994}
- m_IndirectSpecularColor: {r: 0.18028326, g: 0.22571333, b: 0.30692202, a: 1}
+ m_IndirectSpecularColor: {r: 0.18028301, g: 0.22571309, b: 0.30692127, a: 1}
m_UseRadianceAmbientProbe: 0
--- !u!157 &3
LightmapSettings:
@@ -207,6 +207,54 @@ Transform:
m_Father: {fileID: 1637532756}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: -135, z: 0}
+--- !u!1 &575161927
+GameObject:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ serializedVersion: 6
+ m_Component:
+ - component: {fileID: 575161928}
+ - component: {fileID: 575161929}
+ m_Layer: 5
+ m_Name: YouAreDead
+ m_TagString: Untagged
+ m_Icon: {fileID: 0}
+ m_NavMeshLayer: 0
+ m_StaticEditorFlags: 0
+ m_IsActive: 1
+--- !u!4 &575161928
+Transform:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 575161927}
+ m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
+ m_LocalPosition: {x: 0, y: 0, z: 0}
+ m_LocalScale: {x: 1, y: 1, z: 1}
+ m_ConstrainProportionsScale: 0
+ m_Children: []
+ m_Father: {fileID: 1395018204}
+ m_RootOrder: 3
+ m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
+--- !u!114 &575161929
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 575161927}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 19102, guid: 0000000000000000e000000000000000, type: 0}
+ m_Name:
+ m_EditorClassIdentifier:
+ m_PanelSettings: {fileID: 11400000, guid: 5de7ff8d9b1f3415195a2e4429eb502c, type: 2}
+ m_ParentUI: {fileID: 0}
+ sourceAsset: {fileID: 9197481963319205126, guid: 027f1a2de6bbc4ecbafa99b6b0e54ead, type: 3}
+ m_SortingOrder: 0
--- !u!1 &592038060
GameObject:
m_ObjectHideFlags: 0
@@ -785,6 +833,7 @@ Transform:
- {fileID: 1522746831}
- {fileID: 1895071184}
- {fileID: 874665408}
+ - {fileID: 575161928}
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
diff --git a/Assets/Src/LobbyManager.cs b/Assets/Src/LobbyManager.cs
index d09b98c..9e13a28 100644
--- a/Assets/Src/LobbyManager.cs
+++ b/Assets/Src/LobbyManager.cs
@@ -156,6 +156,24 @@ private void Update()
{
RefreshLobbyData();
}
+
+ if (State == LobbyState.ClientInGame) {
+ // Load all players and figure our how many of them are alive
+ var players = gameObject.GetComponents();
+ var aliveCount = 0;
+ foreach (var player in players)
+ {
+ if (!player.GetHealthSystem().IsDead()) {
+ aliveCount++;
+ }
+ }
+
+ if (aliveCount <= 1) {
+ // Game over
+ Debug.Log("Game over");
+ CloseGame();
+ }
+ }
}
private void OnDestroy()
diff --git a/Assets/Src/PlayerController.cs b/Assets/Src/PlayerController.cs
index 7c4ee7d..c052c5d 100644
--- a/Assets/Src/PlayerController.cs
+++ b/Assets/Src/PlayerController.cs
@@ -38,7 +38,6 @@ private void OnHealthChangeClient(float previousValue, float newValue)
private void OnHealthChangeServer(object sender, EventArgs e)
{
-
if (IsServer)
{
health.Value = hs.GetHealth();
@@ -142,9 +141,8 @@ public void OnHitServer(float damage, ulong sourcePlayer)
hs.Damage(damage);
if (hs.IsDead())
{
- Debug.Log($"Thats it, Im dead :( killed by #{sourcePlayer}. I have died #{deaths} times.");
- deaths++;
- hs.SetHealth(maxHealth);
+ Debug.Log($"Thats it, Im dead :( killed by #{sourcePlayer}.");
+ networkObject.Despawn(true);
}
}
}
diff --git a/Assets/Src/UI/LobbyUIController.cs b/Assets/Src/UI/LobbyUIController.cs
index df265d3..8984fc3 100644
--- a/Assets/Src/UI/LobbyUIController.cs
+++ b/Assets/Src/UI/LobbyUIController.cs
@@ -51,6 +51,7 @@ public class LobbyUIController : MonoBehaviour
// in game view buttons
private Button closeGameButton;
private Button leaveGameButton;
+ private GameObject gameOverUI;
// unity events
private async void Awake()
@@ -123,6 +124,7 @@ private void SetupInGameViewReferences()
// in game view buttons
closeGameButton = inGameDocument.rootVisualElement.Q("close-game") as Button;
leaveGameButton = inGameDocument.rootVisualElement.Q("leave-game") as Button;
+ gameOverUI = GameObject.Find("GameOver");
}
public string GetPlayerName()