Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using BossFightGame.Scripts;
- using UnityEngine;
- public class Enemy : MonoBehaviour
- {
- public HealthSystem healthSystem = new HealthSystem(100);
- protected GameObject player;
- protected int damage;
- private bool isDead;
- void Start()
- {
- healthSystem.onHealthChanged += OnHealthChanged;
- }
- private void OnHealthChanged(int i)
- {
- if (i <= 0)
- {
- Death();
- }
- }
- public virtual void Move() { }
- public virtual void Attack() { }
- private void Death()
- {
- isDead = true;
- GetComponent<Animator>().SetBool("death", isDead);
- GetComponent<Enemy>().enabled = false;
- }
- private void Awake()
- {
- player = FindObjectOfType<PlayerController>().gameObject;
- }
- void Update()
- {
- if (player == null)
- return;
- if (!isDead)
- {
- Move();
- Attack();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement