//Pendiente //IGameEntity gameEntity; public override void Awake() { base.Awake(); entity = GetComponent <IGameEntity>(); currentlySelected = false; controller = GameObject.Find("GameController"); player = controller.GetComponent <Player>(); _collider = GetComponent <Collider>(); selectedRect = SelectionOverlay.CalculateBox(_collider); }
/// <summary> /// Adjust the texture initally, needed for the buildings /// </summary> public void AdjustTexture() { selectedRect = SelectionOverlay.CalculateBox(_collider); Vector3 position = this.gameObject.transform.position; position.y = _collider.bounds.max.y + (_collider.bounds.size.y * .5f); // move the plane a little bit from the center plane.transform.position = position; // rotate the plain to its original position plane.transform.rotation = _LifeBarDefaultRotation; }
protected virtual void LateUpdate() { // only updates the texture if there's been a change in the healthy -> improves quite a lot the results in the profiler inspector if (_lastHealth != entity.healthPercentage) { _lastHealth = entity.healthPercentage; healthRatio = _lastHealth / 100f; SelectionOverlay.UpdateTexture(plane, selectedBox, healthRatio); } if (_attackedEntity || (currentlySelected && entity.info.isUnit)) { selectedRect = SelectionOverlay.CalculateBox(_collider); Vector3 position = this.gameObject.transform.position; position.y = _collider.bounds.max.y + (_collider.bounds.size.y * .5f); // move the plane a little bit from the center plane.transform.position = position; // rotate the plain to its original position plane.transform.rotation = _LifeBarDefaultRotation; if (!_selectionVisible) { plane.SetActive(true); _selectionVisible = true; } } else { if (_selectionVisible) { plane.SetActive(false); _selectionVisible = false; } } }