Пример #1
0
        public void InitializeGame()
        {
            if (!offline && (!client.Initialized() || !server.Initialized()))
            {
                throw new Exception("Connection unitialized. Can't start a game");
            }
            if (offline)
            {
                left  = new HumanPlayer(Side.LEFT);
                right = new HumanPlayer(Side.RIGHT);
            }
            else if (isServer)
            {
                left  = new HumanPlayer(Side.LEFT);
                right = new NetworkPlayer(Side.RIGHT);
            }
            else
            {
                left  = new NetworkPlayer(Side.LEFT);
                right = new HumanPlayer(Side.RIGHT);
            }
            WorldController wrld     = new WorldController(left, right, server, client, isServer);
            Overseer        overseer = new Overseer(wrld);
            BallObject      ball     = new BallObject(left, right, overseer);

            wrld.AttachBall(ball);
            using (var game = new Pong(left, right, ball))
                game.Run();
        }
Пример #2
0
 public void ConnectToServer(string ip, ushort port = PORT)
 {
     isServer = false;
     client   = Client.Instance;
     client.Initialize(ip, port);
     server = Server.Instance;
     if (client.Initialized())
     {
         server.Initialize(port++);
     }
     else
     {
         throw new Exception("Cannot start connection");
     }
 }
Пример #3
0
 private Boolean isThereConnection()
 {
     return((left is NetworkPlayer || right is NetworkPlayer) &&
            (server.Initialized() && client.Initialized()));
 }