Skip to content

Commit

Permalink
Merge pull request #6 from nguyloc/Loc
Browse files Browse the repository at this point in the history
Fix code
  • Loading branch information
nguyloc authored Jun 18, 2024
2 parents f66e314 + f06c2c9 commit 812c515
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Assets/Loc/Prefab/GameController.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
score: 0
live: 3
live: 1
scoreText: {fileID: 6499760609730368711}
liveText: {fileID: 868600938434190930}
gameOverPanel: {fileID: 1271839059773703003}
Expand Down
4 changes: 4 additions & 0 deletions Assets/Loc/Scene/Scene 2.unity
Original file line number Diff line number Diff line change
Expand Up @@ -7364,6 +7364,10 @@ PrefabInstance:
propertyPath: m_Name
value: GameController
objectReference: {fileID: 0}
- target: {fileID: 7898298861492298930, guid: 40faca3c88a00144aa0458d067dec36e, type: 3}
propertyPath: live
value: 1
objectReference: {fileID: 0}
m_RemovedComponents: []
m_RemovedGameObjects: []
m_AddedGameObjects: []
Expand Down
22 changes: 11 additions & 11 deletions Assets/Loc/Scripts/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class GameController : MonoBehaviour
public static GameController Instance { get; private set; }

[SerializeField] int score = 0;
[SerializeField] int live = 3;
[SerializeField] int live = 1;
[SerializeField] TextMeshProUGUI scoreText;
[SerializeField] TextMeshProUGUI liveText;
[SerializeField] GameObject gameOverPanel;
Expand Down Expand Up @@ -42,15 +42,15 @@ private void DecreaseLive()
live--;
UpdateUI();

if (live == 0)
{
int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
SceneManager.LoadScene(currentSceneIndex);
}
else
{
GameOverPanel();
}
//if (live == 0)
//{
// int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
// SceneManager.LoadScene(currentSceneIndex);
//}
//else
//{
// GameOverPanel();
//}
}

public void ResetScore()
Expand All @@ -61,7 +61,7 @@ public void ResetScore()

public void ResetLives()
{
live = 3;
live = 1;
UpdateUI();
}

Expand Down
15 changes: 12 additions & 3 deletions Assets/Loc/Scripts/PlayerMovement.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,20 @@ private void CheckForDeath()
isAlive = false;
_animator.SetTrigger("Dying");
_rigibody2D.velocity = Vector2.zero;

GameController.Instance.ProcessPlayerDeath();
GameController.Instance.ResetScore();
StartCoroutine(HandleDeath());
//GameController.Instance.ProcessPlayerDeath();
//GameController.Instance.ResetScore();
//GameController.Instance.GameOverPanel();
}
}
private IEnumerator HandleDeath()
{

yield return new WaitForSeconds(1f);


GameController.Instance.GameOverPanel();
}

void OnFire(InputValue value)
{
Expand Down

0 comments on commit 812c515

Please sign in to comment.