bool CheckMovementInitialization() { if (Selected && // we're selected Player.SelectedNode != null && // player has clicked on a map node (Player.SelectedNode.OccupiedBy == null || Player.SelectedNode.OccupiedBy.GetComponent <Hero>() == null) && // the map node is not occupied by an allied unit Reachable != null && Reachable.Contains(Player.SelectedNode)) // destination tile is reachable { // action upon completion Path.PathAction action; if (Player.SelectedNode.OccupiedBy == null) { action = Path.PathAction.Move; } else if (Player.SelectedNode.OccupiedBy.GetComponent <Monster>() != null) { action = Path.PathAction.Attack; } else { action = Path.PathAction.Use; } // if we're attacking, check whether we still can if (action == Path.PathAction.Attack) { if (AlreadyAttacked) { return(false); } AlreadyAttacked = true; } // forbid user interaction while moving Player.InvalidateSelection(); Player.Mode = Player.PlayerMode.Waiting; Player.InvalidateHighlight(Reachable); // initilize movement AStarPathFinder pf = new AStarPathFinder(action); Path = pf.Find(Tile, Player.SelectedNode); Tile.OccupiedBy = null; Tile = null; return(true); } return(false); }
public static bool FilterIconShow(int groupId, int id, int value) => Reachable.Contains(new UberStateCondition(groupId, id, value));