Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Enemy : MonoBehaviour
- {
- protected int health;
- protected GameObject player;
- protected int damage;
- private bool isDead;
- public void ChangeHealth(int hp)
- {
- health += hp;
- if(hp<=100)
- 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