public virtual void Execute(Tile targetTile) { var areaOfAffect = StatCalculator.CalculateStat(ActionReference, StatType.AttackAOE); var affectedTiles = TileGridController.Instance.GetTilesInRadius(targetTile.GridX, targetTile.GridY, areaOfAffect); this.ExecuteAction(affectedTiles); }
protected virtual Action GetMostEffectiveAttack(CharacterController playerCharacter, out float maxPotentialDamage) { Action bestAttack = null; maxPotentialDamage = 0f; if (_aiCharacter.Character.Weapon?.Actions == null || _aiCharacter.Character.Weapon.Actions.Count == 0) { Debug.LogWarning($"Character {_aiCharacter.Character.Name} does not have a weapon with attacks."); return(bestAttack); } foreach (var attack in _aiCharacter.Character.Weapon.Actions) { if (Vector3.Distance(_aiCharacter.transform.position, playerCharacter.transform.position) < attack.Range) { var potentialDamage = StatCalculator.CalculateStat(attack, StatType.Damage); if (potentialDamage > maxPotentialDamage) { maxPotentialDamage = potentialDamage; bestAttack = attack; } } } return(bestAttack); }
protected virtual void VirtualStart() { var maxHealth = StatCalculator.CalculateStat(Character, StatType.Health); _currentHealth = maxHealth; _currentshieldHealth = Character.Shield?.Health ?? 0; _healthController = GetComponent <HealthController>(); _healthController?.SetHealthStats(_currentHealth, maxHealth, _currentshieldHealth, _currentshieldHealth); _moveController = GetComponent <MoveController>(); _actionControllers = GetComponents <ActionController>().ToList(); _actionViewers = GetComponents <ActionViewer>().ToList(); PlaceSelfInGrid(); }
private void SelectAction(Action action) { var attackViewer = _selectedCharacter.GetActionViewer(action); if (attackViewer == null) { Debug.LogError("Unable to display attack because an attack viewer could not be found.\n" + "Make sure your character has a weapon with attacks, and an attack viewer that references it."); return; } DeselectAction(); DeselectMove(); _actionIsSelected = true; _selectedAction = action; var actionAOE = StatCalculator.CalculateStat(action, StatType.AttackAOE); _selectedActionRange = StatCalculator.CalculateStat(action, StatType.AttackRange); attackViewer.DisplayAction(actionAOE, _selectedActionRange); Debug.Log($"Attack '{action.Name}' has been selected."); }