Exemple #1
0
        public TestEngine(YmfasClient _client)
        {
            netClient = _client;

            // create the event manager
            eventMgr = new EventManager(netClient);
        }
Exemple #2
0
        public TestEngine(YmfasClient _client)
        {
            netClient = _client;

            // create the event manager
            eventMgr = new EventManager(netClient);
        }
Exemple #3
0
        private void timer_Tick(object sender, EventArgs e)
        {
            //looking for servers
            if (splashState == MainSplashState.Searching)
            {
                Console.Out.WriteLine("searching...");
                //update the engine state
                ymfasClient.Update();

                //attempt to find a new server
                Lidgren.Library.Network.NetServerInfo session = ymfasClient.GetLocalSession();
                if (session != null)
                {
                    String hostname = ymfasClient.GetHostNameFromIP(session.RemoteEndpoint.Address.ToString());
                    lstServers.Items.Add(hostname + " - " + session.RemoteEndpoint.Address.ToString());
                }
            }

            //connecting to a server
            if (splashState == MainSplashState.Connecting)
            {
                // update the engine state
                ymfasClient.Update();

                //time out if too long
                if (ticksConnecting * timer.Interval >= MAX_CONNECT_TIME)
                {
                    splashState = MainSplashState.Searching;
                    ymfasClient.Dispose();
                    ymfasClient = null;
                    MessageBox.Show("Connection attempt failed.");
                }
                else
                {
                    ticksConnecting++;

                    //check for successful connection
                    if (ymfasClient.Status == NetConnectionStatus.Connected)
                    {
                        splashState = MainSplashState.None;

                        // join lobby
                        GameLobby = new frmGameLobby(ymfasClient);
                        GameLobby.ShowDialog();

                        if (GameLobby.DialogResult == DialogResult.OK)
                        {
                            ymfasClient       = GameLobby.Client;
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }
                }
            }
        }
Exemple #4
0
        public frmGameLobby(YmfasClient _client, YmfasServer _server)
        {
            client    = _client;
            server    = _server;
            lobbyMode = LobbyMode.Hosting;
            Initialize();

            chkReady.Visible    = false;
            cmbGameMode.Enabled = true;
            idTicketCounter     = 1;
        }
Exemple #5
0
        public frmGameLobby(YmfasClient _client, YmfasServer _server)
        {
            client = _client;
            server = _server;
            lobbyMode = LobbyMode.Hosting;
            Initialize();

            chkReady.Visible = false;
            cmbGameMode.Enabled = true;
            idTicketCounter = 1;
        }
Exemple #6
0
        private void btnJoin_Click(object sender, EventArgs e)
        {
            //Initiate search for servers
            grpServerList.Visible = true;
            ymfasClient           = new YmfasClient(txtName.Text);

            btnJoin.Enabled = false;
            btnHost.Enabled = false;
            ymfasClient.SearchSessions();

            //Handle server search in the timer object
            splashState = MainSplashState.Searching;
        }
Exemple #7
0
        /// <summary>
        /// Launches the form to configure networking 
        /// upon return, the network engine should be fully initialized
        /// </summary>
        public static bool ConfigureNetwork()
        {
            // launch the main splash window
            frmMainSplash networkForm = new frmMainSplash();
            Console.Out.WriteLine("Running the form");
            networkForm.ShowDialog();
            Console.Out.WriteLine("Form done running");

            System.Console.Write(networkForm.DialogResult);

            if (networkForm.DialogResult == System.Windows.Forms.DialogResult.Cancel)
                return false;

            // check to see if we have a host as well
            client = networkForm.Client;
            server = networkForm.Server;

            return true;
        }
Exemple #8
0
        public void Dispose()
        {
            // destroy all scene instance-specific information
            DisposeScene();
            netClient.Dispose();
            netClient = null;

            if (world != null)
            {
                world.Dispose();
                world = null;
            }

            if (root != null)
            {
                root.Dispose();
                root = null;
            }
        }
Exemple #9
0
        /// <summary>
        /// Launches the form to configure networking
        /// upon return, the network engine should be fully initialized
        /// </summary>
        public static bool ConfigureNetwork()
        {
            // launch the main splash window
            frmMainSplash networkForm = new frmMainSplash();

            Console.Out.WriteLine("Running the form");
            networkForm.ShowDialog();
            Console.Out.WriteLine("Form done running");

            System.Console.Write(networkForm.DialogResult);

            if (networkForm.DialogResult == System.Windows.Forms.DialogResult.Cancel)
            {
                return(false);
            }

            // check to see if we have a host as well
            client = networkForm.Client;
            server = networkForm.Server;

            return(true);
        }
Exemple #10
0
        private void btnHost_Click(object sender, EventArgs e)
        {
            //Host a game
            // create a client and a server for the game lobby to use
            ymfasServer = new YmfasServer(txtName.Text);
            ymfasClient = new YmfasClient(txtName.Text);

            ymfasClient.Update();
            ymfasClient.Connect(IPAddress.Loopback);

            //Enter lobby
            GameLobby = new frmGameLobby(ymfasClient, ymfasServer);

            GameLobby.ShowDialog();
            // if we actually started a game
            if (GameLobby.DialogResult == DialogResult.OK)
            {
                ymfasClient = GameLobby.Client;
                ymfasServer = GameLobby.Server;

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Exemple #11
0
 public frmGameLobby(YmfasClient _client)
 {
     client    = _client;
     lobbyMode = LobbyMode.ClientOnly;
     Initialize();
 }
Exemple #12
0
 public frmGameLobby(YmfasClient _client)
 {
     client = _client;
     lobbyMode = LobbyMode.ClientOnly;
     Initialize();
 }
Exemple #13
0
        public void Dispose()
        {
            // destroy all scene instance-specific information
            DisposeScene();
            netClient.Dispose();
            netClient = null;

            if (world != null)
            {
                world.Dispose();
                world = null;
            }

            if (root != null)
            {
                root.Dispose();
                root = null;
            }
        }
Exemple #14
0
        private void btnHost_Click(object sender, EventArgs e)
        {
            //Host a game
            // create a client and a server for the game lobby to use
            ymfasServer = new YmfasServer(txtName.Text);
            ymfasClient = new YmfasClient(txtName.Text);

            ymfasClient.Update();
            ymfasClient.Connect(IPAddress.Loopback);

            //Enter lobby
            GameLobby = new frmGameLobby(ymfasClient, ymfasServer);

            GameLobby.ShowDialog();
            // if we actually started a game
            if (GameLobby.DialogResult == DialogResult.OK) {
                ymfasClient = GameLobby.Client;
                ymfasServer = GameLobby.Server;

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
        }
Exemple #15
0
        private void timer_Tick(object sender, EventArgs e)
        {
            //looking for servers
            if (splashState == MainSplashState.Searching) {

                Console.Out.WriteLine("searching...");
                //update the engine state
                ymfasClient.Update();

                //attempt to find a new server
                Lidgren.Library.Network.NetServerInfo session = ymfasClient.GetLocalSession();
                if (session != null) {
                    String hostname = ymfasClient.GetHostNameFromIP(session.RemoteEndpoint.Address.ToString());
                    lstServers.Items.Add(hostname + " - " + session.RemoteEndpoint.Address.ToString());
                }
            }

            //connecting to a server
            if (splashState == MainSplashState.Connecting) {

                // update the engine state
                ymfasClient.Update();

                //time out if too long
                if (ticksConnecting * timer.Interval >= MAX_CONNECT_TIME) {
                    splashState = MainSplashState.Searching;
                    ymfasClient.Dispose();
                    ymfasClient = null;
                    MessageBox.Show("Connection attempt failed.");
                }
                else {
                    ticksConnecting++;

                    //check for successful connection
                    if (ymfasClient.Status == NetConnectionStatus.Connected) {
                        splashState = MainSplashState.None;

                        // join lobby
                        GameLobby = new frmGameLobby(ymfasClient);
                        GameLobby.ShowDialog();

                        if (GameLobby.DialogResult == DialogResult.OK)
                        {
                            ymfasClient = GameLobby.Client;
                            this.DialogResult = DialogResult.OK;
                            this.Close();
                        }
                    }
                }
            }
        }
Exemple #16
0
        private void btnJoin_Click(object sender, EventArgs e)
        {
            //Initiate search for servers
            grpServerList.Visible = true;
            ymfasClient = new YmfasClient(txtName.Text);

            btnJoin.Enabled = false;
            btnHost.Enabled = false;
            ymfasClient.SearchSessions();

            //Handle server search in the timer object
            splashState = MainSplashState.Searching;
        }