public override void processInput(CombatManager mgr) { //Targeter targeter = CombatManager.currentUnit.currentAbility.targeter; if (Input.GetMouseButtonDown(0) && !EventSystem.current.IsPointerOverGameObject()) { HexTile hitTile = UIManager.GetClickedTile(); if (hitTile == null) { return; } if (hitTile.selectable) { command = (AbilityCommand)targeter.ChooseTarget(hitTile, true); UIManager.setHexCursor(hitTile, true); UIManager.button(ButtonName.CONFIRM).gameObject.SetActive(true); } } }
public List <ICommand> ChooseAbility(BoardState boardState, List <ICommand> movement) { float score = Mathf.NegativeInfinity; MoveCommand bestMove = (MoveCommand)movement[0]; AbilityCommand bestSkill = new AbilityCommand(); List <ICommand> bestAction = new List <ICommand>(); foreach (ICommand move in movement) { move.Execute(true); foreach (Ability ability in Unit.current.data.abilities) { HexCoords position = ((MoveCommand)move).path.end.coords; Targeter targeter = ability.Targeter(position, Unit.current); List <HexCoords> targets = targeter.FindTargets(position); foreach (HexCoords t in targets) { HexTile tile = Map.current.TileAt(t); AbilityCommand testMove = (AbilityCommand)targeter.ChooseTarget(tile); testMove.Execute(true); float testScore = boardState.TeamHealth(Unit.current.data.team); testScore -= boardState.TeamHealth(Team.PLAYER); if (testScore > score) { score = testScore; bestSkill = testMove; bestMove = (MoveCommand)move; } testMove.Undo(true); } } move.Undo(true); } bestAction.Add(bestMove); bestAction.Add(bestSkill); return(bestAction); }