public override bool CanExecute(SimulatedDisplacement sim, Direction dir, Board board) { if (board.CheckCoord(sim.GetCurrentVector())) { Tile tile = board.GetTile(sim.GetCurrentVector()); return(tile.tileType == TileType.PLAINS); } return(false); }
public override bool CanExecute(SimulatedDisplacement sim, Direction dir, Board board) { // TODO Fail upon snare if (sim.displacement.unit.statusController.HasStatus(new StunEffect(0))) { return(false); } if (board.CheckCoord(sim.GetCurrentVector())) { Tile tile = board.GetTile(sim.GetCurrentVector()); return(tile.tileType == TileType.PLAINS); } return(false); }
public static void MoveUnit(SimulatedDisplacement sim, Board board) { MoveUnit(sim.GetUnit(), board.GetTile(sim.GetCurrentVector())); }
public void Relax() { bool changed; do { Dictionary <Vector2, SimulatorNode> nextIter = new Dictionary <Vector2, SimulatorNode>(); changed = false; foreach (KeyValuePair <Vector2, SimulatorNode> pair in nodes) { SimulatorNode node = pair.Value; if (IsRelaxed(node)) { //No Conflict Resolution Needed, update unit values foreach (SimulatorEdge edge in node.edges) { SimulatedDisplacement sim = edge.sim; Vector2 current = sim.GetCurrentVector(); Vector2 next; if (!sim.conflict && !sim.outOfBounds) { next = sim.GetNextSimulationStep(board); changed = changed || next != current; } else { next = current; //do not move forward } //Create and push to simulation our new location if (!nextIter.ContainsKey(current)) { nextIter.Add(current, new SimulatorNode(current)); } if (!nextIter.ContainsKey(next)) { nextIter.Add(next, new SimulatorNode(next)); } nextIter[next].AddEdge(new SimulatorEdge(nextIter[current], nextIter[next], sim)); } } else { //Create and push to simulation our new location foreach (SimulatorEdge edge in node.edges) { SimulatedDisplacement sim = edge.sim; Vector2 current = sim.GetCurrentVector(); Vector2 prev = sim.GetPreviousSimulationStep(board); sim.conflict = true; changed = changed || prev != current; //Create and push to simulation our new location if (!nextIter.ContainsKey(current)) { nextIter.Add(current, new SimulatorNode(current)); } if (!nextIter.ContainsKey(prev)) { nextIter.Add(prev, new SimulatorNode(prev)); } nextIter[prev].AddEdge(new SimulatorEdge(nextIter[current], nextIter[prev], sim)); } } } nodes = nextIter; } while(changed); }