add spawn point, death
This commit is contained in:
@@ -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");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user