Skip to content
Draft
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
3 changes: 3 additions & 0 deletions Assets/Interface Assets/GameOver.uxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements" xmlns:uie="UnityEditor.UIElements" xsi="http://www.w3.org/2001/XMLSchema-instance" engine="UnityEngine.UIElements" editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../UIElementsSchema/UIElements.xsd" editor-extension-mode="False">
<ui:Label text="GAME OVER" display-tooltip-when-elided="true" style="font-size: 64px; white-space: normal; height: 402px;" />
</ui:UXML>
10 changes: 10 additions & 0 deletions Assets/Interface Assets/GameOver.uxml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 50 additions & 1 deletion Assets/Scenes/Game.unity
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand Down
18 changes: 18 additions & 0 deletions Assets/Src/LobbyManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<PlayerController>();
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()
Expand Down
6 changes: 2 additions & 4 deletions Assets/Src/PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ private void OnHealthChangeClient(float previousValue, float newValue)

private void OnHealthChangeServer(object sender, EventArgs e)
{

if (IsServer)
{
health.Value = hs.GetHealth();
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions Assets/Src/UI/LobbyUIController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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()
Expand Down