Skip to content

Commit

Permalink
Merge pull request #44 from ES2-UFPI/eryckkawa#30
Browse files Browse the repository at this point in the history
Finalizado sistema de dano
  • Loading branch information
marcio-leal authored Jul 16, 2024
2 parents 9c54737 + 899d013 commit e638b33
Show file tree
Hide file tree
Showing 6 changed files with 94 additions and 6 deletions.
11 changes: 5 additions & 6 deletions Assets/Scenes/Torre - Felipe.unity
Original file line number Diff line number Diff line change
Expand Up @@ -12486,11 +12486,6 @@ Transform:
m_CorrespondingSourceObject: {fileID: 1149450743610261583, guid: dc02f77b0506f764c9d22c61c681c4af, type: 3}
m_PrefabInstance: {fileID: 1746705694}
m_PrefabAsset: {fileID: 0}
--- !u!4 &1762591494 stripped
Transform:
m_CorrespondingSourceObject: {fileID: 6433677090840053048, guid: 19126af9e3b37894aa7f8924b2916d27, type: 3}
m_PrefabInstance: {fileID: 2135270840}
m_PrefabAsset: {fileID: 0}
--- !u!1001 &1781144544
PrefabInstance:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -15355,7 +15350,11 @@ PrefabInstance:
- target: {fileID: 613842560230377664, guid: 19126af9e3b37894aa7f8924b2916d27, type: 3}
propertyPath: interactorSource
value:
objectReference: {fileID: 1762591494}
objectReference: {fileID: 1487666422}
- target: {fileID: 3122378250214386190, guid: 19126af9e3b37894aa7f8924b2916d27, type: 3}
propertyPath: gameInput
value:
objectReference: {fileID: 1606203397}
- target: {fileID: 4793283505566672030, guid: 19126af9e3b37894aa7f8924b2916d27, type: 3}
propertyPath: player
value:
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/Consumables.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Assets/Scripts/Consumables/HealthOrb.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HealthOrb : MonoBehaviour
{
[SerializeField] private float restoreAmount = 20f;

private void OnTriggerEnter(Collider other)
{
PlayerStatus playerStatus = other.GetComponent<PlayerStatus>();
if (playerStatus != null)
{
playerStatus.RestoreHealth(restoreAmount);
Destroy(gameObject);
}
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Consumables/HealthOrb.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions Assets/Scripts/Player/PlayerStats.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerStatus : MonoBehaviour
{
[SerializeField] private float playerHealth = 100f; // Valor inicial da saúde do jogador
[SerializeField] private float damagePlayer = 10f; // Dano causado pelo jogador

private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
TakeDamage(damagePlayer);
}
}

public void TakeDamage(float damage)
{
playerHealth -= damage;
Debug.Log($"Player took {damage} damage. Current health: {playerHealth}");

if (playerHealth <= 0)
{
Debug.Log("Player has died!");
}
}

public void RestoreHealth(float health)
{
playerHealth += health;

if (playerHealth > 100f)
{
playerHealth = 100f;
}

Debug.Log($"Player restored {health} health. Current health: {playerHealth}");
}

}
11 changes: 11 additions & 0 deletions Assets/Scripts/Player/PlayerStats.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e638b33

Please sign in to comment.