Skip to content

Commit 6b9d33f

Browse files
committed
feat: add kills count at retry (total yolo)
1 parent 14a0e43 commit 6b9d33f

File tree

8 files changed

+32
-3
lines changed

8 files changed

+32
-3
lines changed

Assets/Runtime/Enemy/EnemyManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private IEnumerator SpawnEnemies(TargetableBehaviour? targetableBehaviour)
6262

6363
private void OnGameStateUpdated(GameState gameState)
6464
{
65-
if (gameState == GameState.Stopped)
65+
if (gameState == GameState.Started)
6666
{
6767
foreach (var spawnedEnemy in _spawnedEnemies)
6868
{

Assets/Runtime/Game/GameBehaviour.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ namespace Com.ThirdNerve.Backfire.Runtime.Game
55
{
66
public class GameBehaviour : MonoBehaviour
77
{
8+
public int Kills;
9+
810
[SerializeField] private GameState gameState = GameState.Stopped;
911
public GameState GameState
1012
{
@@ -37,6 +39,7 @@ public void Pause()
3739
public void StopGame()
3840
{
3941
GameState = GameState.Stopped;
42+
Kills = 0;
4043
Time.timeScale = 1f;
4144
}
4245

Assets/Runtime/Player/PlayerSpawnBehaviour.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using Com.ThirdNerve.Backfire.Runtime.Game;
22
using Com.ThirdNerve.Backfire.Runtime.Health;
3+
using Com.ThirdNerve.Backfire.Runtime.Stats;
34
using UnityEngine;
45

56
namespace Com.ThirdNerve.Backfire.Runtime.Player
@@ -24,6 +25,7 @@ private void OnGameStateUpdated(GameState gameState)
2425
_player.GetComponent<FailOnDeathBehaviour>().gameBehaviour = _gameBehaviour;
2526
_player.GetComponent<PlayerMovementBehaviour>().gameBehaviour = _gameBehaviour;
2627
_player.GetComponent<PlayerReflectorBehaviour>().gameBehaviour = _gameBehaviour;
28+
_player.GetComponent<KillCountBehaviour>().gameBehaviour = _gameBehaviour;
2729
break;
2830
case GameState.Stopped:
2931
Destroy(_player);

Assets/Runtime/Stats/KillCountBehaviour.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
using System;
2+
using Com.ThirdNerve.Backfire.Runtime.Game;
23
using UnityEngine;
34

45
namespace Com.ThirdNerve.Backfire.Runtime.Stats
56
{
67
public class KillCountBehaviour : MonoBehaviour
78
{
9+
public GameBehaviour? gameBehaviour;
810
private int _current;
911

1012
public int Current
@@ -13,6 +15,11 @@ public int Current
1315
set
1416
{
1517
_current = value;
18+
if (gameBehaviour != null)
19+
{
20+
gameBehaviour.Kills = value;
21+
}
22+
1623
KillsUpdated?.Invoke(this);
1724
}
1825
}

Assets/Runtime/UI/Menu/FailedMenuBehaviour.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ private void GameStateUpdated(GameState gameState)
5252

5353
private void Show()
5454
{
55+
var kills = _root.Q<TextElement>("kills");
56+
kills.text = $"Kills: {_gameBehaviour.Kills}";
57+
5558
_root.style.display = DisplayStyle.Flex;
5659
_retryButton.Focus();
5760
}

Assets/Scenes/Level.unity

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -552,6 +552,7 @@ MonoBehaviour:
552552
m_Script: {fileID: 11500000, guid: f8c6aa41db664da5a37c5b1eb614dacd, type: 3}
553553
m_Name:
554554
m_EditorClassIdentifier:
555+
gameBehaviour: {fileID: 0}
555556
--- !u!1 &342955371
556557
GameObject:
557558
m_ObjectHideFlags: 0
@@ -630,7 +631,7 @@ Transform:
630631
m_GameObject: {fileID: 342955371}
631632
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
632633
m_LocalPosition: {x: 0, y: 0, z: 0}
633-
m_LocalScale: {x: 25, y: 25, z: 1}
634+
m_LocalScale: {x: 23, y: 23, z: 0}
634635
m_ConstrainProportionsScale: 0
635636
m_Children: []
636637
m_Father: {fileID: 0}
@@ -735,7 +736,7 @@ Camera:
735736
m_Enabled: 1
736737
serializedVersion: 2
737738
m_ClearFlags: 2
738-
m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0}
739+
m_BackGroundColor: {r: 0, g: 0, b: 0, a: 0}
739740
m_projectionMatrixMode: 1
740741
m_GateFitMode: 2
741742
m_FOVAxisMode: 0
@@ -1059,6 +1060,7 @@ MonoBehaviour:
10591060
m_Script: {fileID: 11500000, guid: ec6e08d68e254c3496225d7e6f3677fd, type: 3}
10601061
m_Name:
10611062
m_EditorClassIdentifier:
1063+
Kills: 0
10621064
gameState: 4
10631065
--- !u!4 &920591321
10641066
Transform:
@@ -1469,6 +1471,7 @@ MonoBehaviour:
14691471
m_Script: {fileID: 11500000, guid: f8c6aa41db664da5a37c5b1eb614dacd, type: 3}
14701472
m_Name:
14711473
m_EditorClassIdentifier:
1474+
gameBehaviour: {fileID: 0}
14721475
--- !u!1 &1129614780
14731476
GameObject:
14741477
m_ObjectHideFlags: 0
@@ -1973,6 +1976,7 @@ MonoBehaviour:
19731976
m_Script: {fileID: 11500000, guid: f8c6aa41db664da5a37c5b1eb614dacd, type: 3}
19741977
m_Name:
19751978
m_EditorClassIdentifier:
1979+
gameBehaviour: {fileID: 0}
19761980
--- !u!1 &1254199996
19771981
GameObject:
19781982
m_ObjectHideFlags: 0
@@ -2434,6 +2438,7 @@ MonoBehaviour:
24342438
m_Script: {fileID: 11500000, guid: f8c6aa41db664da5a37c5b1eb614dacd, type: 3}
24352439
m_Name:
24362440
m_EditorClassIdentifier:
2441+
gameBehaviour: {fileID: 0}
24372442
--- !u!1 &1483436857
24382443
GameObject:
24392444
m_ObjectHideFlags: 0

Assets/UI/FailureMenu.uss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
.list-container {
22
background-color: rgba(255, 0, 0, 0.7);
33
}
4+
5+
.kills {
6+
-unity-text-align: upper-center;
7+
font-size: 36px;
8+
color: white;
9+
padding-bottom: 36px;
10+
}

Assets/UI/FailureMenu.uxml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<Style src="./FailureMenu.uss" />
44

55
<ui:VisualElement name="container" class="container">
6+
<ui:TextElement name="kills" class="kills"/>
7+
68
<ui:VisualElement name="list-container" class="list-container">
79
<ui:Button name="retry" text="Retry" class="menu-item"/>
810
<ui:Button name="quit" text="Quit" class="menu-item"/>

0 commit comments

Comments
 (0)