public void PlayerMove(int forPlayer, TransferTurnDoneData moves) { var player = Players[forPlayer]; ApplyMoves(player, moves); var otherPlayers = Players.Where(a => a.Key != forPlayer).Select(a => a.Value).ToList(); foreach (var p in otherPlayers) { var otherMoves = new Dictionary <int, TransferTurnDoneUnit>(); foreach (var u in p.Units) { otherMoves.Add(u.Key, new TransferTurnDoneUnit { Move = u.Value.Position + Fate.GlobalFate.Choose(Vector2.Up, Vector2.Down, Vector2.Left, Vector2.Right) }); } ApplyMoves(p, new TransferTurnDoneData { UnitActions = otherMoves }); } }
private void ApplyMoves(ServerPlayer player, TransferTurnDoneData moves) { foreach (var move in moves.UnitActions) { var forUnit = move.Key; var newTarget = move.Value; var unit = player.Units[forUnit]; if (newTarget.Move.HasValue) { BreadthFirstPathfinder.Search(this.Astar, unit.Position, unit.MoveDistance, out var result); if (result.ContainsKey(newTarget.Move.Value)) { unit.Position = newTarget.Move.Value; } } } }