Пример #1
0
        /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~创建角色~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
        /// <summary>
        /// 登陆测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnLoginPageClick(object sender, EventArgs e)
        {
            this.SetCreateProgress(0, 1);
            if (m_tabLogin_Start.Text == "停止")
            {
                m_tabLogin_Start.Text    = "开始";
                m_tabLogin_Start.Enabled = true;
                EnableTabPage(true, m_tabUser);
                EnableLoginTabPage(true);

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.CreateUser, false);
            }
            else
            {
                sCreateUserInfo info = new sCreateUserInfo();
                info.ip            = this.m_tabUser_IP.Text;
                info.port          = ushort.Parse(this.m_tabUser_Port.Text);
                info.db_name       = this.m_tabUser_DB.Text;
                info.start_id      = long.Parse(this.m_tabUser_StartId.Text);
                info.start_account = long.Parse(this.m_tabUser_StartAccount.Text);
                info.end_account   = long.Parse(this.m_tabUser_EndAccount.Text);
                if (info.start_id < 0)
                {
                    MessageBox.Show("请设置有效的角色起始id", "错误", MessageBoxButtons.OK);
                    return;
                }
                if (info.end_account <= info.start_account || info.start_account < 0)
                {
                    MessageBox.Show("请设置有效的账号范围", "错误", MessageBoxButtons.OK);
                    return;
                }

                m_tabLogin_Start.Enabled = false;
                EnableTabPage(false, m_tabUser);
                EnableLoginTabPage(false);
                m_pressure_type       = ePressureType.CreateUser;
                m_tabLogin_Start.Text = "停止";

                EventController.TriggerEvent(ClientEventID.SWITCH_PRESSURE, ePressureType.CreateUser, true, info);
                m_tabLogin_Start.Enabled = true;
            }
        }
 private void OnGameEvent(GameEvent evt)
 {
     switch (evt.type)
     {
     case ClientEventID.SWITCH_PRESSURE:
     {
         ePressureType type     = evt.Get <ePressureType>(0);
         bool          is_start = evt.Get <bool>(1);
         if (type == ePressureType.CreateUser && is_start)
         {
             m_pressure_info = evt.Get <sCreateUserInfo>(2);
             this.Start();
         }
         else
         {
             this.Stop();
         }
     }
     break;
     }
 }