added sounds
This commit is contained in:
@@ -1,31 +1,43 @@
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
public class Player : MonoBehaviour
|
||||
public class Player : MonoBehaviour, IPlayer
|
||||
{
|
||||
[SerializeField] private float jumpForce = 1f;
|
||||
[SerializeField] private float jumpForce = 3f;
|
||||
[SerializeField] private Rigidbody rb;
|
||||
[SerializeField] private GameObject splashObject;
|
||||
[SerializeField] private Transform splashParent;
|
||||
public bool isDead = false;
|
||||
public ParticleSystem deadParticle;
|
||||
[SerializeField] private ParticleSystem deadParticle;
|
||||
[SerializeField] private ParticleSystem jumpParticle;
|
||||
|
||||
public bool isDead { get; private set; }
|
||||
|
||||
|
||||
[Inject] private IInputReader inputReader;
|
||||
[Inject] private DeathScreenController deathScreenController;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
isDead = false;
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
ShowAndHideSplash(collision);
|
||||
if (collision.gameObject.CompareTag("Safe") && !isDead)
|
||||
if(isDead) return;
|
||||
|
||||
if (collision.gameObject.CompareTag("Safe"))
|
||||
{
|
||||
rb.linearVelocity = Vector3.up * jumpForce;
|
||||
jumpParticle.Play();
|
||||
}
|
||||
else if(collision.gameObject.CompareTag("Death"))
|
||||
{
|
||||
isDead = true;
|
||||
deadParticle.Play();
|
||||
this.GetComponent<Renderer>().enabled = false;
|
||||
inputReader.blockedInput = true;
|
||||
inputReader.blockedInput = true;
|
||||
deathScreenController.ShowDeathScreen();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,3 +50,8 @@ public class Player : MonoBehaviour
|
||||
Destroy(instancedSplash, 2f);
|
||||
}
|
||||
}
|
||||
|
||||
public interface IPlayer
|
||||
{
|
||||
bool isDead { get; }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user