Änderungen am 12.02.2025 getroffen.
This commit is contained in:
38
Assets/Scripts/Health.cs
Normal file
38
Assets/Scripts/Health.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
/// <summary>
|
||||
/// Link zum OG Script: https://www.youtube.com/watch?v=vNL4WYgvwd8
|
||||
/// </summary>
|
||||
public class Health : MonoBehaviour
|
||||
{
|
||||
public int maxHealth = 5;
|
||||
public int currentHealth = 5;
|
||||
public Image healthbar;
|
||||
|
||||
// health logic
|
||||
void Start()
|
||||
{
|
||||
currentHealth = maxHealth;
|
||||
}
|
||||
|
||||
// take dmg logic
|
||||
private void Update()
|
||||
{
|
||||
TakeDamage();
|
||||
}
|
||||
|
||||
void TakeDamage()
|
||||
{
|
||||
healthbar.fillAmount = (float)currentHealth / (float)maxHealth;
|
||||
|
||||
if (currentHealth <= 0)
|
||||
{
|
||||
// player is dead
|
||||
// death animation
|
||||
// game over screen
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/Health.cs.meta
Normal file
11
Assets/Scripts/Health.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abeb25a7ebccdd549a934791ddc6ca61
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7851c49aa5f61d14eaa1b7262e877d63
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user