diff options
Diffstat (limited to 'Assets/Scripts/Actors/Player.cs')
-rw-r--r-- | Assets/Scripts/Actors/Player.cs | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/Assets/Scripts/Actors/Player.cs b/Assets/Scripts/Actors/Player.cs index 012c09a..95ec2ca 100644 --- a/Assets/Scripts/Actors/Player.cs +++ b/Assets/Scripts/Actors/Player.cs @@ -12,10 +12,11 @@ namespace MontanaJohns.Actors public Camera MainCamera => _camera; public GameObject projectilePrefab; public Transform firePoint; + public Vector3 spawnPoint; - Camera _camera; - PlayerInput playerInput; - InputAction use, move, jump; + private Camera _camera; + private PlayerInput playerInput; + private InputAction use, move, jump; protected override void Awake() { @@ -37,7 +38,8 @@ namespace MontanaJohns.Actors base.Start(); GameObject loadedItem = (GameObject)Instantiate(Resources.Load("ActiveItems/Whip")); activeItem = loadedItem.GetComponent<Whip>(); - stats = baseStats + activeItem.stats; + ResetStats(); + spawnPoint = transform.position; } protected void Update() @@ -51,6 +53,23 @@ namespace MontanaJohns.Actors { base.Move(move.ReadValue<Vector2>().x); } + DeathCheck(); + } + + protected void DeathCheck() + { + if(health <= 0) + { + MainCamera.GetComponent<LevelController>().ResetLevel(); + ResetStats(); + health = stats.maxHealth; + transform.position = spawnPoint; + } + } + + protected void ResetStats() + { + stats = baseStats + activeItem.stats; } protected void Fire() |