Compare commits
2 Commits
9ea333b529
...
4e128b7641
| Author | SHA1 | Date | |
|---|---|---|---|
| 4e128b7641 | |||
| 364ffc9a23 |
@@ -567,6 +567,7 @@ GameObject:
|
||||
- component: {fileID: 1872598832695960773}
|
||||
- component: {fileID: 1960184128864250160}
|
||||
- component: {fileID: 1781483820777133190}
|
||||
- component: {fileID: 8149587721611830724}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
m_TagString: Player
|
||||
@@ -606,7 +607,6 @@ MonoBehaviour:
|
||||
sprintSpeed: 10
|
||||
gravity: -9.81
|
||||
rotationSpeed: 10
|
||||
healthBar: {fileID: 4603696628922152095}
|
||||
--- !u!143 &1781483820777133190
|
||||
CharacterController:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -632,6 +632,21 @@ CharacterController:
|
||||
m_SkinWidth: 0.08
|
||||
m_MinMoveDistance: 0.001
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &8149587721611830724
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3653993672432327505}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1685f5c21ab4b2e418e35e5cf3e60864, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_maxHealth: 100
|
||||
_currentHealth: 100
|
||||
_healthText: {fileID: 4603696628922152095}
|
||||
--- !u!1 &4992829604954765258
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -11,9 +11,10 @@ GameObject:
|
||||
- component: {fileID: 1593526044607189551}
|
||||
- component: {fileID: 4260072969707999758}
|
||||
- component: {fileID: 8136388527997030937}
|
||||
- component: {fileID: 8002523264253901019}
|
||||
m_Layer: 0
|
||||
m_Name: Blob
|
||||
m_TagString: Untagged
|
||||
m_TagString: Enemy
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
@@ -88,6 +89,21 @@ MonoBehaviour:
|
||||
player: {fileID: 0}
|
||||
obstacleDetectionDistance: 1
|
||||
rotationSpeed: 5
|
||||
--- !u!114 &8002523264253901019
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2103289545128957355}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 1685f5c21ab4b2e418e35e5cf3e60864, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
_maxHealth: 100
|
||||
_currentHealth: 20
|
||||
_healthText: {fileID: 0}
|
||||
--- !u!1 &2485118932734020551
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
8
3D blobici/Assets/Scripts/HP.meta
Normal file
8
3D blobici/Assets/Scripts/HP.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 987db2b9503502740955897893550fde
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
60
3D blobici/Assets/Scripts/HP/Health Manager.cs
Normal file
60
3D blobici/Assets/Scripts/HP/Health Manager.cs
Normal file
@@ -0,0 +1,60 @@
|
||||
using UnityEngine;
|
||||
using TMPro;
|
||||
|
||||
public class HealthManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float _maxHealth = 100f;
|
||||
[SerializeField] private float _currentHealth = 100f;
|
||||
[SerializeField] private TMP_Text _healthText;
|
||||
|
||||
public float CurrentHealth { get => _currentHealth;}
|
||||
public float MaxHealth { get => _maxHealth; }
|
||||
|
||||
private void Start()
|
||||
{
|
||||
if(_healthText != null)
|
||||
_healthText.text = _currentHealth.ToString() + "/" + _maxHealth.ToString();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_healthText != null)
|
||||
_healthText.text = _currentHealth.ToString() + "/" + _maxHealth.ToString();
|
||||
|
||||
|
||||
// These are only for debugging!!!!
|
||||
if(Input.GetKeyDown(KeyCode.K))
|
||||
if(transform.tag == "Player")
|
||||
ModifyHealth(-10);
|
||||
|
||||
if(Input.GetKeyDown(KeyCode.L))
|
||||
ModifyHealth(10);
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
if(transform.tag == "Enemy")
|
||||
ModifyHealth(-50);
|
||||
}
|
||||
|
||||
public void ModifyHealth(float amount)
|
||||
{
|
||||
if (_currentHealth + amount > _maxHealth)
|
||||
{
|
||||
_currentHealth = _maxHealth;
|
||||
return;
|
||||
}
|
||||
if (_currentHealth + amount <= 0)
|
||||
{
|
||||
_currentHealth = 0;
|
||||
if (transform.tag == "Player")
|
||||
Debug.Log("Game over bastarde");
|
||||
else
|
||||
{
|
||||
Destroy(gameObject);
|
||||
Debug.Log("Character named " + gameObject.name + " died");
|
||||
}
|
||||
return;
|
||||
}
|
||||
_currentHealth += amount;
|
||||
}
|
||||
|
||||
}
|
||||
2
3D blobici/Assets/Scripts/HP/Health Manager.cs.meta
Normal file
2
3D blobici/Assets/Scripts/HP/Health Manager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1685f5c21ab4b2e418e35e5cf3e60864
|
||||
@@ -12,24 +12,15 @@ public class PlayerMovement : MonoBehaviour
|
||||
private CharacterController controller;
|
||||
private Vector3 velocity;
|
||||
private PlayerSkillTree PlayerSkills;
|
||||
private int health;
|
||||
private int maxHealth;
|
||||
[Header ("Health")]
|
||||
[SerializeField] private TMP_Text healthBar;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
PlayerSkills = PlayerSkillTree.Instance;
|
||||
maxHealth = PlayerSkills.MaxHealth;
|
||||
health = PlayerSkills.GetHealth();
|
||||
|
||||
Debug.Assert(maxHealth > 0);
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
controller = GetComponent<CharacterController>();
|
||||
healthBar.text = GetHealthText();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
@@ -50,17 +41,6 @@ public class PlayerMovement : MonoBehaviour
|
||||
Debug.Log("Potion not available!");
|
||||
}
|
||||
}
|
||||
|
||||
// TEMPORARY!!! LATER USED FOR COLISIONS
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.F))
|
||||
{
|
||||
PlayerSkills.SetHealth(-20);
|
||||
health = PlayerSkills.GetHealth();
|
||||
|
||||
healthBar.text = GetHealthText();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
@@ -116,9 +96,4 @@ public class PlayerMovement : MonoBehaviour
|
||||
{
|
||||
return PlayerSkills.GetPlayerSkills();
|
||||
}
|
||||
|
||||
private string GetHealthText()
|
||||
{
|
||||
return (health.ToString() + " / " + maxHealth.ToString());
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@
|
||||
"com.unity.collab-proxy": "2.6.0",
|
||||
"com.unity.feature.development": "1.0.2",
|
||||
"com.unity.multiplayer.center": "1.0.0",
|
||||
"com.unity.timeline": "1.8.8",
|
||||
"com.unity.timeline": "1.8.9",
|
||||
"com.unity.ugui": "2.0.0",
|
||||
"com.unity.modules.accessibility": "1.0.0",
|
||||
"com.unity.modules.ai": "1.0.0",
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
"url": "https://packages.unity.com"
|
||||
},
|
||||
"com.unity.timeline": {
|
||||
"version": "1.8.8",
|
||||
"version": "1.8.9",
|
||||
"depth": 0,
|
||||
"source": "registry",
|
||||
"dependencies": {
|
||||
|
||||
@@ -5,6 +5,7 @@ TagManager:
|
||||
serializedVersion: 3
|
||||
tags:
|
||||
- Walls
|
||||
- Enemy
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
|
||||
Reference in New Issue
Block a user