Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class EnemyHealthManager : MonoBehaviour
- {
- public int enemyHealth; // How much health the enemy has
- public GameObject deathPartical;// Effect when enemy dies
- public int pointsForKillingEnemy; // Points to add when the enemy is killed
- // Start is called before the first frame update
- void Start()
- {
- }
- // Update is called once per frame
- void Update()
- {
- if (enemyHealth <= 0)
- {
- Instantiate(deathPartical, transform.position, transform.rotation); // Spawn the death effect
- ScoreManager.AddPoints(pointsForKillingEnemy); // Add points to score
- Destroy(gameObject); // Destroy the enemy
- }
- }
- public void giveDamage(int damageToGive)
- {
- enemyHealth -= damageToGive;
- GetComponent<AudioSource>().Play();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement