/// <summary>
        /// Event handler for when the Play Game menu entry is selected.
        /// </summary>
        void HostGameMenuEntrySelected(object sender, PlayerInputEventArgs e)
        {
            GameServer gs = new GameServer(9999);
            GameClient gc = new GameClient();
            gc.ConnectToGame("127.0.0.1", 9999);
            ScreenManager.AddScreen(new LobbyScreen(gc.Lobby));

            return;
        }
Exemplo n.º 2
0
        //Netcode testing suite... or just a template
        public static void Main(string[] args)
        {
            try
            {
                c = new GameClient();
            }
            catch (Exception error)
            {
                Debug.WriteLine("Error occurred creating client: {0}", new object[] { error.Message });
                throw error;
            }

            try
            {
                //s = new NetworkServer(9999);
                gs = new GameServer(9999);
            }
            catch (Exception error)
            {
                Debug.WriteLine("Error occurred creating server: {0}", new object[] { error.Message });
                throw error;
            }

            //while (true)
            //{
            //    if (s.getCMD().Count > 0)
            //    {
            //        foreach (Command c in s.getCMD())
            //        {
            //            Console.WriteLine(c.ct);
            //            Console.WriteLine(c.entity_id);
            //            Console.WriteLine(c.direction.X);
            //            Console.WriteLine(c.direction.Y);
            //            Console.WriteLine(c.position.X);
            //            Console.WriteLine(c.position.Y);
            //            Console.WriteLine("===========");
            //        }
            //    }
            //    List<StateChange> l = new List<StateChange>();
            //    StateChange st = new StateChange();
            //    st.type = StateChangeType.DELETE_ENTITY;
            //    st.intProperties[StateProperties.FRAME_WIDTH] = 123;
            //    st.stringProperties[StateProperties.SPRITE_NAME] = "I'm the Baconator";
            //    l.Add(st);
            //    s.broadcastSC(l);
            //    Thread.Sleep(2000);
            //}
            c.ConnectToGame("127.0.0.1", 9999);
            //c1.connect("127.0.0.1", 9999);
            //c2.connect("127.0.0.1", 9999);
            //c3.connect("127.0.0.1", 9999);

            Timer t = new Timer(NetTest.doPing, new AutoResetEvent(false), 0, 2000);
            Thread.Sleep(5000);
            c.Lobby.SelectCharacter(1337);
            c.Lobby.LockCharacter();

            while (true)
            {
                Thread.Sleep(10000);
            }
        }
Exemplo n.º 3
0
 private void StartGame(GameClient gc)
 {
     LoadingScreen.Load(ScreenManager, false, new GameplayScreen(gc));
     return;
 }
Exemplo n.º 4
0
 /// <summary>
 /// Create a new client-side lobby.
 /// </summary>
 /// <param name="gameClient">The game client associated with this lobby.</param>
 public LobbyClient(GameClient gameClient)
     : base(gameClient)
 {
     return;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Constructor.
        /// </summary>
        public GameplayScreen(GameClient gb)
        {
            game = gb;

            context = new View(gb.GameState, gb.GetPlayerEntity());
        }
        /// <summary>
        /// Event handler for when the Play Game menu entry is selected.
        /// </summary>
        void ContinueMenuEntrySelected(object sender, PlayerInputEventArgs e)
        {
            int port;
            if (!int.TryParse(hostPort.ToString(), out port) || port <= MIN_PORT || port >= MAX_PORT)
            {
                return;
            }

            string hostAddressString = hostAddress.ToString().Trim();
            if (string.IsNullOrWhiteSpace(hostAddressString)) // Sanity
            {
                return;
            }

            GameClient gc = new GameClient();
            gc.ConnectToGame(hostAddressString, port);
            ScreenManager.AddScreen(new LobbyScreen(gc.Lobby));
            return;
        }