/// <summary> /// Call this when the turn switch to update the ground hazards and apply effects /// </summary> /// <param name="player"> True for player turn </param> public IEnumerator UpdateNewTurnHazards(bool player) { int start = player ? 0 : 9; for (int i = 0; i < 9; i++) { BaseFieldEffect fieldEffect = _fieldEffects[start + i]; if (fieldEffect != null) { bool pauseForEffect = (_units[start + i] != null); // Check if tile is occupied and eventually apply effect fieldEffect.StartTurnExecute(); // Clear the tile if the effect is expired if (fieldEffect.Duration < 1) { ClearTile(start + i); } // Pause for animation and stuff if (pauseForEffect) { yield return(new WaitForSeconds(1)); } } } yield return(null); }
public void AddFieldEffect(int tile, BaseFieldEffect fieldEffect) { if (_fieldEffects[tile] == null) { _fieldEffects[tile] = fieldEffect; } else { if (_fieldEffects[tile].GetType().Equals(fieldEffect.GetType())) { _fieldEffects[tile].Update(fieldEffect); fieldEffect.Clear(); } } }
void Update() { // Check for mouse movement if (Input.mousePosition.Equals(_oldMousePos)) { _timer += Time.deltaTime; } else { _timer = 0; } _oldMousePos = Input.mousePosition; int tile = Battleground.Instance.GetCurrentTile(); if (tile < 0 || _timer < DelayBeforeShow) { // No valid tile turn UI off Panel.SetActive(false); _line.enabled = false; return; } BaseFieldEffect fieldEffect = Battleground.Instance.GetFieldEffect(tile); if (fieldEffect == null) { Panel.SetActive(false); _line.enabled = false; return; } Icon.sprite = fieldEffect.Icon; Description.text = fieldEffect.GetDescription(); Panel.SetActive(true); Vector3 start = (Vector3)Battleground.Instance.GetPositionFromTile(tile) + new Vector3(0f, -1.5f, 11f); Vector3 end = start + new Vector3(-6f, -4f, 11f); Panel.transform.position = end + new Vector3(0f, -1f, 0f); _line.enabled = true; _line.SetPosition(0, start); _line.SetPosition(1, end); }