public CActionItem getSuitAbleSkill(CObject_Character target)
    {
        if (!canUseNextSkill_)
        {
            return(null);
        }

        for (int i = shortCutTokenID_; i < MAX_SHORTCUT_COUNT; i++)
        {
            CActionItem curItem = mItems[i];
            if (CanUseSkill(curItem, target))
            {
                shortCutTokenID_++;
                waitNextSkillTime_ = GameProcedure.s_pTimeSystem.GetTimeNow();
                shortCutTokenID_  %= MAX_SHORTCUT_COUNT;
                canUseNextSkill_   = false;
                return(curItem);
            }
        }

        for (int i = 0; i < shortCutTokenID_; i++)
        {
            CActionItem curItem = mItems[i];
            if (CanUseSkill(curItem, target))
            {
                waitNextSkillTime_ = GameProcedure.s_pTimeSystem.GetTimeNow();
                shortCutTokenID_   = i + 1;
                shortCutTokenID_  %= MAX_SHORTCUT_COUNT;
                canUseNextSkill_   = false;
                return(curItem);
            }
        }
        return(null);
    }
Exemple #2
0
    void UpdateMemberRenderInterfaceByIndex(int nIndex)
    {
        if (m_anPassengerIDs[nIndex] == 0)
        {
            return;
        }

        if (m_abPassengerAttacheds[nIndex])
        {
            return;
        }

        if (GetRenderInterface() != null && m_pBusData != null && m_pBusData.m_aSeatInfo[nIndex].m_pszLocator.Length > 0)
        {
            CObject pObj = CObjectManager.Instance.FindServerObject((int)m_anPassengerIDs[nIndex]);
            if (pObj != null && pObj.GetRenderInterface() != null)
            {
                GetRenderInterface().Attach_Object(pObj.GetRenderInterface(), m_pBusData.m_aSeatInfo[nIndex].m_pszLocator);
                CObject_Character player = pObj as CObject_Character;
                if (player != null)
                {
                    player.GetCharacterData().Set_BusObjID((uint)ServerID);
                }
                m_abPassengerAttacheds[nIndex] = true;
                UpdateAnimation();
                SetPosition(GetPosition());
            }
        }
    }
Exemple #3
0
    void RemoveAllPassengers()
    {
        int i;

        for (i = 0; i < GameStruct_Bus.DEF_BUS_MAX_PASSENGER_COUNT; i++)
        {
            if (m_anPassengerIDs[i] != MacroDefine.INVALID_ID)
            {
                if (m_abPassengerAttacheds[i] && GetRenderInterface() != null)
                {
                    CObject pObj = CObjectManager.Instance.FindServerObject((int)m_anPassengerIDs[i]);
                    if (pObj != null && pObj.GetRenderInterface() != null)
                    {
                        CObject_Character player = pObj as CObject_Character;
                        if (player != null)
                        {
                            player.GetCharacterData().Set_BusObjID(0);
                        }
                        GetRenderInterface().Detach_Object(pObj.GetRenderInterface());
                        pObj.SetMapPosition(pObj.GetPosition().x, pObj.GetPosition().z);                    //角色离开飞行坐骑后刷新自己的位置  [8/22/2011 zzy]
                    }
                }
                m_anPassengerIDs[i]       = 0;
                m_abPassengerAttacheds[i] = false;
            }
        }
        m_nPassengerCount = 0;
    }
 private void UpdateEffectTargetPos(SImpactEffect pImpactEffect)
 {
     if (pImpactEffect == null)
     {
         return;
     }
     if (pImpactEffect.IsLineEffect())
     {
         uint uEffect = pImpactEffect.GetEffect();
         if (uEffect != 0 && m_Character.GetRenderInterface() != null && pImpactEffect.GetCreatorID() != MacroDefine.INVALID_ID)
         {
             CObject_Character pCreator = (CObject_Character)(CObjectManager.Instance.FindServerObject((int)pImpactEffect.GetCreatorID()));
             if (pCreator != null)
             {
                 Vector3 fvPos = Vector3.zero;
                 if (pCreator.GetRenderInterface() != null && pImpactEffect.GetCreatorLocator().Length > 0)
                 {
                     pCreator.GetRenderInterface().GetLocator(pImpactEffect.GetCreatorLocator(), ref fvPos);
                 }
                 else
                 {
                     fvPos = pCreator.GetPosition();
                 }
                 m_Character.GetRenderInterface().SetEffectExtraTransformInfos(uEffect, ref fvPos);
             }
         }
     }
 }
Exemple #5
0
    // 组建队伍,设置队伍的 leader,并且加入为第一个成员
    public bool CreateTeam(TeamMemberInfo leader, short TeamID)
    {
        if (m_Type != TEAM_OR_GROUP_TYPE.INVAILD_TYPE)
        {
            throw new Exception("create team failed  type = " + m_Type.ToString());
        }

        m_Type = TEAM_OR_GROUP_TYPE.TEAM_TYPE;
        m_ID   = TeamID;
        SetLeaderGUID(leader.m_GUID);

        m_TeamMembers.Add(leader);

        //通知Talk Interface,队伍建立
        //Talk..TeamCreate(m_ID);
        //设置角色层数据
        CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Set_HaveTeamFlag(true);

        // 更新队伍信息 [9/26/2011 Ivan edit]
        CObject_Character player = CObjectManager.Instance.FindServerObject(leader.m_OjbID) as CObject_Character;

        if (player != null)
        {
            player.GetCharacterData().RefreshName();
        }

        return(true);
    }
Exemple #6
0
    private bool IsEnemy(CObject cObject)
    {
        CObject_Character pChar = (CObject_Character)cObject;

        return(ENUM_RELATION.RELATION_ENEMY == GameProcedure.s_pGameInterface.GetCampType(
                   getPlayerMySelf(), pChar));
    }
    // 客户端移除一个关系,通常用于移除临时好友
    public bool                                                             RemoveRelation(RELATION_GROUP RelationGroup, int idx)
    {
        RelationList pRelationList;

        pRelationList = GetRelationList(RelationGroup);
        if (pRelationList == null)
        {
            return(false);
        }

        if (idx < 0 || idx >= pRelationList.GetMemberCount())
        {
            return(false);
        }

        // keep name [10/9/2011 Ivan edit]
        string m_szName = pRelationList.GetMember(idx).m_szName;

        // 刷新头顶名字颜色 [9/26/2011 Ivan edit]
        CObject_Character player = (CObject_Character)(CObjectManager.Instance.FindCharacterByName(m_szName));

        if (player != null)
        {
            player.GetCharacterData().RefreshName();
        }
        pRelationList.Erase(idx);
        UpdateUIList(RelationGroup);
        return(true);
    }
Exemple #8
0
        internal string GetHeadIcon()
        {
            CObject_Character pCharObj = _GetTargetAsCharacter();

            if (pCharObj.GetCharacterType() == CHARACTER_TYPE.CT_MONSTER)
            {
                CObject_PlayerNPC npc = pCharObj as CObject_PlayerNPC;
                if (npc != null)
                {
                    return(npc.GetPortrait());
                }
                else
                {
                    return("");
                }
            }

            //得到玩家和自己的头像
            string pImageName = "";
            //打开生物定义表
            _DBC_CHAR_FACE pFaceImage = CDataBaseSystem.Instance.GetDataBase <_DBC_CHAR_FACE>(
                (int)DataBaseStruct.DBC_CHAR_FACE).Search_Index_EQU(pCharObj.GetCharacterData().Get_PortraitID());

            if (pFaceImage != null)
            {
                pImageName = pFaceImage.pImageSetName;
            }

            return(pImageName);
        }
Exemple #9
0
    public void DestroyObject(CObject obj)
    {
        if (obj == null)
        {
            return;
        }
        //如果是主目标,取消选择
        if (obj == mMainTarget)
        {
            mMainTarget = null;
        }
        if (obj == mNearestTargetOLD)
        {
            mNearestTargetOLD = null;
        }
        mObjects.Remove(obj.ID);
        mServerObjects.Remove(obj.ServerID);

        //如果被ui关心,发出事件并清除
        int id = obj.ID;

        Dictionary <string, OBJECT_BECARED> .Enumerator enumerator = mapCaredObjects.GetEnumerator();
        while (enumerator.MoveNext())
        {
            OBJECT_BECARED careItem = enumerator.Current.Value;
            if (careItem.id == id)
            {
                //产生事件
                List <string> vParam = new List <string>();
                vParam.Add(id.ToString());
                vParam.Add("destroy");

                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_OBJECT_CARED_EVENT, vParam);

                mapCaredObjects.Remove(enumerator.Current.Key);
                break;
            }
        }

        //删除队列中其他同ID的物体
        enumerator = mapCaredObjects.GetEnumerator();
        while (enumerator.MoveNext())
        {
            OBJECT_BECARED careItem = enumerator.Current.Value;
            if (careItem.id == id)
            {
                mapCaredObjects.Remove(enumerator.Current.Key);
                enumerator = mapCaredObjects.GetEnumerator();
            }
        }



        if (obj.GetParent() != null)
        {
            obj.GetParent().EraseChild(obj);
        }
        obj.Release();
    }
    // 移动一个关系,Srg 是原来的组,guid 是要移动的玩家 GUID,Dtype 是移动后的关系类型,Drg 是移动后的组
    public bool                                                             MoveRelation(RELATION_GROUP Srg, RELATION_TYPE Dtype, RELATION_GROUP Drg, uint guid)
    {
        RelationList pSRelationList;

        pSRelationList = GetRelationList(Srg);
        if (pSRelationList == null)
        {
            return(false);
        }

        RelationList pDRelationList;

        pDRelationList = GetRelationList(Drg);
        if (pDRelationList == null)
        {
            return(false);
        }

        SDATA_RELATION_MEMBER pMember;

        pMember = pSRelationList.GetMemberByGUID(guid);
        if (pMember == null)
        {
            return(false);
        }

        if (pSRelationList.RemoveByGUID(guid))
        {
            UpdateUIList(Srg);

            // 修改关系信息
            pMember.m_RelationType = Dtype;

            string m_szName = pMember.m_szName;
            bool   isFinish = false;
            if (pDRelationList.Add(pMember))
            {
                UpdateUIList(Drg);
                isFinish = true;
            }
            else
            {
                pMember  = null;
                isFinish = false;
            }

            // 必须等add完成后再刷新 [9/26/2011 Ivan edit]
            CObject_Character player = (CObject_Character)(CObjectManager.Instance.FindCharacterByName(m_szName));
            if (player != null)
            {
                player.GetCharacterData().RefreshName();
            }
            return(isFinish);
        }

        return(false);
    }
Exemple #11
0
    //------------
    //角色属性创建/销毁
    //------------
    public CCharacterData CharacterData_Create(CObject_Character character)
    {
        //创建新的角色数据
        CCharacterData pNewCharacterData = new CCharacterData(character);

        m_mapAllCharacterData[character.ID] = pNewCharacterData;

        return(pNewCharacterData);
    }
Exemple #12
0
    //------------
    //学习(升级)门派心法相关 五行属性
    //------------
    public void SendStudySkillEvent(int nSkillIDandLEVEL, int NPCID, int HaveUPLevelSkill)
    {
        int nXinfaID = nSkillIDandLEVEL;
        SCLIENT_SKILLCLASS pXinFa = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_SkillClass(nXinfaID);
        int nXinFaLevel           = pXinFa.m_nLevel;
        int nSelfLevel            = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_Level();
        CObject_Character pMySelf = CObjectManager.Instance.getPlayerMySelf();

        // 判断人物等级是否达到
        if (!isUpLevelXinfaRequirement(nXinfaID, nXinFaLevel + HaveUPLevelSkill))
        {
            CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "Role levle Low");
            return;
        }

        //// 获得升级心法需要的金钱
        Spend needSpend = GetUplevelXinfaSpend(nXinfaID, nXinFaLevel + HaveUPLevelSkill);

        // 获得升级心法需要的经验 [10/13/2011 Ivan edit]
        int myExp = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_Exp();

        if (needSpend.dwSpendExperience > myExp)
        {
            CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "Not enough Exp");
            return;
        }

        ////使用客户端的数据来判断升级的金钱和经验是否够升级
        int nCurMoney = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_Money();

        if (needSpend.dwSpendMoney != -1)
        {
            if (needSpend.dwSpendMoney > nCurMoney)
            {
                CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "Not enough money");
                //ADDTALKMSG("升级需要的金钱不足");
                return;
            }
        }

        if (GetUpLevelXinfaCDTime() > 0)
        {
            CEventSystem.Instance.PushEvent(GAME_EVENT_ID.GE_INFO_SELF, "CD Time");
            return;
        }

        _STUDYXINFA_INFO studyInfo;

        CGAskStudyXinfa msg = (CGAskStudyXinfa)NetManager.GetNetManager().CreatePacket((int)PACKET_DEFINE.PACKET_CG_ASKSTUDYXINFA);

        studyInfo.m_idXinfa  = (short)nXinfaID;                 //技能ID
        studyInfo.m_NowLevel = (short)nXinFaLevel;              //技能等级
        studyInfo.m_idMenpai = (short)NPCID;                    //师父ID
        msg.UplevelInfo      = studyInfo;

        NetManager.GetNetManager().SendPacket(msg);
    }
Exemple #13
0
    protected void DoTrigger(int nLogicCount, int nTargetCount, int[] paTargetIDs)
    {
        SetLogicCount(nLogicCount);

        if (GetSpecialObjData() != null && GetSpecialObjData().m_lpszEffect_Active != null && GetSpecialObjData().m_lpszEffect_Active.Length > 0)
        {
            CObject_Effect pEffectObj = (CObject_Effect)(CObjectManager.Instance.NewEffect(-1));
            if (pEffectObj != null)
            {
                SObject_EffectInit initEffect = new SObject_EffectInit();
                initEffect.m_fvPos         = GetPosition();
                initEffect.m_fvRot         = new UnityEngine.Vector3(0.0f, 0.0f, 0.0f);
                initEffect.m_pszEffectName = GetSpecialObjData().m_lpszEffect_Active;
                initEffect.m_bLoopEffect   = false;
                pEffectObj.Initial(initEffect);
            }
        }


        // 有子弹
        if (GetSpecialObjData() != null && GetSpecialObjData().m_nBulletID != MacroDefine.INVALID_ID)
        {
            SObject_BulletInit initBullet = new SObject_BulletInit();
            initBullet.m_fvPos = GetPosition();

            UnityEngine.Vector3 fvRot = UnityEngine.Vector3.zero;
            fvRot.y                      = GetFaceDir();
            initBullet.m_fvRot           = fvRot;
            initBullet.m_idSend          = (uint)ServerID;
            initBullet.m_nSendLogicCount = GetLogicCount();
            initBullet.m_nBulletID       = m_pSpecialObjData.m_nBulletID;
            initBullet.m_bSingleTarget   = true;
            initBullet.m_fvTargetPos     = new UnityEngine.Vector3(-1.0f, -1.0f, -1.0f);
            for (int i = 0; i < nTargetCount; i++)
            {
                initBullet.m_idTarget = paTargetIDs[i];
                CObject_Bullet pBullet = (CObject_Bullet)CObjectManager.Instance.NewBullet(-1);
                pBullet.Initial(initBullet);
            }
        }
        else
        {
            CObject_Character pCharacter = null;
            for (int i = 0; i < nTargetCount; i++)
            {
                int idCharacter = paTargetIDs[i];
                pCharacter = (CObject_Character)(CObjectManager.Instance.FindServerObject(idCharacter));
                if (pCharacter != null)
                {
                    pCharacter.ShowLogicEvent(ServerID, nLogicCount, true);
                }
            }
        }
    }
Exemple #14
0
        public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer)
        {
            //当前流程是主流程
            if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain)
            {
                CObjectManager pObjectManager = CObjectManager.Instance;
                GCDelObject    delObjPacket   = (GCDelObject)pPacket;
                //判断是否是本场景
                // 将场景ID和资源ID分开,不再使用资源ID代替场景ID [10/24/2011 Sun]
                if (WorldManager.Instance.GetActiveSceneID() != delObjPacket.getSceneID())
                {
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }

                //寻找obj
                CObject           pDelObj = pObjectManager.FindServerObject((int)delObjPacket.getObjID());
                CObject_Character pObj    = pDelObj as CObject_Character;
                LogManager.Log("GCDelObjectHandler ObjID:" + delObjPacket.getObjID());
                if (pObj == null)
                {
                    CObjectManager.Instance.DestroyObject(pDelObj);
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }

                if (CObjectManager.Instance.GetMainTarget() != null && pObj == CObjectManager.Instance.GetMainTarget())
                {
                    CObjectManager.Instance.SetMainTarget(-1, CObjectManager.DESTROY_MAIN_TARGET_TYPE.DEL_OBJECT);
                }
                // 判断obj是否在载具上面,在的话需要删除掉 [8/29/2011 Ivan edit] //todo
                if (pObj.GetCharacterType() == CHARACTER_TYPE.CT_PLAYEROTHER ||
                    pObj.GetCharacterType() == CHARACTER_TYPE.CT_PLAYERMYSELF)
                {
                    if (pObj.GetCharacterData().Get_BusObjID() != MacroDefine.UINT_MAX)
                    {
                        CObject pBus = CObjectManager.Instance.FindServerObject((int)pObj.GetCharacterData().Get_BusObjID());
                        if (pBus != null)
                        {
                            SCommand_Object cmdTemp = new SCommand_Object();
                            cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_BUS_REMOVE_PASSENGER;
                            cmdTemp.SetValue <int>(0, pObj.ServerID);
                            pBus.PushCommand(cmdTemp);
                        }
                    }
                }

                //删除对象
                CObjectManager.Instance.DestroyObject(pObj);
                //之后不能执行任何代码
            }

            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
        }
Exemple #15
0
        public string GetName()
        {
            CObject_Character pCharObj = _GetTargetAsCharacter();

            if (pCharObj != null)
            {
                return(pCharObj.GetCharacterData().Get_Name());
            }
            else
            {
                return("");
            }
        }
Exemple #16
0
        //是否是敌对阵营
        public int IsEnemy()
        {
            CObject_Character pCharObj = (CObject_Character)CObjectManager.Instance.GetMainTarget();

            //选中的不是其他玩家
            //if( g_theKernel.IsKindOf( pCharObj->GetClass(), GETCLASS(CObject_PlayerOther) ) == FALSE )
            //	state->PushInteger( -2 );

            ENUM_RELATION sCamp = GameInterface.Instance.GetCampType(pCharObj, CObjectManager.Instance.getPlayerMySelf());

            if (sCamp != ENUM_RELATION.RELATION_FRIEND)
            {
                return(1);  //敌人
            }
            return(0);
        }
    //// 没用到 public void RemoveLogicEvent(int nLogicCount)
    ////{
    ////    _LOGIC_EVENT pLogicEvent;
    ////    for (int i = 0; i < m_listLogicEvent.Count; i++)
    ////    {
    ////        pLogicEvent = m_listLogicEvent[i];
    ////        if (pLogicEvent.m_nSenderLogicCount == nLogicCount)
    ////        {
    ////            m_listLogicEvent.RemoveAt(i);
    ////            break;
    ////        }
    ////    }
    ////}

    private void DoLogicEvent_Bullet(_LOGIC_EVENT pLogicEvent)
    {
        if (pLogicEvent != null)
        {
            _LOGIC_EVENT_BULLET pBulletInfo = pLogicEvent.m_bullet;
            CObject             pSender     = CObjectManager.Instance.FindServerObject((int)pLogicEvent.m_nSenderID);
            if (pSender != null)
            {
                UnityEngine.Vector3 fvSenderPos      = new UnityEngine.Vector3();
                UnityEngine.Vector3 fvSenderRot      = UnityEngine.Vector3.zero;
                CObject_Character   pCharacterSender = (CObject_Character)pSender;
                fvSenderPos    = pSender.GetPosition();
                fvSenderPos.y += 1.0f;                //temp code
                fvSenderRot.y  = pSender.GetFaceDir();
                if (pCharacterSender != null)
                {
                    if (pBulletInfo.m_pszSenderLocator.Length > 0 &&
                        pCharacterSender.GetRenderInterface() != null)
                    {
                        pCharacterSender.GetRenderInterface().GetLocator(pBulletInfo.m_pszSenderLocator, ref fvSenderPos);
                    }
                }

                SObject_BulletInit initBullet = new SObject_BulletInit();
                initBullet.m_fvPos           = fvSenderPos;
                initBullet.m_fvRot           = fvSenderRot;
                initBullet.m_idSend          = pLogicEvent.m_nSenderID;
                initBullet.m_nSendLogicCount = pLogicEvent.m_nSenderLogicCount;
                initBullet.m_nBulletID       = pBulletInfo.m_nBulletID;
                initBullet.m_bSingleTarget   = pBulletInfo.m_bHitTargetObj;
                if (pBulletInfo.m_bHitTargetObj)
                {
                    initBullet.m_fvTargetPos = new Vector3(-1.0f, -1.0f, -1.0f);
                    initBullet.m_idTarget    = (int)pBulletInfo.m_nTargetID;
                }
                else
                {
                    initBullet.m_fvTargetPos.x = pBulletInfo.m_fTargetX;
                    initBullet.m_fvTargetPos.z = pBulletInfo.m_fTargetZ;
                    initBullet.m_fvTargetPos.y = GFX.GfxUtility.getSceneHeight(pBulletInfo.m_fTargetX, pBulletInfo.m_fTargetZ);
                }

                CObject_Bullet pBullet = CObjectManager.Instance.NewBullet(-1);
                pBullet.Initial(initBullet);
            }
        }
    }
Exemple #18
0
    public void CharacterData_Destroy(CObject_Character character)
    {
        if (character == null)
        {
            throw new NullReferenceException("character is null in CharacterData_Destroy()");
        }
        if (m_mapAllCharacterData.ContainsKey(character.ID))
        {
            m_mapAllCharacterData.Remove(character.ID);

            //是否能成功?
            if (character.IsMySelf(character.ServerID))
            {
                CActionSystem.Instance.CleanInvalidAction();
            }
        }
    }
Exemple #19
0
    /// <summary>
    /// 锁定最近的目标
    /// </summary>
    public CObject_Character LockNearestEnemy()
    {
        if (GetMainTarget() != null && IsEnemy(GetMainTarget()))
        {
            return((CObject_Character)GetMainTarget());
        }

        float fNearestDist                  = 20.0f; //最大允许距离(m)
        CObject_PlayerMySelf myself         = CObjectManager.Instance.getPlayerMySelf();
        CObject_Character    pNearestTarget = (CObject_Character)CObjectManager.Instance.GetNearestTargetByOrigin(myself, fNearestDist, true);

        //锁定该目标
        if (pNearestTarget != null && pNearestTarget != GetMainTarget())
        {
            SetMainTarget(pNearestTarget.ServerID, DESTROY_MAIN_TARGET_TYPE.DEL_OBJECT);
        }
        return(pNearestTarget);
    }
        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);
        }
    public int GetRelationOther(CObject_Character pCharObj)
    {
        if (pCharObj.GetCharacterType() != CHARACTER_TYPE.CT_PLAYEROTHER)
        {
            return(-1);
        }
        _CAMP_DATA playerCampData = GetCharacterData().Get_CampData();

        // 目前只有和平全体组队模式 [8/19/2011 edit by ZL]
        switch (playerCampData.m_nPKModeID)
        {
        case (byte)PK_MODE.PK_MODE_PEACE:
            return(1);

        case (byte)PK_MODE.PK_MODE_GOODBAD:
            return(0);

        case (byte)PK_MODE.PK_MODE_PERSONAL:
            return(0);

        case (byte)PK_MODE.PK_MODE_GUILD:
            //			return pCharObj->GetCharacterData()->Get_Guild() ==
            //				CObjectManager::GetMe()->GetMySelf()->GetCharacterData()->Get_Guild() ? 0 : 1;
            return(0);

        case (byte)PK_MODE.PK_MODE_TEAM:
            //todo
//                     CTeamOrGroup playerTeam = null;
//                     playerTeam = CUIDataPool::GetMe()->GetTeamOrGroup();
//                     for ( int i = 0; i < playerTeam->GetTeamMemberCount(1); ++i ) {
//                         if ( playerTeam->GetMemberByIndex(i, 1)->m_szNick && strcmp(playerTeam->GetMemberByIndex(i, 1)->m_szNick,
//                                     pCharObj->GetCharacterData()->Get_Name()) == 0 ) {
//                             return 1;
//                         }
//                     }
            return(0);

        case (byte)PK_MODE.PK_MODE_FAMILY:
            return(0);

        default: return(1);
        }
        return(-1);
    }
Exemple #22
0
    public void ReceiveTalk(GCChat msg)
    {
        ENUM_CHAT_TYPE chatType = (ENUM_CHAT_TYPE)msg.ChatType;
        string         name     = EncodeUtility.Instance.GetUnicodeString(msg.SourName) + ":";
        string         text     = Encoding.UTF8.GetString(msg.Contex);
        // 删除不必要的多余字符
        string showText = (name + text).Replace("\0", "");

        if (chatType == ENUM_CHAT_TYPE.CHAT_TYPE_NORMAL)
        {
            ShowChat(showText, chatType);
            CObject_Character talker = (CObject_Character)CObjectManager.Instance.FindServerObject((int)msg.SourObject);
            talker.ShowTalk(text);
        }
        else if (chatType == ENUM_CHAT_TYPE.CHAT_TYPE_TELL)//私聊
        {
            ShowChat(showText, chatType);
        }
    }
Exemple #23
0
    public OPERATE_RESULT IsCanUse_CheckLevel(int idUser, int idLevel)
    {
        CObject_Character pUser = (CObject_Character)(CObjectManager.Instance.FindObject(idUser));

        if (pUser == null)
        {
            return(OPERATE_RESULT.OR_ERROR);
        }
        int iSkillClass = m_pDefine.m_nSkillClass;
        int iLevel      = m_nLevel - 1;

        if (iLevel < 0)
        {
            iLevel = 0;
        }
        // 得到技能对应的心法数据
        SCLIENT_SKILLCLASS pSkillClass = CObjectManager.Instance.getPlayerMySelf().GetCharacterData().Get_SkillClass(iSkillClass);

        if (pSkillClass != null)
        {
            // 技能数据id
            int iSkillData_V1ID = 0;
            if (iLevel < 12)// 境界心法超过12级 [4/19/2012 SUN]
            {
                iSkillData_V1ID = m_pDefine.m_anSkillByLevel[iLevel];
            }
            else if (pSkillClass.IsJingJie())
            {
                iSkillData_V1ID = m_pDefine.m_anSkillByLevel[11];
            }
            //打开数据表
            _DBC_SKILLDATA_V1_DEPLETE pSkillData_V1 = CDataBaseSystem.Instance.GetDataBase <_DBC_SKILLDATA_V1_DEPLETE>((int)DataBaseStruct.DBC_SKILLDATA_V1_DEPLETE).Search_Index_EQU(iSkillData_V1ID);
            //搜索纪录
            if (pSkillData_V1 != null)
            {
                if (pSkillData_V1.nNeedLevel > pUser.GetCharacterData().Get_Level())
                {
                    return(OPERATE_RESULT.OR_NEED_HIGH_LEVEL_XINFA);
                }
            }
        }
        return(OPERATE_RESULT.OR_OK);
    }
Exemple #24
0
        public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer)
        {
            GCCharImpactListUpdate Packet = (GCCharImpactListUpdate)pPacket;

            if (GameProcedure.GetActiveProcedure() == GameProcedure.s_ProcMain)
            {
                CObject pObj = CObjectManager.Instance.FindServerObject(Packet.OwnerID);
                if (pObj != null)
                {
                    ////如果需要更新资源,尝试放入缓冲队列
                    //if(pObjectManager->GetLoadQueue()->TryAddLoadTask(pObj->GetID(), pPacket))
                    //	return PACKET_EXE_NOTREMOVE;

                    CObject_Character pChar = (CObject_Character)pObj;
                    if (pChar != null)
                    {
                        pChar.RemoveAllImpact();
                    }
                    SimpleImpactList ImpactList = new SimpleImpactList();

                    for (short i = 0; i < Packet.NumImpact; i++)
                    {
                        SCommand_Object cmdTemp = new SCommand_Object();
                        cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_UPDATE_IMPACT_EX;
                        cmdTemp.SetValue <short>(0, Packet.ImpactID[i]);
                        pObj.PushCommand(cmdTemp);
                        ImpactList.AddImpact(Packet.ImpactID[i]);
                    }
                    //待实现
                    //CTeamOrGroup* pTeam = CUIDataPool::GetMe()->GetTeamOrGroup();
                    //if ( pTeam != NULL )
                    //{
                    //    pTeam->UpdateImpactsList( pPacket->GetOwnerID(), &ImpactList );
                    //}

                    //pObj->PushDebugString("GCCharImpactListUpdate");
                    pObj.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow());
                }
                LogManager.Log("RECV GCCharImpactListUpdate");
            }
            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
        }
Exemple #25
0
    // 解散队伍
    public void DismissTeam()
    {
        switch (m_Type)
        {
        case TEAM_OR_GROUP_TYPE.TEAM_TYPE:
        {         // 队伍的情况
            for (int i = 0; i < m_TeamMembers.Count; i++)
            {
                // 更新队员头顶信息颜色 [10/9/2011 Ivan edit]
                CObject_Character player = CObjectManager.Instance.FindServerObject((int)m_TeamMembers[i].m_OjbID) as CObject_Character;
                if (player != null)
                {
                    player.GetCharacterData().RefreshName();
                }
            }
            m_TeamMembers.Clear();
        }
        break;

        case TEAM_OR_GROUP_TYPE.GROUP_TYPE:
        {
            m_TeamInfo.Clear();
        }
        break;

        default:
            return;
        }

        CleanUp();

        //设置角色层数据
        CObject_PlayerMySelf self = CObjectManager.Instance.getPlayerMySelf();

        if (self != null)
        {
            self.GetCharacterData().Set_HaveTeamFlag(false);
            self.GetCharacterData().Set_TeamLeaderFlag(false);
            self.GetCharacterData().Set_TeamFullFlag(false);
            self.GetCharacterData().Set_TeamFollowFlag(false);
        }
    }
Exemple #26
0
    bool RemovePassenger(uint nPassengerID)
    {
        if (nPassengerID == 0)
        {
            return(false);
        }

        int nCount = GetPassengerCount();

        if (nCount > 0)
        {
            int i;
            for (i = 0; i < nCount; i++)
            {
                if (m_anPassengerIDs[i] == nPassengerID)
                {
                    if (m_abPassengerAttacheds[i] && GetRenderInterface() != null)
                    {
                        CObject pObj = CObjectManager.Instance.FindServerObject((int)m_anPassengerIDs[i]);
                        if (pObj != null && pObj.GetRenderInterface() != null)
                        {
                            CObject_Character player = pObj as CObject_Character;
                            if (player != null)
                            {
                                player.GetCharacterData().Set_BusObjID(0);
                            }
                            GetRenderInterface().Detach_Object(pObj.GetRenderInterface());
                            pObj.SetMapPosition(pObj.GetPosition().x, pObj.GetPosition().z);                        //角色离开飞行坐骑后刷新自己的位置  [8/22/2011 zzy]
                        }
                    }
                    m_anPassengerIDs[i]                = m_anPassengerIDs[nCount - 1];
                    m_abPassengerAttacheds[i]          = m_abPassengerAttacheds[nCount - 1];
                    m_anPassengerIDs[nCount - 1]       = 0;
                    m_abPassengerAttacheds[nCount - 1] = false;
                    // 减少乘客 [8/26/2011 ivan edit]
                    --m_nPassengerCount;
                    return(true);
                }
            }
        }
        return(false);
    }
 protected void AlreadyHit()
 {
     if (m_idTarget != MacroDefine.INVALID_ID)
     {
         CObject_Character pChar = (CObject_Character)CObjectManager.Instance.FindServerObject(m_idTarget);
         if (pChar != null)
         {
             pChar.ShowLogicEvent((int)m_idSend, m_nSendLogicCount, true);
         }
     }
     m_bAlreadyHit = true;
     if (m_pBulletData != null && m_pBulletData.m_szHitEffect.Length > 0)
     {
         ChangEffect(m_pBulletData.m_szHitEffect, false);
     }
     else
     {
         Release();
     }
 }
Exemple #28
0
    public CObject_Character FindCharacterByName(string szName)
    {
        CObject_Character pObject = null;

        if (mServerObjects.Count > 0)
        {
            foreach (int k in mServerObjects.Keys)
            {
                if (mServerObjects[k] is CObject_Character)
                {
                    CObject_Character character = (CObject_Character)mServerObjects[k];
                    if (character.GetCharacterData().Get_Name() == szName)
                    {
                        pObject = character;
                        break;
                    }
                }
            }
        }
        return(pObject);
    }
    // 从名单里移除,并释放数据
    public virtual bool                                             Erase(int idx)
    {
        if (m_vecRelationMember.Count <= idx || idx < 0)
        {
            return(false);
        }

        // 更新好友信息 [9/26/2011 Ivan edit]
        CObject_Character player = (CObject_Character)(CObjectManager.Instance.FindServerObject(
                                                           (int)m_vecRelationMember[idx].m_GUID));

        if (player != null)
        {
            player.GetCharacterData().RefreshName();
        }

        //   SAFE_DELETE( m_vecRelationMember[idx] );
        m_vecRelationMember.RemoveAt(idx);

        return(true);
    }
Exemple #30
0
    internal CObject FindCharacterByTableID(int idTable)
    {
        CObject_Character pObject = null;

        if (mServerObjects.Count != 0)
        {
            foreach (CObject obj in mServerObjects.Values)
            {
                CObject_Character npc = obj as CObject_Character;
                if (npc != null)
                {
                    if (idTable == npc.GetCharacterData().Get_RaceID())
                    {
                        pObject = npc;
                        break;
                    }
                }
            }
        }

        return(pObject);
    }