40 lines
976 B
C#
40 lines
976 B
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
//Marvin Schneider
|
|
public class EnemyStats : MonoBehaviour
|
|
{
|
|
public Enemy enemy;
|
|
public float health = 0;
|
|
public float speed = 0;
|
|
public float damage = 0;
|
|
|
|
private void Start() {
|
|
health = enemy.getCurrentHealth();
|
|
speed = enemy.getCurrentSpeed();
|
|
damage = enemy.getDamage();
|
|
}
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D other) {
|
|
if (other.gameObject.CompareTag("Bullet")){
|
|
BulletScript bulletScript = other.gameObject.GetComponent<BulletScript>();
|
|
health -= bulletScript.weapon.getDamage();
|
|
|
|
if (health <= 0)
|
|
{
|
|
Destroy(this.gameObject);
|
|
}
|
|
|
|
} else if(other.gameObject.CompareTag("Player")){
|
|
speed = 0f;
|
|
}
|
|
}
|
|
|
|
private void OnTriggerExit2D(Collider2D other) {
|
|
speed = enemy.getCurrentSpeed();
|
|
}
|
|
}
|