Ejemplo n.º 1
0
        void OnMoveUnit(ClientToServerMessage message)
        {
            MoveUnitRequest request = message.MoveUnitRequest;

            if (request == null)
            {
                throw new ServerClientException("Invalid move unit request");
            }
            Unit unit = PlayerState.GetUnit(request.UnitId);

            if (unit == null)
            {
                throw new ServerClientException("Encountered an invalid unit ID in a move request");
            }
            int        movementPointsLeft;
            List <Hex> captures;

            PlayerState.MoveUnit(unit, request.NewPosition, out movementPointsLeft, out captures);
            UnitMoveBroadcast move = new UnitMoveBroadcast(unit.Id, movementPointsLeft);

            foreach (var hex in captures)
            {
                move.Captures.Add(hex.Position);
            }
            ServerToClientMessage broadcast = new ServerToClientMessage(move);

            BroadcastMessage(broadcast);
        }
Ejemplo n.º 2
0
 public ServerToClientMessage(UnitMoveBroadcast move)
 {
     Type     = ServerToClientMessageType.UnitMove;
     UnitMove = move;
 }