Advertisement
rodrigofbm

HudEnemy

Jul 4th, 2015
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.81 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3. using UnityEngine.UI;
  4.  
  5. public class HudEnemy : MonoBehaviour {
  6.     public Image imagem;
  7.     private Player player;
  8.     public GameObject[] enemies;
  9.  
  10.  
  11.  
  12.     // Use this for initialization
  13.     void Start () {
  14.         imagem = gameObject.GetComponent<Image> ();
  15.         enemies = GameObject.FindGameObjectsWithTag("Inimigo");
  16.         player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player> ();
  17.  
  18.  
  19.  
  20.     }
  21.    
  22.     // Update is called once per frame
  23.     void Update () {
  24.         if (player.atacando) {
  25.             for (int i = 0; i < enemies.Length; i++)
  26.             {
  27.                 if (enemies[i].GetComponent<Inimigo>())
  28.                 {
  29.                     if(Vector3.Distance(enemies[i].transform.position, player.transform.position) <3){
  30.                     imagem.fillAmount = enemies[i].GetComponent<Inimigo>().mana;
  31.                     }
  32.            
  33.                 }
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement