add spawn point, death

This commit is contained in:
2023-07-10 19:21:58 +03:00
parent 9d68af5244
commit 2df859debe
9 changed files with 163 additions and 7 deletions
+16 -1
View File
@@ -12,6 +12,8 @@ public class Player : Character
[SerializeField]
private Sprite _noHammerSprite;
public int Lives=3;
private int _hammerSpeed = 5;
private int _totalCoins = 0;
@@ -25,7 +27,6 @@ public class Player : Character
private void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
@@ -37,6 +38,7 @@ public class Player : Character
DontDestroyOnLoad(gameObject);
_spriteRenderer = GetComponentInChildren<SpriteRenderer>();
Spawn();
}
public void AddCoin()
@@ -105,4 +107,17 @@ public class Player : Character
}
_animator.SetBool("Climb", isClimbing);
}
protected override void OnDeath()
{
Lives--;
Spawn();
if (Lives==0)
{
print("game over");
}
}
}