Skip to content

Commit

Permalink
added images of each body part, put them as one body in the UI HUD, s…
Browse files Browse the repository at this point in the history
…tarted modifying BodyDamageScript, still need to link it to player character object
  • Loading branch information
soulsyrup committed Jan 3, 2024
1 parent acfe12f commit 345ce10
Show file tree
Hide file tree
Showing 21 changed files with 1,174 additions and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public class AdrenalineTrigger : MonoBehaviour
private float adrenalineLevel = 0f;
public float adrenalineTriggerThreshold = 20f; // Threshold for adrenaline boost
public Image adrenalineBar;
HealthRegeneration healthScript;
private HealthRegeneration healthScript;

private void Start()
{
Expand All @@ -15,7 +15,7 @@ private void Start()

private void Update()
{
if (healthScript.currentHealth <= adrenalineTriggerThreshold && adrenalineLevel < 100f)
if (healthScript.GetCurrentHealth() <= adrenalineTriggerThreshold && adrenalineLevel < 100f)
{
adrenalineLevel += Time.deltaTime * 50f; // Increase adrenaline
UpdateAdrenalineBar();
Expand All @@ -29,9 +29,9 @@ private void Update()

private void UpdateAdrenalineBar()
{
if(adrenalineBar != null)
if (adrenalineBar != null)
{
adrenalineBar.fillAmount = adrenalineLevel / 100f;
}
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
using UnityEngine;
using UnityEngine.InputSystem;



public class CharacterMain : MonoBehaviour
{
private bool isJumping;
private bool isWalking;
public float movementSpeed = 5f;
private Vector2 moveInput;




[SerializeField] private string charName; // GameObject will NOT be player's name - this will.
[SerializeField] private Health health; // Useless for now.

private void Start()
{

}

private void Update()
{
//OnMove;
transform.Translate(new Vector3(moveInput.x, 0, moveInput.y) * movementSpeed * Time.deltaTime);

}

private void OnMove(InputValue value)
{

moveInput = value.Get<Vector2>();
/*
private void Update()
{
HandleMovement();
Move();
}
private void Move(InputAction context)
{
if(context != null)
{
moveInput = context.ReadValue<Vector2>();
}
}
private void HandleMovement()
{
// Calculate movement direction based on input
Vector3 moveDirection = new Vector3(moveInput.x, 0f, moveInput.y).normalized;
// Check if the player is walking
isWalking = moveDirection.magnitude > 0;
// Move the character using the CharacterController
characterController.Move(moveDirection * movementSpeed * Time.deltaTime);
}
*/
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using Unity.Netcode;

public class Health: NetworkBehaviour
{
// ***Network Checks*** All network calls and references are made in the Limb script and anything calling to this Class. This prevents unneccessary checks on our part.

// ***At this spot*** I need to make a reference to any other Transforms we may need to call upon for references. Ex: Animators, Armors, Augmentations, UI, etc.

private float healthMain; // Our primary Health, enough hits to everything else and we bleed out.
private float healthMax; // The maximum Health allowed. This value allows it to be upgraded.
private float staminaMain; // See above, but with Stamina.
private float staminaMax; // Self explanatory.
private float adrenaline; // Adrenaline drive, given during moments of low health for those "Oh shit" moments.
private float cyberHealth; // Seperate from healthMain, this variable controls overall mental health - Get low enough, physical damage may occur! Warranty not included.
private float armorHealth; // Probably just gonna Transform.GetComponent this from the actual armor item. Might make this to each limb as well. For now, mundane stuff!

public enum BodyPart
{
Head,
Chest,
LeftArm,
RightArm,
LeftLeg,
RightLeg
}

public enum Toxicity // I'm running this as an enum for now, it may be split in to seperate variables - Just did this so I can possibly have other factors later.
{
Bio,
Psych,
Radiation
}


private Dictionary<BodyPart, float> bodyPartHealth = new Dictionary<BodyPart, float>();
private Dictionary<Toxicity, float> toxicBar = new Dictionary<Toxicity, float>(); // This will be our dictionary for the toxicity meters.

// Augmentations will be in another MonoBehavior, I don't feel like including them in this one, mainly for sake of compile and run time. - Sona

private void Start()
{
InitializeHealth();
Debug.Log("Health behavior on " + this.gameObject + " has been activated."); // I just like knowing the script is functioning.
}

public void InitializeHealth() // Bodypart floats are counted as a 1-100 float value. They can be increased, but it will need to be handled outside the script for cleanliness.
{
// if (!isLocalPlayer) return;

bodyPartHealth[BodyPart.Head] = 100f;
bodyPartHealth[BodyPart.Chest] = 100f;
bodyPartHealth[BodyPart.LeftArm] = 100f;
bodyPartHealth[BodyPart.RightArm] = 100f;
bodyPartHealth[BodyPart.LeftLeg] = 100f;
bodyPartHealth[BodyPart.RightLeg] = 100f;
}

public void InitializeToxicBar() // Load the meters up and zero them out, we'll get the values later from the server.
{
// if (!isLocalPlayer) return;

toxicBar[Toxicity.Bio] = 0f;
toxicBar[Toxicity.Psych] = 0f;
toxicBar[Toxicity.Radiation] = 0f;
}

public void DamageArmor(float D) // Private so that this function must be special called by a referencing script. I'll network this soon to test for lag.
{
if (D <= 0) return;
else
{
armorHealth -= D;
if(armorHealth <= 0)
{
armorHealth = 0;
Debug.Log("Armor on " + this.gameObject + " has been destroyed beyond repair!");
}
}
}

public void DamagePlayer(float D, BodyPart bodyPart) // D to call for the damage float, X will probably reference a body part in the future.
{
if(bodyPartHealth.ContainsKey(bodyPart))
{
if(D > 0)
{
bodyPartHealth[bodyPart] -= D;
healthMain -= D / bodyPartHealth[bodyPart] * 2;
}
}
PlayerStatus();
}

private void PlayerStatus() // Let's check on player's status, their limbs, etc.
{
// To further elaborate, healing and whatnot can be handled by an item's script - and it can reference this one.
// Right now, none of these check for the armor status - Which, I'll probably give them a bonus to health from the armor anyway. Maybe.

if (bodyPartHealth.ContainsKey(BodyPart.Head) && bodyPartHealth[BodyPart.Head] <= 0) // Let's be honest. Head Health being 0 means they are dead.
{
Debug.Log("Should get your head looked at, it's missing!");
}
if (bodyPartHealth.ContainsKey(BodyPart.LeftLeg) && bodyPartHealth[BodyPart.LeftLeg] <= 0)
{
Debug.Log("My leg!");
}
if (bodyPartHealth.ContainsKey(BodyPart.LeftArm) && bodyPartHealth[BodyPart.LeftArm] <= 0)
{
Debug.Log("Look! No hands!");
}
if (bodyPartHealth.ContainsKey(BodyPart.RightArm) && bodyPartHealth[BodyPart.RightArm] <= 0)
{
Debug.Log("Look! No hands!");
}
if (bodyPartHealth.ContainsKey(BodyPart.RightLeg) && bodyPartHealth[BodyPart.RightLeg] <= 0)
{
Debug.Log("My leg!");
}
InitializeHealth();

}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.InputSystem;

public class Settings : MonoBehaviour
{

// Dirty settings. Clean up later.
[Header("Menu State")] // What is going on with our menu, is it visible? Invisible? Do I need to BLOW IT UP? Shown here.
[SerializeField] private bool _menuActive;

[Space]
[Header("Game State")]
[SerializeField] private bool gamePaused; // Probably has no use. I don't know if this is an MMO or Single-Player anymore.

[Space]
[Space]
[Header("UI Theme")] // No, I'm not making specialized themes right now - This is just to hold the settings for appearance so I don't have to do it again later. Add onto as needed.
[Space]
[SerializeField] private GameObject _menuBackground;
[Space]
[Space]
[Header("Settings")]
[Space]

[SerializeField] private Slider _MusicVol;
[SerializeField] private Slider _MasterVol;
[SerializeField] private Slider _AtmosVol;
[SerializeField] private Button _btnApply;
[SerializeField] private Button _btnCancel;

private void Start()
{
if (!_menuBackground) this.enabled = false; // Prevent bugs if we don't have the UI active or set.
}

private void Update()
{
if (Keyboard.current.escapeKey.wasPressedThisFrame)
{
EscapeKeyPressed();
}
}

private void EscapeKeyPressed()
{
_menuActive = !_menuActive;
PauseMenu(); // References because script time.
}

private void PauseMenu()
{
if(_menuActive) _menuBackground.SetActive(true);
if(!_menuActive) _menuBackground.SetActive(false);
}

private void CancelButton()
{
_menuActive = false;
PauseMenu();
}

private void ApplyButton()
{
// I do nothing right now :D!!!
}

// Music/Master will come after have some atmospheric sounnds / music to work with - as it involves me working with an audio mixer.

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using UnityEngine;
using UnityEngine.UI;

public class ThirstMeter : MonoBehaviour
{
public float maxThirst = 100f;
private float currentThirst;
public Image thirstBar;

void Start()
{
currentThirst = maxThirst;
UpdateThirstBar();
}

void Update()
{
// Decrease thirst over time or based on player actions
currentThirst = Mathf.Clamp(currentThirst, 0, maxThirst);
UpdateThirstBar();
}

public void ConsumeWater(float amount)
{
currentThirst += amount;
currentThirst = Mathf.Clamp(currentThirst, 0, maxThirst);
UpdateThirstBar();
}

private void UpdateThirstBar()
{
if (thirstBar != null)
{
thirstBar.fillAmount = currentThirst / maxThirst;
}
}
}

Loading

0 comments on commit 345ce10

Please sign in to comment.