This repository has been archived on 2024-11-28. You can view files and clone it, but cannot push or open issues or pull requests.
PMC_Projekt/ProjektUnity/Assets/Scripts/Enemy/EnemyStats.cs

39 lines
975 B
C#
Raw Normal View History

2024-09-05 11:46:56 +02:00
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemyStats : MonoBehaviour
{
public Enemy enemy;
public float health = 0;
public float speed = 0;
public float damage = 0;
2024-09-05 11:46:56 +02:00
private void Start() {
health = enemy.getCurrentHealth();
speed = enemy.getCurrentSpeed();
damage = enemy.getDamage();
2024-09-05 11:46:56 +02:00
}
//Für Später
private void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.CompareTag("Bullet")){
BulletScript bulletScript = other.gameObject.GetComponent<BulletScript>();
health -= bulletScript.weapon.getDamage();
2024-09-05 11:46:56 +02:00
if (health <= 0)
{
Destroy(this.gameObject);
}
} else if(other.gameObject.CompareTag("Player")){
speed = 0f;
2024-09-05 11:46:56 +02:00
}
}
private void OnTriggerExit2D(Collider2D other) {
speed = enemy.getCurrentSpeed();
}
2024-09-05 11:46:56 +02:00
}