コード例 #1
0
        public void AddFriendByName(string name, RELATION_GROUP nGroup)
        {
            if (string.IsNullOrEmpty(name))
            {
                return;
            }
            int group  = -1;
            int nIndex = -1;

            if (CDataPool.Instance.GetRelation().GetRelationByName(name, ref group, ref nIndex)
                != RELATION_TYPE.RELATION_TYPE_STRANGER)
            {
                return;
            }

            CObject_Character pTargetObj = CObjectManager.Instance.FindCharacterByName(name);

            if (pTargetObj == CObjectManager.Instance.getPlayerMySelf())
            {
                return;
            }
            if (pTargetObj is CObject_PlayerOther)
            {
                ENUM_RELATION sCamp = Interface.GameInterface.Instance.GetCampType(pTargetObj, CObjectManager.Instance.getPlayerMySelf());
                if (sCamp != ENUM_RELATION.RELATION_FRIEND)
                {// 如果不是同一阵营的
                    GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加不同阵营的人到好友");
                    return;
                }
            }
            CGRelation Msg = new CGRelation();

            Msg.GetRelation().CleanUp();
            Msg.GetRelation().m_Type = (byte)RELATION_REQUEST_TYPE.REQ_ADDFRIEND;
            REQUEST_ADD_RELATION_WITH_GROUP pFriend = new REQUEST_ADD_RELATION_WITH_GROUP();

            Msg.GetRelation().mRelation = pFriend;
            pFriend.CleanUp();
            pFriend.SetTargetName(EncodeUtility.Instance.GetGbBytes(name));
            pFriend.SetGroup((byte)nGroup);
            pFriend.SetRelationType((byte)RELATION_TYPE.RELATION_TYPE_FRIEND);

            NetManager.GetNetManager().SendPacket(Msg);
        }
コード例 #2
0
        public void delFriend(RELATION_GROUP group, int index) //删除一个好友
        {
            SDATA_RELATION_MEMBER pInfo = CDataPool.Instance.GetRelation().GetRelationInfo(group, index);

            if (group == RELATION_GROUP.RELATION_GROUP_TEMPFRIEND)      // 如果是临时好友
            {
                CDataPool.Instance.GetRelation().RemoveRelation(group, index);
                GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_UPDATE_FRIEND);
                return;
            }
            else if (group == RELATION_GROUP.RELATION_GROUP_BLACK)
            {
                CGRelation Msg = new CGRelation();

                Msg.GetRelation().CleanUp();
                Msg.GetRelation().m_Type = (byte)RELATION_REQUEST_TYPE.REQ_DELFROMBLACKLIST;

                RELATION_GUID pBlackName    = new RELATION_GUID();
                Msg.GetRelation().mRelation = pBlackName;
                pBlackName.CleanUp();
                pBlackName.SetTargetGUID(pInfo.m_GUID);
                NetManager.GetNetManager().SendPacket(Msg);
            }
            else
            {
                CGRelation Msg = new CGRelation();
                Msg.GetRelation().CleanUp();
                Msg.GetRelation().m_Type    = (byte)RELATION_REQUEST_TYPE.REQ_DELFRIEND;
                REQUEST_DEL_FRIEND pFriend  = new REQUEST_DEL_FRIEND();
                Msg.GetRelation().mRelation = pFriend;
                pFriend.CleanUp();
                pFriend.SetTargetGUID(pInfo.m_GUID);
                NetManager.GetNetManager().SendPacket(Msg);
            }

            return;
        }
コード例 #3
0
    public override void Init()
    {
        base.Init();
        m_pMySelf = s_pObjectManager.getPlayerMySelf();
        int m_nID = m_pMySelf.ServerID;
        //      m_pActiveSkill = NULL;
        //      m_pSkillArea = NULL;
        //      m_pMouseTarget = NULL;
        //      m_bAutoRun = FALSE;
        //      m_bAutoMoveAlong = FALSE;
        //------------------------------------------------------------------
        //重置LogicCount
        //	    m_pMySelf->ResetLogicCount();

        //------------------------------------------------------------------
        //清空加载队列
        //	    CObjectManager::GetMe()->GetLoadQueue()->ClearAllTask();

        //------------------------------------------------------------------
        //发送环境请求
        //	    CGEnvRequest msgEnvRequest;
        //	    CNetManager::GetMe()->SendPacket(&msgEnvRequest);

        //------------------------------------------------------------------
        //发送自身数据请求

        //自身基本信息
        CGCharAskBaseAttrib msgMyBaseAttrib = new CGCharAskBaseAttrib();

        msgMyBaseAttrib.setTargetID((uint)m_nID);
        s_NetManager.SendPacket(msgMyBaseAttrib);

        //基本属性
        CGAskDetailAttrib msgMyAttrib = new CGAskDetailAttrib();

        msgMyAttrib.ObjID = (uint)m_nID;
        s_NetManager.SendPacket(msgMyAttrib);

        ////自身装备(用于创建渲染层外形)
        //CGCharAskEquipment msgAskMyEquip;
        //msgAskMyEquip.setObjID(m_nID);
        //CNetManager::GetMe()->SendPacket(&msgAskMyEquip);

        //生活技能
        CGAskDetailAbilityInfo msgAbility = new CGAskDetailAbilityInfo();

        msgAbility.ObjID = m_nID;
        NetManager.GetNetManager().SendPacket(msgAbility);
        //
        //      //技能系
        CGAskSkillClass msgMySkillClass = new CGAskSkillClass();

        msgMySkillClass.ObjID = m_nID;
        s_NetManager.SendPacket(msgMySkillClass);

        //技能
        CGAskDetailSkillList msgMyDetailSkill = new CGAskDetailSkillList();

        msgMyDetailSkill.ObjID = m_nID;
        s_NetManager.SendPacket(msgMyDetailSkill);
        //
        //      //组队数据
        //      CUIDataPool::GetMe()->ClearTeamInfo();
        //      CGAskTeamInfo msgTeamInfo;
        //      msgTeamInfo.SetObjID( m_nID );
        //      CNetManager::GetMe()->SendPacket(&msgTeamInfo);
        //
        //      //如果是城市向服务器请求城市数据
        //      CGCityAskAttr	MsgCityBuilding;
        //      CNetManager::GetMe()->SendPacket( &MsgCityBuilding );
        //
        //      //所有称号
        //      CGCharAllTitles	msgAllTitles;
        //      msgAllTitles.setTargetID( m_nID );
        //      CNetManager::GetMe()->SendPacket(&msgAllTitles);

        //是第一次登陆
        if (GameProcedure.s_ProcEnter.GetEnterType() == (uint)ENTER_TYPE.ENTER_TYPE_FIRST)
        {
            //详细装备(用于在数据池中存储物品详细属性)
            CGAskDetailEquipList msgAskEquip = new CGAskDetailEquipList();
            msgAskEquip.ObjId = (uint)m_nID;
            msgAskEquip.Mode  = ASK_EQUIP_MODE.ASK_EQUIP_ALL;
            s_NetManager.SendPacket(msgAskEquip);

            //背包
            CGAskMyBagList msgMyBag = new CGAskMyBagList();
            msgMyBag.Mode = ASK_BAG_MODE.ASK_ALL;
            s_NetManager.SendPacket(msgMyBag);

            CGAskMail msgAskMail = new CGAskMail();
            msgAskMail.AskType = (byte)ASK_TYPE.ASK_TYPE_LOGIN;
            s_NetManager.SendPacket(msgAskMail);

            //MissionList
            CGAskMissionList msgMissionList = new CGAskMissionList();
            msgMissionList.ObjID = (uint)m_nID;
            s_NetManager.SendPacket(msgMissionList);

            //向服务器请求快捷栏数据
            CGAskSetting msgSetting = new CGAskSetting();
            s_NetManager.SendPacket(msgSetting);
            //请求法宝栏数据
            CGAskTalismanBag AskTalismanBag = new CGAskTalismanBag();
            s_NetManager.SendPacket(AskTalismanBag);



            //向服务器请求关系人列表
            CGRelation MsgRelation           = new CGRelation();
            MsgRelation.GetRelation().m_Type = (byte)RELATION_REQUEST_TYPE.REQ_RELATIONLIST;
            NetManager.GetNetManager().SendPacket(MsgRelation);

            //想服务器请求符印信息
            CGAskFlushCharmInfo msgFlushCharmInfo = new CGAskFlushCharmInfo();
            NetManager.GetNetManager().SendPacket(msgFlushCharmInfo);

            //广播第一次进入游戏,用来初始化ui或者一些组件
            CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_APPLICATION_INITED);
        }
    }
コード例 #4
0
        //加入好友功能(包括好友、临时好友、黑名单)
        public void addFriend(RELATION_GROUP nGroup, string name)
        {
            string            strva    = name;
            CGRelation        Msg      = new CGRelation();
            CObject_Character pCharObj = null;

            Msg.GetRelation().m_Type = (byte)RELATION_REQUEST_TYPE.REQ_ADDFRIEND;
            REQUEST_ADD_RELATION_WITH_GROUP pFriend = new REQUEST_ADD_RELATION_WITH_GROUP();

            Msg.GetRelation().mRelation = pFriend;
            pFriend.CleanUp();

            bool valueIsNum = false;                                /*Ogre::StringConverter::isNumber(strva.c_str());*/

            if (nGroup == RELATION_GROUP.RELATION_GROUP_FRIEND_ALL) // 如果直接一个名字,就自动往所有的列表里加,
            {
                nGroup = RELATION_GROUP.RELATION_GROUP_F1;
            }
            else if (nGroup == RELATION_GROUP.RELATION_GROUP_TEMPFRIEND) //临时好友
            {
                SDATA_RELATION_MEMBER pMember = new SDATA_RELATION_MEMBER();

                if (!valueIsNum)
                {
                    pCharObj = (CObject_Character)CObjectManager.Instance.FindCharacterByName(strva);
                    if (pCharObj == null)
                    {
                        return;
                    }
                    pMember.m_szName = strva;
                }
                else
                {
                    pCharObj = (CObject_Character)CObjectManager.Instance.GetMainTarget();
                    if (pCharObj == null)
                    {
                        return;
                    }
                    pMember.m_szName = pCharObj.GetCharacterData().Get_Name();
                }
                // 如果是玩家并且是统一阵营的才会添加
                ENUM_RELATION sCamp = Interface.GameInterface.Instance.GetCampType(pCharObj, CObjectManager.Instance.getPlayerMySelf());
                if ((pCharObj is CObject_PlayerOther) == false)
                {
                    return;
                }
                if (sCamp != ENUM_RELATION.RELATION_FRIEND)
                {
                    return;
                }

                int nTmpGroup = -1, nIndex = -1;
                CDataPool.Instance.GetRelation().GetRelationByName(pMember.m_szName, ref nTmpGroup, ref nIndex);
                if (nTmpGroup >= 0)
                {
                    return;
                }

                pMember.m_RelationType = RELATION_TYPE.RELATION_TYPE_TEMPFRIEND;
                if (CDataPool.Instance.GetRelation().AddRelation(RELATION_GROUP.RELATION_GROUP_TEMPFRIEND, pMember))
                {
                    string szText = "你将" + pMember.m_szName + " 添加为临时好友";
                    GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, szText);
                }
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_UPDATE_FRIEND);
                return;
            }
            else if (nGroup == RELATION_GROUP.RELATION_GROUP_BLACK)
            { // 增加黑名单的添加
                CGRelation Msg1                 = new CGRelation();
                Msg1.GetRelation().m_Type       = (byte)RELATION_REQUEST_TYPE.REQ_ADDTOBLACKLIST;
                REQUEST_ADD_RELATION pBlackName = new REQUEST_ADD_RELATION();
                Msg1.GetRelation().mRelation    = pBlackName;
                pBlackName.CleanUp();

                if (strva == "")
                {
                    pCharObj = (CObject_Character)CObjectManager.Instance.GetMainTarget();
                    if (pCharObj == null)
                    {
                        return;
                    }
                    pBlackName.SetTargetName(EncodeUtility.Instance.GetGbBytes(pCharObj.GetCharacterData().Get_Name()));
                }
                else if (valueIsNum)
                {
//                      pCharObj = (CObject_Character)CObjectManager.Instance.FindCharacterByRaceID(int.Parse(strva));
//                      if( pCharObj == null ) pCharObj = (CObject_Character*)CObjectManager::GetMe()->FindCharacterByName(strva.c_str());
//                      if( pCharObj == null ) return ;
//                      pBlackName->SetTargetGUID( Ogre::StringConverter::parseInt(strva.c_str()) );
                }
                else
                {
                    pCharObj = (CObject_Character)CObjectManager.Instance.FindCharacterByName(strva);
                    if (pCharObj == null)
                    {
                        return;
                    }
                    pBlackName.SetTargetName(EncodeUtility.Instance.GetGbBytes(strva));
                }

                if (pCharObj == CObjectManager.Instance.getPlayerMySelf())
                {
                    return;
                }

                if (pCharObj is CObject_PlayerOther)        // 如果是玩家
                {
                    ENUM_RELATION sCamp = Interface.GameInterface.Instance.GetCampType(pCharObj, CObjectManager.Instance.getPlayerMySelf());
                    if (sCamp != ENUM_RELATION.RELATION_FRIEND)
                    {
                        GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加不同阵营的人到黑名单");
                        return;
                    }
                }
                else
                {
                    GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加非玩家到黑名单");
                    return;
                }

                pBlackName.SetRelationType((byte)RELATION_TYPE.RELATION_TYPE_BLACKNAME);
                NetManager.GetNetManager().SendPacket(Msg1);
                return;
            }

            if (strva == "")
            {
                pCharObj = (CObject_Character)CObjectManager.Instance.GetMainTarget();
                if (pCharObj == null)
                {
                    return;
                }
                pFriend.SetTargetName(EncodeUtility.Instance.GetGbBytes(pCharObj.GetCharacterData().Get_Name()));
            }
            else if (valueIsNum)
            {
//              pCharObj = (CObject_Character)CObjectManager::GetMe()->FindCharacterByRaceID(Ogre::StringConverter::parseInt(strva.c_str()));
//              if( pCharObj == NULL ) pCharObj = (CObject_Character*)CObjectManager::GetMe()->FindCharacterByName(strva.c_str());
//              if( pCharObj == NULL ) return 0;
//              pFriend->SetTargetGUID( Ogre::StringConverter::parseInt(strva.c_str()) );
            }
            else
            {
                pFriend.SetTargetName(EncodeUtility.Instance.GetGbBytes(strva));
                pCharObj = (CObject_Character)CObjectManager.Instance.FindCharacterByName(strva);
                if (pCharObj == null)
                {
                    return;
                }
            }
            if (pCharObj == CObjectManager.Instance.getPlayerMySelf())      // 如果是自己,就不加
            {
                return;
            }

            if (pCharObj is CObject_PlayerOther)       // 如果是玩家
            {
                ENUM_RELATION sCamp = Interface.GameInterface.Instance.GetCampType(pCharObj, CObjectManager.Instance.getPlayerMySelf());
                if (sCamp != ENUM_RELATION.RELATION_FRIEND)             // 如果不是同一阵营的
                {
                    GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加不同阵营的人到好友");
                    return;
                }
//              // 改为势力判断 [9/26/2011 Ivan edit]
//              if (pCharObj.GetCharacterData().GetShiLi() !=
//                  CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->GetShiLi())
//              {
//                  CGameProcedure::s_pEventSystem->PushEvent( GE_INFO_SELF, "不能添加不同势力的人到好友" );
//                  return 0;
//              }
            }
            else
            {
                GameProcedure.s_pEventSystem.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "不能添加非玩家到好友");
                return;
            }

            pFriend.SetGroup((byte)nGroup);
            pFriend.SetRelationType((byte)RELATION_TYPE.RELATION_TYPE_FRIEND);

            NetManager.GetNetManager().SendPacket(Msg);

            return;
        }