public void TryCastAbility(Ability ability) { if (selectedUnit == null || selectedUnit.Owner != player) { inGameUi.ShowMessage("You don't control this unit", Color.red); inGameUi.Invoke("HideMessage", 3f); return; } string error; if (!ability.CanCast(out error)) { inGameUi.ShowMessage(error, Color.red); inGameUi.Invoke("HideMessage", 3f); } else { selectedUnit.GetComponent <UnitController>().StopAll(); ability.Cast(); } }