Exemplo n.º 1
0
        /// <summary>
        /// 关系操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;
            int col = e.ColumnIndex; //获取当前列的索引

            if (col == 5)
            {
                PropID item_id = new PropID();
                item_id.type      = ePropType.CURRENCY;
                item_id.obj_type  = (uint)eCurrencyType.Gold;
                item_id.obj_value = 1000;

                string idx      = m_list_relation.Rows[row].Cells["Idx"].Value.ToString();
                long   char_idx = long.Parse(idx);
                ServerMsgSend.SendRelationGive(char_idx, item_id);
            }
            else if (col == 6)
            {
                string            idx       = m_list_relation.Rows[row].Cells["Idx"].Value.ToString();
                long              char_idx  = long.Parse(idx);
                RelationAddTarget target_id = new RelationAddTarget();
                target_id.type     = eRelationAddType.Idx;
                target_id.char_idx = char_idx;
                ServerMsgSend.SendRelationAdd(target_id, eRelationFlag.Block, "");
            }
            else if (col == 7)
            {
                string idx      = m_list_relation.Rows[row].Cells["Idx"].Value.ToString();
                long   char_idx = long.Parse(idx);
                m_list_relation.Rows.RemoveAt(row);
                RelationDataManager.Instance.RemoveRelation(char_idx);
                ServerMsgSend.SendRelationRemove(char_idx);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 加密
        /// </summary>
        private void OnEncryptInfo(PacketBase packet)
        {
            gs2c.EncryptInfo msg = packet as gs2c.EncryptInfo;
            GlobalID.ENCRYPT_KEY = msg.key;

            ServerMsgSend.SendLogin(ServerConfig.net_info.user_name, ServerConfig.net_info.user_psw);
        }
Exemplo n.º 3
0
        public void Start(uint ping_type, int time_offset)
        {
            if (m_timer_id > 0)
            {
                return;
            }

            m_packet_idx = 0;
            m_ping_type  = ping_type;
            m_timer_id   = TimerManager.Instance.AddLoop(time_offset * 1000, 0, (timer_id, param) =>
            {
                if (Utils.HasFlag(m_ping_type, (uint)ePingType.Gate))
                {
                    ServerMsgSend.SendPingGS(++m_packet_idx);
                }
                if (Utils.HasFlag(m_ping_type, (uint)ePingType.Server))
                {
                    ServerMsgSend.SendPingSS(++m_packet_idx);
                }
                if (Utils.HasFlag(m_ping_type, (uint)ePingType.Fight))
                {
                    ServerMsgSend.SendPingFS(++m_packet_idx);
                }
                if (Utils.HasFlag(m_ping_type, (uint)ePingType.World))
                {
                    ServerMsgSend.SendPingWS(++m_packet_idx);
                }
                if (Utils.HasFlag(m_ping_type, (uint)ePingType.Global))
                {
                    ServerMsgSend.SendPingGL(++m_packet_idx);
                }
            });
        }
        /// <summary>
        /// 加密
        /// </summary>
        private void OnEncryptInfo(PacketBase packet)
        {
            gs2c.EncryptInfo msg = packet as gs2c.EncryptInfo;
            GlobalID.ENCRYPT_KEY = msg.key;

            ServerMsgSend.SendLogin(m_conn_idx, "test" + m_account_idx, "1");
        }
        /// <summary>
        /// 关系操作
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnCellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;
            int col = e.ColumnIndex; //获取当前列的索引

            long event_idx        = 0;
            long char_idx         = 0;
            eRelationApplyCmd cmd = eRelationApplyCmd.Agree;

            if (col == 4)
            {
                string idx = m_list_relation.Rows[row].Cells["Idx"].Value.ToString();
                event_idx = long.Parse(idx);
                string str_char_idx = m_list_relation.Rows[row].Cells["CharIdx"].Value.ToString();
                char_idx = long.Parse(str_char_idx);
                cmd      = eRelationApplyCmd.Agree;
            }
            else if (col == 5)
            {
                string idx = m_list_relation.Rows[row].Cells["Idx"].Value.ToString();
                event_idx = long.Parse(idx);
                string str_char_idx = m_list_relation.Rows[row].Cells["CharIdx"].Value.ToString();
                char_idx = long.Parse(str_char_idx);
                cmd      = eRelationApplyCmd.Reject;
            }
            m_list_relation.Rows.RemoveAt(row);
            RelationDataManager.Instance.RemoveNewApplys(event_idx);

            ServerMsgSend.SendRelationApplyCommand(event_idx, char_idx, cmd);
        }
Exemplo n.º 6
0
 /// <summary>
 /// 通知有新邮件
 /// </summary>
 private void OnMailCount(PacketBase packet)
 {
     ss2c.MailCount msg = packet as ss2c.MailCount;
     if (msg.total_mail_count > 0)
     {
         ServerMsgSend.SendMailList();
     }
 }
 /// <summary>
 /// 移动
 /// </summary>
 private void MoveOne(long conn_idx, int x, int y)
 {
     x = MathUtils.RandRange(-2, 2) + x;
     y = MathUtils.RandRange(-2, 2) + y;
     x = (int)MathUtils.Clamp(x, -50, 50);
     x = (int)MathUtils.Clamp(x, -50, 50);
     ServerMsgSend.SendUnitMove(conn_idx, x, y);
 }
        private void OnBtnOk(object sender, EventArgs e)
        {
            string   user_name = this.m_txt_name.Text;
            eSexType sex       = this.m_com_sex.SelectedIndex == 0 ? eSexType.BOY : eSexType.GIRL;

            ServerMsgSend.SendCreateCharacter(user_name, (uint)sex);

            this.Close();
        }
Exemplo n.º 9
0
        /// <summary>
        /// 发邮件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBtnOK(object sender, EventArgs e)
        {
            MailWriteInfo info = new MailWriteInfo();

            //info.receiver_type = MailWriteInfo.eReceiverType.CHARID;
            //info.receiver_idx = long.Parse(m_txt_recv.Text);
            info.receiver.SetName(m_txt_recv.Text);
            info.subject = m_txt_subject.Text;
            info.content = m_txt_content.Text;
            ServerMsgSend.SendWriteMail(info);
        }
Exemplo n.º 10
0
        private void SendCheck()
        {
            if (m_check_sn == 0)
            {
                return;
            }

            ServerMsgSend.SendSpeedCheck(m_check_sn);

            m_check_sn = 0;
        }
Exemplo n.º 11
0
        private void OnBtnOk(object sender, EventArgs e)
        {
            string scene_type = this.m_txt_scene.Text;

            if (scene_type.Trim().Length == 0)
            {
                return;
            }
            ServerMsgSend.SendEnterScene(ushort.Parse(scene_type));
            this.Close();
        }
 /// <summary>
 /// 登陆
 /// </summary>
 private void OnClientLogin(PacketBase packet)
 {
     gs2c.ClientLogin msg = packet as gs2c.ClientLogin;
     if (msg.login_result == eLoginResult.E_SUCCESS)
     {
         ServerMsgSend.SendCharacterList(m_conn_idx);
     }
     else
     {
         Log.Error("登录错误:" + m_conn_idx);
     }
 }
Exemplo n.º 13
0
        private void Init()
        {
            ServerMsgSend.SendRelationList();

            Dictionary <long, RelationInfo> list = RelationDataManager.Instance.relations;

            foreach (var obj in list)
            {
                RelationInfo info = obj.Value;
                m_list_relation.Rows.Add(info.char_idx, info.char_name, info.flags, info.level, info.char_type);
            }
        }
 /// <summary>
 /// 创建角色
 /// </summary>
 private void OnCreateCharacter(PacketBase packet)
 {
     gs2c.CreateCharacter msg = packet as gs2c.CreateCharacter;
     if (msg.result != eCreateCharResult.E_SUCCESS)
     {
         Log.Error("创建角色错误:" + msg.result);
     }
     else
     {
         Log.Debug("角色创建成功:" + msg.char_idx);
         ServerMsgSend.SendCharacterList(m_conn_idx);
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// 创建角色
 /// </summary>
 private void OnCreateCharacter(PacketBase packet)
 {
     gs2c.CreateCharacter msg = packet as gs2c.CreateCharacter;
     if (msg.result != eCreateCharResult.E_SUCCESS)
     {
         EventController.TriggerEvent(ClientEventID.SHOW_MESSAGE, "创建角色错误:" + msg.result, "错误");
     }
     else
     {
         EventController.TriggerEvent(ClientEventID.SHOW_MESSAGE, "创建成功:" + msg.char_idx, "信息");
         ServerMsgSend.SendCharacterList();
     }
 }
 /// <summary>
 /// 角色列表
 /// </summary>
 private void OnCharacterList(PacketBase packet)
 {
     ss2c.EnumCharacter msg = packet as ss2c.EnumCharacter;
     if (msg.list.Count == 0 || msg.list.Count > 1)
     {
         ServerMsgSend.SendCreateCharacter(m_conn_idx, "test" + m_account_idx, (uint)eSexType.BOY);
     }
     else
     {
         CharacterLogin char_info = msg.list[0];
         ServerMsgSend.SendEnterGame(m_conn_idx, char_info.char_idx);
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// 登录角色
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnUserDClick(object sender, MouseEventArgs e)
        {
            int index = m_list_user.SelectedIndex;

            if (index < 0)
            {
                return;
            }
            CharacterLogin char_data = LoginDataMgr.Instance.GetCharacterByIndex(index);

            ServerMsgSend.SendEnterGame(char_data.char_idx);
            ServerMsgSend.SendEnterScene(0);

            this.Close();
        }
Exemplo n.º 18
0
        /// <summary>
        /// 发邮件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBtnOK(object sender, EventArgs e)
        {
            MailWriteInfo info = new MailWriteInfo();

            if (m_comb_name_type.SelectedIndex == 0)
            {
                info.receiver.SetIdx(long.Parse(m_txt_recv.Text));
            }
            else
            {
                info.receiver.SetName(m_txt_recv.Text);
            }
            info.subject = m_txt_subject.Text;
            info.content = m_txt_content.Text;
            ServerMsgSend.SendWriteMail(info);
        }
Exemplo n.º 19
0
        /// <summary>
        /// 登陆
        /// </summary>
        private void OnClientLogin(PacketBase packet)
        {
            gs2c.ClientLogin msg = packet as gs2c.ClientLogin;
            if (msg.login_result == eLoginResult.E_SUCCESS)
            {
                EventController.TriggerEvent(ClientEventID.SHOW_STATUS, eFormStatusType.Account, "登录账号:" + ServerConfig.net_info.user_name);
                EventController.TriggerEvent(ClientEventID.SHOW_STATUS, eFormStatusType.Log, "登录成功");

                ServerMsgSend.SendCharacterList();
            }
            else
            {
                EventController.TriggerEvent(ClientEventID.SHOW_MESSAGE, "登录错误:" + msg.login_result, "错误");
                EventController.TriggerEvent(ClientEventID.SHOW_STATUS, eFormStatusType.Log, "登录失败");
            }
        }
Exemplo n.º 20
0
        /// <summary>
        /// 角色列表
        /// </summary>
        private void OnCharacterList(PacketBase packet)
        {
            ss2c.EnumCharacter msg = packet as ss2c.EnumCharacter;
            LoginDataMgr.Instance.AddCharacterList(msg.list);
            if (msg.list.Count == 0 || msg.list.Count > 1)
            {
                EventController.TriggerEvent(ClientEventID.OPEN_FORM, eFormType.CreateUser);
            }
            else
            {
                CharacterLogin char_info = msg.list[0];
                EventController.TriggerEvent(ClientEventID.SHOW_STATUS, eFormStatusType.User, "当前角色:" + char_info.char_name);

                ServerMsgSend.SendEnterGame(char_info.char_idx);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 发消息
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBtnOK(object sender, EventArgs e)
        {
            int select_idx = m_comb_chat_type.SelectedIndex;

            if (select_idx >= 0 && m_txt_content.Text.Length > 0)
            {
                eChatType type     = (eChatType)(select_idx + 2);
                string    content  = m_txt_content.Text;
                long      receiver = 0;
                if (type == eChatType.PRIVATE)
                {
                    receiver = long.Parse(m_txt_recevier.Text);
                }
                ServerMsgSend.SendChat(type, receiver, content);
            }
        }
Exemplo n.º 22
0
        private void OnPicMouseUp(object sender, MouseEventArgs e)
        {
            base.OnMouseUp(e);
            if (e.Button == MouseButtons.Right)
            {
                for (int i = 0; i < m_cur_rect_count; ++i)
                {
                    Rectangle rect = m_list_unit_rect[i].rect;
                    if (rect.Contains(e.Location))
                    {
                        m_right_menu_unit_idx = m_list_unit_rect[i].unit_idx;
                        mainContextMenuStrip.Show(this, e.Location);
                        return;
                    }
                }

                //移动
                Unit main_unit = UnitManager.Instance.GetUnitByIdx(PlayerDataMgr.Instance.main_player_id);
                if (main_unit != null)
                {
                    int new_x, new_y;
                    int x = e.Location.X - 500;
                    int y = e.Location.Y - 500;
                    if (x > main_unit.pos.x * 10)
                    {
                        new_x = main_unit.pos.x + 1;
                    }
                    else
                    {
                        new_x = main_unit.pos.x - 1;
                    }
                    if (y > main_unit.pos.y * 10)
                    {
                        new_y = main_unit.pos.y + 1;
                    }
                    else
                    {
                        new_y = main_unit.pos.y - 1;
                    }
                    main_unit.ModifyPos(new_x, new_y);
                    ServerMsgSend.SendUnitMove(new_x, new_y);
                }
            }
        }
Exemplo n.º 23
0
        /// <summary>
        /// 添加关系
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnBtnOK(object sender, EventArgs e)
        {
            string str_value = m_txt_value.Text.Trim();

            if (m_add_type.SelectedIndex < 0 || m_add_flag.SelectedIndex < 0 || str_value.Length == 0)
            {
                return;
            }

            RelationAddTarget target = new RelationAddTarget();

            if (m_add_type.SelectedIndex == 0)
            {
                target.type = eRelationAddType.Idx;
                if (!StringUtils.IsInteger(str_value))
                {
                    return;
                }
                target.char_idx = long.Parse(str_value);
            }
            else
            {
                target.type      = eRelationAddType.Name;
                target.char_name = str_value;
            }

            eRelationFlag flag = eRelationFlag.Invalid;

            if (m_add_flag.SelectedIndex == 0)
            {
                flag = eRelationFlag.Friend;
            }
            else
            {
                flag = eRelationFlag.Block;
            }

            ServerMsgSend.SendRelationAdd(target, flag, m_txt_message.Text.Trim());

            this.Close();
        }
Exemplo n.º 24
0
        private void OnCellClick(object sender, DataGridViewCellEventArgs e)
        {
            int row = e.RowIndex;
            int col = e.ColumnIndex; //获取当前列的索引

            if (col == 5)
            {
                string idx = m_list_mail.Rows[row].Cells["Idx"].Value.ToString();
                ServerMsgSend.SendReadMail(long.Parse(idx));
            }
            else if (col == 6)
            {
                if (MessageBox.Show("确定要删除邮件吗?", "信息", MessageBoxButtons.OKCancel) == DialogResult.OK)
                {
                    string idx = m_list_mail.Rows[row].Cells["Idx"].Value.ToString();
                    ServerMsgSend.SendDeleteMail(long.Parse(idx));

                    m_list_mail.Rows.RemoveAt(row);
                }
            }
        }
Exemplo n.º 25
0
 private void OnBtnOk(object sender, EventArgs e)
 {
     if (m_com_name.SelectedIndex > 0 && m_txt_value.Text.Trim().Length > 0)
     {
         bool         is_string = false;
         string       value     = m_txt_value.Text.Trim();
         eUnitModType type      = (eUnitModType)m_com_name.SelectedIndex;
         switch (type)
         {
         case eUnitModType.UMT_char_name:
             is_string = true;
             break;
         }
         if (is_string)
         {
             ServerMsgSend.SendUnitModifyString(type, value);
         }
         else
         {
             ServerMsgSend.SendUnitModifyInt(type, long.Parse(value));
         }
     }
     this.Close();
 }
Exemplo n.º 26
0
 /// <summary>
 /// 服务器时间
 /// </summary>
 private void OnServerTime(PacketBase packet)
 {
     ws2c.ServerTime msg = packet as ws2c.ServerTime;
     Log.Debug("服务器时间:" + msg.server_time);
     if (timer_id != 0)
     {
         TimerManager.Instance.RemoveTimer(timer_id);
     }
     timer_id = TimerManager.Instance.AddLoop(1000 * 60 * 10, int.MaxValue, (id, param) => { ServerMsgSend.SendServerTime(); });
 }
 /// <summary>
 /// 进入游戏
 /// </summary>
 private void OnEnterGame(PacketBase packet)
 {
     gs2c.EnterGame msg = packet as gs2c.EnterGame;
     ServerMsgSend.SendEnterScene(m_conn_idx, 0);
 }