added GUI and pausing and finished death

This commit is contained in:
2023-04-22 03:18:21 -04:00
parent c4094b169c
commit 52de70fcb1
56 changed files with 11739 additions and 3314 deletions

View File

@ -4,6 +4,7 @@ using System.Runtime.CompilerServices;
using System.Threading;
using UnityEngine;
public class CameraController : MonoBehaviour
{
@ -26,7 +27,7 @@ public class CameraController : MonoBehaviour
[SerializeField]
private bool isChild = false;
// Start is called before the first frame update
@ -52,8 +53,8 @@ public class CameraController : MonoBehaviour
//transform.Rotate(0, mouseX * Time.deltaTime * 180f, 0);
//cam.transform.parent.parent.transform.Rotate(mouseY * Time.deltaTime * 180f, 0, 0);
Cursor.visible = false;
Cursor.lockState = CursorLockMode.Locked;
//Cursor.visible = false;
//Cursor.lockState = CursorLockMode.Locked;
}

View File

@ -2,6 +2,7 @@ using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
using TMPro;
public class PlayerComponent : MonoBehaviour
@ -33,6 +34,9 @@ public class PlayerComponent : MonoBehaviour
private float knockbackDuration = 1f;
[SerializeField]
private float knockbackDistance = 5f;
[SerializeField]
private StatsOutputScreen statsOutput;
[HideInInspector]
public bool IsAlive { get { return this.health > 0; } }
private void Awake()
@ -49,6 +53,9 @@ public class PlayerComponent : MonoBehaviour
void Update()
{
NoiseManager.SetRunning(MovementController.IsRunning);
statsOutput.health = this.health;
statsOutput.stamina = 20f;
statsOutput.oxygen = 100f;
if (shakeTimer > 0)
{
@ -62,6 +69,11 @@ public class PlayerComponent : MonoBehaviour
perlin.m_AmplitudeGain = 0;
}
}
if (!IsAlive)
{
PlayerInteractionHandler.instance.isDead = true;
movementController.isDead = true;
}
}

View File

@ -40,9 +40,11 @@ public class PlayerInteractionHandler : MonoBehaviour
private PistolComponent pistol;
[SerializeField]
private NoiseVisibilitySettingsManager noiseManager;
private InGameManager manager;
public bool isDead = false;
// Start is called before the first frame update
void Start()
{
@ -56,6 +58,7 @@ public class PlayerInteractionHandler : MonoBehaviour
itemSelector = ItemSelector.instance;
pistol.gameObject.SetActive(this.gunEnabled);
flashlightEnabled = this.flashlight.gameObject.activeSelf;
manager = GameObject.FindObjectOfType<InGameManager>();
}
private bool receiverInRange(out int index)
@ -77,7 +80,10 @@ public class PlayerInteractionHandler : MonoBehaviour
void Update()
{
if (manager.IsPaused||isDead)
{
return;
}
if(Input.GetButtonDown("Fire1"))
{

View File

@ -1,6 +1,7 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Cinemachine;
public class PlayerMovementController : MonoBehaviour
{
@ -37,7 +38,7 @@ public class PlayerMovementController : MonoBehaviour
[SerializeField]
private NoiseVisibilitySettingsManager noiseSettings;
private InGameManager manager;
public float NoiseDistance { get { return this.noiseSettings.NoiseDistance; } }
@ -46,11 +47,19 @@ public class PlayerMovementController : MonoBehaviour
private Vector3 lookingDirectionVector;
private bool movementLocked = false;
[SerializeField]
private CinemachineFreeLook freelook;
[SerializeField]
private string mouseXAxis = "Mouse X";
[SerializeField]
private string mouseYAxis = "Mouse Y";
public bool isDead = false;
private void GetMovementOld()
{
x = Input.GetAxis("Horizontal");
y = Input.GetAxis("Vertical");
if (movementLocked)
if (movementLocked||manager.IsPaused)
{
x = 0;
y = 0;
@ -82,12 +91,13 @@ public class PlayerMovementController : MonoBehaviour
void Start()
{
ccForceAddon = ccontroller.gameObject.GetComponent<CharacterControllerForce>();
manager = GameObject.FindObjectOfType<InGameManager>();
}
// Update is called once per frame
void Update()
{
if(isDead) return;
AllowRotation = Input.GetMouseButton(1) || Input.GetAxis("Aim")>0.5f;
GetMovementOld();
MovePlayer();
@ -105,7 +115,11 @@ public class PlayerMovementController : MonoBehaviour
SlowLookAt(this.lookingDirectionVector);
}
freelook.m_XAxis.m_InputAxisName = !manager.IsPaused ? this.mouseXAxis : "";
freelook.m_YAxis.m_InputAxisName = !manager.IsPaused ? this.mouseYAxis : "";
}

View File

@ -0,0 +1,60 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class StatsOutputScreen : MonoBehaviour
{
[SerializeField]
private TMP_Text healthText;
[SerializeField]
private TMP_Text staminaText;
[SerializeField]
private TMP_Text oxygenText;
[HideInInspector]
public float health = 0;
[HideInInspector]
public float stamina = 0;
[HideInInspector]
public float oxygen = 0;
private Color initColor;
// Start is called before the first frame update
void Start()
{
initColor = healthText.color;
InvokeRepeating("ToggleColor", 0.5f, 0.5f);
}
// Update is called once per frame
void Update()
{
healthText.text = "Health:" + health.ToString();
if (health <= 1)
{
//Dark Red
healthText.color = new Color(50,0,0);
}
else if (health <=3)
{
healthText.color = Color.red;
}
else
{
healthText.color = initColor;
}
staminaText.text = "Stamina:" + stamina.ToString();
oxygenText.text = "Oxygen:"+oxygen.ToString();
}
private void ToggleColor()
{
if(health<=1)
healthText.gameObject.SetActive(!healthText.gameObject.activeSelf);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: de7389d71ec7803409f26fc6407bc153
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: