/// <summary> /// Returns a details panel injected with the data from a character. /// </summary> /// <param name="character">The character whose data will be used to fill the details panel.</param> /// <returns>A read-only list of string that contains the details panel.</returns> public IReadOnlyList <string> Render() { IDisplayCharacter focusedTarget; IReadOnlyList <IDisplayCharacter> otherTargets = new List <IDisplayCharacter>(); var targets = _uiStateTracker.CurrentTargetPositions; // If there are no characters within any of our target positions, return the current turn character if (!targets.Any(targetPosition => _uiCharacterManager.GetCharacterFromPosition(targetPosition) != null)) { focusedTarget = _uiCharacterManager.GetCurrentTurnCharacter(); } // If our main target position is occupied, display that target else if (_uiCharacterManager.CharacterInPositionExists(_uiStateTracker.CurrentTargetPosition) && targets.Contains(_uiStateTracker.CurrentTargetPosition)) { focusedTarget = _uiCharacterManager.GetCharacterFromPosition(_uiStateTracker.CurrentTargetPosition); otherTargets = _uiCharacterManager.GetCharactersFromPositions(targets); } // If our main target position isn't occupied, display any target that occupies a spot in our target list else { focusedTarget = _uiCharacterManager.Characters.First( character => targets.Contains(character.Position)); otherTargets = _uiCharacterManager.GetCharactersFromPositions(targets); } if (otherTargets.Count() > 0) { return(Render(otherTargets, focusedTarget)); } if (focusedTarget == null) { throw new NullReferenceException(); } if (IsCachedData(focusedTarget)) { return(_cachedRender); } else { _cachedCharacter = new CachedCharacter() { Id = focusedTarget.Id, CurrentHealth = focusedTarget.CurrentHealth, MaxHealth = focusedTarget.MaxHealth }; } var characterDetails = new List <string>(); characterDetails.AddRange(RenderCharacter(focusedTarget)); _cachedRender = characterDetails; return(characterDetails); }
/// <summary> /// Gets the target to render in the target panel depending on which panel is active and where the target position is. /// </summary> /// <returns></returns> private IDisplayCharacter GetTarget() { if (_defaultsHandler.IsInFormationPanel || !_combatStateHandler.IsPlayerTurn()) { IDisplayCharacter renderTarget = null; // If there is a character in the player's default target position, render that target's details if (_uiCharacterManager.Characters.Any(chr => chr.Position == _defaultsHandler.CurrentTargetPosition)) { renderTarget = _uiCharacterManager.GetCharacterFromPosition(_defaultsHandler.CurrentTargetPosition); } // Finds any character that is in the player's target list and render that target's details else { var targets = _defaultsHandler.CurrentTargetPositions; renderTarget = _uiCharacterManager.Characters.FirstOrDefault(chr => targets.Contains(chr.Position)); } // If there are no characters that occupy the positions the player is targeting, render the active character's details if (renderTarget == null) { renderTarget = _uiCharacterManager.GetCharacterFromId(_defaultsHandler.ActiveCharacterId); } return(renderTarget); } else { return(_uiCharacterManager.GetCharacterFromId(_defaultsHandler.ActiveCharacterId)); } }
/// <summary> /// Returns true if an action cannot bypass a character blocking its path to the right. /// </summary> /// <returns></returns> private bool IsRightArrowBlocked() { if (_defaultsHandler.ActiveAction.CanTargetThroughUnits) { return(false); } // Don't block any actions from the player's field if (_defaultsHandler.CurrentTargetPosition <= 9) { return(false); } var character = _uiCharacterManager.GetCharacterFromPosition(_defaultsHandler.CurrentTargetPosition); // If there is no character or a dead character in that position, the target is not blocked if (character == null || character.CurrentHealth == 0) { return(false); } return(true); }