// --- Callbacks private void OnHexClicked(HexCell hex) { if (SelectedSkill == SkillType.None || UnitSelectionManager.SelectedUnit == null) { return; } // Skill range ? // Unit correctness with skill ? CrossPlayerController.PerformSkill(UnitSelectionManager.SelectedUnit, hex.Position, SelectedSkill); SkillPerformed?.Invoke(SelectedSkill, hex); }
private void OnPerformSkillCallback(Unit unit, int2 target, SkillType skill) { if (skill == SkillType.Attack) { var targetUnit = HexDatabase.GetSelectable(target) as Unit; if (targetUnit == null) { Debug.LogWarning("targetUnit was null thus cannot be attacked. It should not be possible to initiate attacks on empty cells: " + target); } else { targetUnit.Health -= Math.Abs(unit.Attack - targetUnit.Defense); SkillPerformed?.Invoke(SkillPerformedFinishedFromUI, unit, target, skill); if (SkillPerformed == null) { SkillPerformedFinishedFromUI(unit); } } } TurnManager.EndTurn(unit); }