public static void RemoveEntity(LOSEntity entity) { if (Instance != null) { Instance.Entities.Remove(entity); } }
// Allow entities to tell us when theyre added public static void AddEntity(LOSEntity entity) { if (Instance != null && !Instance.Entities.Contains(entity)) { Instance.Entities.Add(entity); } }
// Use this for initialization void Start() { if (GetComponent<Identity>().unitType.isBuilding()) { //GetComponent<Health>().setHealth(50); //GetComponent<Health>().setMaxHealth(50); //GetComponent<Health>().setAuxHealth(50); auxMaxHealth = GetComponent<BuildingConstruction>().timer; maxHealth = MapValues(auxMaxHealth, 0, auxMaxHealth, GetComponent<Health>().getMaxHealth() / 10, GetComponent<Health>().getMaxHealth()); curHealth = MapValues(auxMaxHealth - GetComponent<BuildingConstruction>().timer, 0, auxMaxHealth, GetComponent<Health>().getMaxHealth() / 10, GetComponent<Health>().getMaxHealth()); } else { maxHealth = GetComponent<Health>().getMaxHealth(); curHealth = GetComponent<Health>().getHealth(); } g = Instantiate(prefab); g.transform.SetParent(GameController.Instance.healthBarsParent.transform); g.transform.GetChild(0).transform.position = Camera.main.WorldToScreenPoint(GetComponentInChildren<auxHealth>().gameObject.transform.position); g1 = g.GetComponentInChildren<auxHealth>().gameObject; visualHealth = g.GetComponentInChildren<auxHealth>().i; unitLOSEntity = gameObject.GetComponent<LOSEntity>(); }
// Reveal an area private void RevealLOS(LOSEntity sight, float los, float fow, float grayscale) { Rect rect = sight.Bounds; RevealLOS(rect, sight.Range, sight.Height + sight.transform.position.y, los, fow, grayscale); }
public static void RemoveEntity(LOSEntity entity) { if (Instance != null) { Instance.Entities.Remove(entity); if (Instance.AnimatingEntities.Contains(entity) == true) Instance.AnimatingEntities.Remove(entity); } }
// Allow entities to tell us when theyre added public static void AddEntity(LOSEntity entity) { if (Instance != null && !Instance.Entities.Contains(entity)) Instance.Entities.Add(entity); }
public static void RemoveEntity(LOSEntity entity) { if (Instance != null) Instance.Entities.Remove(entity); }
// Update is called once per frame void Update() { if (LOSinactive != losMan.revealed) { LOSinactive = losMan.revealed; reveal(); } if (!LOSinactive) { if (los == null) { los = GetComponentInParent<LOSEntity>(); if (los != null) { revealState = los.RevealState; newState(); } } else { { if (revealState != los.RevealState) { revealState = los.RevealState; newState(); } } } } }
/*** Metodes per defecte de Unity ***/ protected virtual void Awake() { audio = gameObject.AddComponent<AudioSource> (); audio.volume = 0.4f; rigbody = gameObject.AddComponent<Rigidbody> (); rigbody.constraints = RigidbodyConstraints.FreezeAll; ent = gameObject.AddComponent<LOSEntity> (); objectIconSprite = Resources.Load<Sprite> ("HUD/ObjectIcons/" + GetType ().ToString ()); objectIconAttack = Resources.Load<Sprite> ("HUD/Unit/AttackStrengthIcon"); objectIconDefense = Resources.Load<Sprite> ("HUD/Unit/DefenseIcon"); objectIconAttackRange = Resources.Load<Sprite> ("HUD/Unit/AttackRangeIcon"); objectIconResource = Resources.Load<Sprite> ("HUD/Unit/Resource"); }