void OnCharacterSelected(CCharacter character) { nameText.text = character.name; movementRangeText.text = "Movement Range: " + character.GetMovementPerAction().ToString(); attackRangeText.text = "Attack Range: " + character.GetAttackRange().ToString(); characterInfoPanel.SetActive(true); }
void TakeActionForCharacter(CCharacter character) { Debug.Log("Determining course of action for character " + character.name); if (character.CanTakeAction(ECharacterAction.ATTACK)) { var tilesInRange = TileMapTools.GetTilesWithinMovementRange(map, character.occupyingTile, character.GetAttackRange()); foreach (var tile in tilesInRange) { if (actionController.IsEnemyCharacterOnTile(tile)) { var characterToAttack = actionController.GetCharacterOnTile(tile); character.Attack(characterToAttack); CharacterEvents.aiActionTakenEvent.Invoke(character, ECharacterAction.ATTACK); return; } } } if (character.CanTakeAction(ECharacterAction.MOVE)) { var tilesInRange = TileMapTools.GetTilesWithinMovementRange(map, character.occupyingTile, character.GetMovementPerAction()); int randomlySelectedIndex = UnityEngine.Random.Range(0, tilesInRange.Count); while (actionController.IsAnyCharacterOnTile(tilesInRange[randomlySelectedIndex])) { if (tilesInRange.Count == 0) { Debug.LogWarning("Character could not find a tile to MOVE to! Weird!"); character.ExhaustActionPoints(); return; } tilesInRange.RemoveAt(randomlySelectedIndex); randomlySelectedIndex = UnityEngine.Random.Range(0, tilesInRange.Count); } character.MoveTo(tilesInRange[randomlySelectedIndex]); CharacterEvents.aiActionTakenEvent.Invoke(character, ECharacterAction.MOVE); return; } }