public override UnitState HandleInput(Controller controller) { var swappedAbility = SwapActiveAbility(controller); if (swappedAbility != null) { BoardVisuals.RemoveTilesFromHighlightsByUnit(Owner); CleanIndicator(); return(swappedAbility); } List <PathfindingData> tilesInRange = GetTilesInRange(); // handling a special case where the targetting is programmatic. // will ecentually need to accomodate for this in a more robust way using OOP if (abilityComponent.CurrentAbility.AutoTargets) { PathfindingData autoTarget = tilesInRange.FirstOrDefault( element => element.tile.IsOccupied() && element.tile.OccupiedBy.GetComponent <Monster> () ); if (autoTarget == null) { AudioComponent.PlaySound(Sounds.ERROR); onAbilityCanceled(); return(new PlayerIdleState(Owner)); } if (Owner.EnergyComponent.AdjustEnergy(-abilityComponent.CurrentAbility.EnergyCost) && abilityComponent.PrepAbility(tilesInRange, autoTarget)) { onAbilityCommited(Owner, abilityComponent.IndexOfCurrentAbility()); return(new PlayerActingState(Owner, tilesInRange, autoTarget)); } } Point mousePosition = BoardUtility.mousePosFromScreenPoint(); HighlightTiles(tilesInRange, mousePosition); // user clicks on a walkable tile which is in range.... if (controller.DetectInputFor(ControlTypes.CONFIRM)) { PathfindingData selectedTarget = tilesInRange.Find( element => element.tile.Position == mousePosition ); // transition to acting state if it's a valid selection // and we successfully prep our ability for use bool targetIsValid = selectedTarget != null && selectedTarget.tile.isWalkable; if (targetIsValid && Owner.EnergyComponent.AdjustEnergy(-abilityComponent.CurrentAbility.EnergyCost) && abilityComponent.PrepAbility(tilesInRange, selectedTarget)) { onAbilityCommited(Owner, abilityComponent.IndexOfCurrentAbility()); return(new PlayerActingState(Owner, tilesInRange, selectedTarget)); } } return(null); }
public override void Enter() { BoardVisuals.RemoveTilesFromHighlightsByUnit(Owner); BoardVisuals.RemoveIndicator(Owner); this.UpdateState(); // Color baseColor = TempChangeColor (); // // start a timer with a callback to transition to the next state // CoroutineHelper.Instance.StartCountdown (cooldownDuration, // () => this.UpdateState (baseColor)); }
public override void EnterCooldown() { BoardVisuals.RemoveTilesFromHighlightsByUnit(owner); StartCoroutine(countdown(Random.Range(0, 4), () => SetState(UnitStates.IDLE))); }