// Update is called once per frame void FixedUpdate() { ZoneBehaviour zoneBehaviour = transform.parent.parent.GetComponent <ZoneBehaviour>(); float timer = zoneBehaviour.captureTimer; float maxTimer = zoneBehaviour.captureDuration; int teamInArea = zoneBehaviour.getTeamInArea(); if (timer == .0f) { width = .0f; } else { width = timer / maxTimer; width = 1 - width; width *= maxWidth; } if (width < .0f) { width = .0f; } if (width > maxWidth) { width = maxWidth; } rt.sizeDelta = new Vector2(width, maxHeight); setUIColor(teamInArea); }
// TODO implement increazing the size of the map. /// <summary> /// Validate if the NavMeshObstacle can be placed unto the map. /// </summary> /// <param name="obstacle">The obstacle of the map.</param> /// <param name="worldPosition">The origin of where we want to place the object in world position.</param> /// <returns>Returns true if the origin position is valid, false if not.</returns> public bool IsPositionValid(Obstacle obstacle, ZoneBehaviour zoneBehaviour) { if (GetObstacleOriginRelativeToMap(this, zoneBehaviour.transform.position, obstacle, out Vector2Int relativePosition)) { return(IsPositionValid(relativePosition, GetSizeFromObstacle(obstacle))); } return(false); }
/// <summary> /// Draw a rectangle on the map from an actual object. /// </summary> /// <param name="obstacle">The obstacle to draw a rectangle for.</param> /// <param name="zoneBehaviour">The zone where to draw the rectangle.</param> /// <param name="color">The color to represent on the map.</param> public void DrawRectangle(Obstacle obstacle, ZoneBehaviour zoneBehaviour, Color color) { if (GetObstacleOriginRelativeToMap(this, zoneBehaviour.transform.position, obstacle, out Vector2Int relativePosition)) { DrawRectangle(relativePosition, GetSizeFromObstacle(obstacle), color); } else { Debug.LogError("Couldn't draw the rectangle."); } }
public void SetCurrentZone(int index) { if (index == 0) { CurrentZone = AllZones[index]; CurrentZone.isActive = true; CurrentZone.SpawnEnemies(); } if (CurrentZone.isFinish) { CurrentZone = AllZones[index]; CurrentZone.isActive = true; CurrentZone.gameObject.GetComponent <TriggerBehaviour>().enabled = true; CurrentZone.SpawnEnemies(); } }
private void Awake() { col = GetComponent <Collider>(); if (instance == null) { instance = this; } else { Destroy(gameObject); } for (int i = 0; i < LevelData.instance.mainObjectives.Length; i++) { if (LevelData.instance.mainObjectives[i].type == ObjectiveType.PositionChild) { return; } } Destroy(gameObject); }
public virtual void RegisterZone(ZoneBehaviour zoneBehaviour) { Debug.Log("Registering: " + zoneBehaviour + " has the zone where the object is: " + this.name); ZoneBehaviours.Push(zoneBehaviour); }