Game UI ready
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
using System.Collections;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine;
|
||||
using VContainer;
|
||||
|
||||
@@ -9,35 +11,34 @@ public class Player : MonoBehaviour, IPlayer
|
||||
[SerializeField] private Transform splashParent;
|
||||
[SerializeField] private ParticleSystem deadParticle;
|
||||
[SerializeField] private ParticleSystem jumpParticle;
|
||||
[SerializeField] private CinemachineImpulseSource cinemachineImpulseSource;
|
||||
|
||||
public bool isDead { get; private set; }
|
||||
|
||||
|
||||
[Inject] private IInputReader inputReader;
|
||||
[Inject] private DeathScreenController deathScreenController;
|
||||
[Inject] private IDeathScreenController IdeathScreenController;
|
||||
[Inject] private IInputReader IinputReader;
|
||||
[Inject] private IAudioController IaudioController;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
isDead = false;
|
||||
}
|
||||
|
||||
|
||||
private void OnCollisionEnter(Collision collision)
|
||||
{
|
||||
ShowAndHideSplash(collision);
|
||||
if(isDead) return;
|
||||
|
||||
if (collision.gameObject.CompareTag("Safe"))
|
||||
if (collision.gameObject.CompareTag("Safe") && rb.linearVelocity.y <=0.5f)
|
||||
{
|
||||
rb.linearVelocity = Vector3.up * jumpForce;
|
||||
jumpParticle.Play();
|
||||
IaudioController.PlayJumpSound();
|
||||
}
|
||||
else if(collision.gameObject.CompareTag("Death"))
|
||||
{
|
||||
isDead = true;
|
||||
deadParticle.Play();
|
||||
this.GetComponent<Renderer>().enabled = false;
|
||||
inputReader.blockedInput = true;
|
||||
deathScreenController.ShowDeathScreen();
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +48,26 @@ public class Player : MonoBehaviour, IPlayer
|
||||
ContactPoint contact = collision.contacts[0];
|
||||
Vector3 surfacePoint = new Vector3(contact.point.x, splashYPos, contact.point.z);
|
||||
GameObject instancedSplash = Instantiate(splashObject, surfacePoint, splashObject.transform.rotation, splashParent);
|
||||
instancedSplash.transform.localScale = new Vector3(Random.Range(0.08f, 0.1f), Random.Range(0.08f, 0.1f),1);
|
||||
Destroy(instancedSplash, 2f);
|
||||
}
|
||||
private void Die()
|
||||
{
|
||||
isDead = true;
|
||||
IinputReader.LockInput();
|
||||
deadParticle.Play();
|
||||
this.GetComponent<Renderer>().enabled = false;
|
||||
IaudioController.PlayDeathSound();
|
||||
Handheld.Vibrate(); //Vibration
|
||||
cinemachineImpulseSource.GenerateImpulseWithForce(1);
|
||||
StartCoroutine(DieRoutine());
|
||||
}
|
||||
|
||||
IEnumerator DieRoutine()
|
||||
{
|
||||
yield return new WaitForSeconds(1f);
|
||||
IdeathScreenController.ShowDeathScreen();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IPlayer
|
||||
|
||||
Reference in New Issue
Block a user