Пример #1
0
        /// <summary>
        /// Event handler raised when the Play entry is selected
        /// </summary>
        void PlaySelected(object sender, EventArgs e)
        {
            MessageBox box;

            if (username.Text == "Username" || password.Text == "Password" ||
                String.IsNullOrWhiteSpace(username.Text) || String.IsNullOrWhiteSpace(password.Text))
            {
                box = new MessageBox("You must enter a valid username and password.", true);
                ScreenManager.AddScreen(box);
                return;
            }

            if (ScreenManager.Initialized)
            {
                GameManager.UserSettings.Username = username.Text;
                GameManager.UserSettings.Password = password.Text;

                //Save their data
                Settings.UserSetting.Save();

                Network.CS_AccountLogin login = new Network.CS_AccountLogin();
                //If this doesnt pass, an error box within cs_account will be shown
                if (login.Send())
                {
                    //Game State is only initially started here
                    //every other game state is controlled by our network client
                    GameManager.GameState = State.LoggingIn;

                    //Wait for a response while showing a message
                    Busy = new BusyScreen(Messages.Connecting);
                    Busy.OperationCompleted += ConnectAccountServer;
                    ScreenManager.AddScreen(Busy);
                }
            }
        }
Пример #2
0
 /// <summary>
 /// Event handler for when a zone is selected
 /// </summary>
 void EnterZone_Selected(object sender, EventArgs e)
 {
     if (ScreenManager.Initialized)
     {
         if (Zones.Keys.Contains(LastButtonClicked.Text))
         {
             Network.CS_JoinZone join = new Network.CS_JoinZone();
             //If this doesnt pass, an error box within cs_join will be shown
             if (join.Send(Zones[LastButtonClicked.Text].Address))
             {
                 //Wait for a response while showing a message
                 Busy = new BusyScreen(Messages.Connecting);
                 Busy.OperationCompleted += ConnectZoneServer;
                 ScreenManager.AddScreen(Busy);
             }
         }
     }
 }