public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer)
        {
            GCCharDirectImpact Packet = (GCCharDirectImpact)pPacket;

            if (GameProcedure.GetActiveProcedure() == GameProcedure.s_ProcMain)
            {
                CObject pObj = CObjectManager.Instance.FindServerObject(Packet.RecieverID);
                if (pObj != null)
                {
                    _DAMAGE_INFO infoDamage = new _DAMAGE_INFO();
                    infoDamage.m_nSkillID          = Packet.SkillID;
                    infoDamage.m_nTargetID         = (uint)Packet.RecieverID;
                    infoDamage.m_nSenderID         = (uint)Packet.SenderID;
                    infoDamage.m_nSenderLogicCount = Packet.SenderLogicCount;
                    infoDamage.m_nImpactID         = Packet.ImpactID;
                    infoDamage.m_nType             = _DAMAGE_INFO.DAMAGETYPE.TYPE_EFFECT;

                    _LOGIC_EVENT logicEvent = new _LOGIC_EVENT();
                    logicEvent.Init(infoDamage.m_nSenderID, infoDamage.m_nSenderLogicCount, infoDamage);

                    SCommand_Object cmdTemp = new SCommand_Object();
                    cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_LOGIC_EVENT;
                    cmdTemp.SetValue <object>(0, logicEvent);
                    pObj.PushCommand(cmdTemp);
                    pObj.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow());
                }
                LogManager.Log("RECV GCCharDirectImpact");
            }
            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
        }
Exemple #2
0
        public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer)
        {
            if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain)
            {
                LogManager.Log("Receive GCDetailHealsAndDamages Packet");
                GCDetailHealsAndDamages Packet = (GCDetailHealsAndDamages)pPacket;
                CObject pObj = CObjectManager.Instance.FindServerObject((int)Packet.RecieverID);
                if (pObj != null)
                {
                    _DAMAGE_INFO infoDamage = new _DAMAGE_INFO();
                    infoDamage.m_nSkillID = Packet.SkillID;

                    if (infoDamage.m_nSkillID != MacroDefine.INVALID_ID)
                    {
                        _DBC_SKILL_DATA skillData = CSkillDataMgr.Instance.GetSkillData((uint)infoDamage.m_nSkillID);
                        if (skillData != null)
                        {
                            infoDamage.m_nBulletID = skillData.m_nBulletID;
                        }
                    }

                    infoDamage.m_nTargetID         = (uint)Packet.RecieverID;
                    infoDamage.m_nSenderID         = (uint)Packet.SenderID;
                    infoDamage.m_nSenderLogicCount = Packet.SenderLogicCount;
                    infoDamage.m_nImpactID         = MacroDefine.INVALID_ID;
                    infoDamage.m_nType             = _DAMAGE_INFO.DAMAGETYPE.TYPE_HEAL_AND_DAMAGE;
                    if (Packet.IsHpModificationDirty())
                    {
                        infoDamage.m_bHealthDirty     = true;
                        infoDamage.m_nHealthIncrement = Packet.HPModification;
                    }
                    if (Packet.IsMpModificationDirty())
                    {
                        infoDamage.m_bManaDirty     = true;
                        infoDamage.m_nManaIncrement = Packet.MPModification;
                    }
                    if (Packet.IsRageModificationDirty())
                    {
                        infoDamage.m_bRageDirty     = true;
                        infoDamage.m_nRageIncrement = Packet.RageModification;
                    }
                    if (Packet.IsStrikePointModificationDirty())
                    {
                        infoDamage.m_bStrikePointDirty     = true;
                        infoDamage.m_nStrikePointIncrement = Packet.StrikePointModification;
                    }
                    infoDamage.m_bIsCriticalHit = Packet.CriticalHit;

                    _LOGIC_EVENT logicEvent = new _LOGIC_EVENT();
                    logicEvent.Init((uint)Packet.SenderID, Packet.SenderLogicCount, infoDamage);

                    SCommand_Object cmdTemp = new SCommand_Object();
                    cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_LOGIC_EVENT;
                    cmdTemp.SetValue <object>(0, logicEvent);
                    pObj.PushCommand(cmdTemp);
                }
            }
            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
        }
 public void AddLogicEvent(_LOGIC_EVENT pLogicEvent)
 {
     if (pLogicEvent != null)
     {
         _LOGIC_EVENT pNewLogicEvent = new _LOGIC_EVENT();
         pNewLogicEvent = pLogicEvent;
         pNewLogicEvent.m_uBeginTime  = (uint)GameProcedure.s_pTimeSystem.GetTimeNow();
         pNewLogicEvent.m_uRemoveTime = 10000;
         m_listLogicEvent.Add(pNewLogicEvent);
     }
 }
    //// 没用到 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);
            }
        }
    }
    public void DoLogicEvent(_LOGIC_EVENT pLogicEvent)
    {
        if (pLogicEvent != null)
        {
            switch (pLogicEvent.m_nEventType)
            {
            case ENUM_LOGIC_EVENT_TYPE.LOGIC_EVENT_TYPE_BULLET:
                DoLogicEvent_Bullet(pLogicEvent);
                break;

            case ENUM_LOGIC_EVENT_TYPE.LOGIC_EVENT_TYPE_DAMAGE:
                DoLogicEvent_Damage(pLogicEvent);
                break;

            default:
                break;
            }
        }
    }
        public override NET_RESULT_DEFINE.PACKET_EXE Execute(PacketBase pPacket, ref Peer pPlayer)
        {
            if (GameProcedure.GetActiveProcedure() == (GameProcedure)GameProcedure.s_ProcMain)
            {
                GCTargetListAndHitFlags Packet = (GCTargetListAndHitFlags)pPacket;
                CObject pObj = CObjectManager.Instance.FindServerObject(Packet.ObjID);
                LogManager.Log("Receive GCTargetListAndHitFlags Packet " + Packet.ObjID + " BulletID: " + Packet.SkillOrSpecialObjDataID + " TargetID: " + Packet.TargetID);
                if (pObj == null)
                {
                    return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
                }

                string pszSenderLocator = "";
                bool   bHitCharacter    = false;
                int    nBulletID        = MacroDefine.INVALID_ID;
                if ((byte)GCTargetListAndHitFlags.TARGETTYPE.SPECIAL_OBJ_ACTIVATE == Packet.DataType)
                {
                    _DBC_SPECIAL_OBJ_DATA pSpecialObjData = CDataBaseSystem.Instance.GetDataBase <_DBC_SPECIAL_OBJ_DATA>((int)DataBaseStruct.DBC_SPECIAL_OBJ_DATA).Search_Index_EQU((int)Packet.SkillOrSpecialObjDataID);
                    if (pSpecialObjData != null)
                    {
                        nBulletID        = pSpecialObjData.m_nBulletID;
                        bHitCharacter    = true;
                        pszSenderLocator = "";
                    }
                }
                else
                {
                    _DBC_SKILL_DATA skillData = CSkillDataMgr.Instance.GetSkillData((uint)Packet.SkillOrSpecialObjDataID);
                    if (skillData != null)
                    {
                        nBulletID        = skillData.m_nBulletID;
                        pszSenderLocator = skillData.m_pszBulletSendLocator;
                        switch ((ENUM_SELECT_TYPE)skillData.m_nSelectType)
                        {
                        case ENUM_SELECT_TYPE.SELECT_TYPE_POS:
                        case ENUM_SELECT_TYPE.SELECT_TYPE_DIR:
                            bHitCharacter = false;
                            break;

                        case ENUM_SELECT_TYPE.SELECT_TYPE_NONE:
                        case ENUM_SELECT_TYPE.SELECT_TYPE_CHARACTER:
                        case ENUM_SELECT_TYPE.SELECT_TYPE_SELF:
                        default:
                            bHitCharacter = true;
                            break;
                        }
                    }
                }

                if (nBulletID != MacroDefine.INVALID_ID)
                {
                    _LOGIC_EVENT_BULLET infoBullet = null;
                    if (bHitCharacter)
                    {
                        CObject_Character pCharacter = (CObject_Character)pObj;
                        // CObject_Special   pSpecial = (CObject_Special)pObj;
                        if (pCharacter != null)
                        {
                            for (byte i = 0; i < Packet.TargetNum; i++)
                            {
                                infoBullet                    = new _LOGIC_EVENT_BULLET();
                                infoBullet.m_nBulletID        = nBulletID;
                                infoBullet.m_pszSenderLocator = pszSenderLocator;
                                infoBullet.m_bHitTargetObj    = bHitCharacter;
                                _LOGIC_EVENT logicEvent = new _LOGIC_EVENT();
                                logicEvent.Init((uint)Packet.ObjID, Packet.LogicCount, infoBullet);
                                SCommand_Object cmdTemp = new SCommand_Object();
                                cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_LOGIC_EVENT;
                                logicEvent.m_bullet.m_nTargetID = (uint)Packet.TargetList[i];
                                cmdTemp.SetValue <object>(0, (object)logicEvent);
                                pCharacter.PushCommand(cmdTemp);
                            }
                        }
                        //else if(pSpecial != null)
                        //{

                        //}
                    }
                    else
                    {
                        infoBullet                    = new _LOGIC_EVENT_BULLET();
                        infoBullet.m_nBulletID        = nBulletID;
                        infoBullet.m_pszSenderLocator = pszSenderLocator;
                        infoBullet.m_bHitTargetObj    = bHitCharacter;

                        infoBullet.m_fTargetX = Packet.PosTarget.m_fX;
                        infoBullet.m_fTargetZ = Packet.PosTarget.m_fZ;
                        _LOGIC_EVENT logicEvent = new _LOGIC_EVENT();
                        logicEvent.Init((uint)Packet.ObjID, Packet.LogicCount, infoBullet);
                        SCommand_Object cmdTemp = new SCommand_Object();
                        cmdTemp.m_wID = (int)OBJECTCOMMANDDEF.OC_LOGIC_EVENT;
                        cmdTemp.SetValue <object>(0, (object)logicEvent);

                        CObject_Character pCharacter = (CObject_Character)pObj;
                        // CObject_Special   pSpecial   = (CObject_Special)pObj;
                        if (pCharacter != null)
                        {
                            pCharacter.PushCommand(cmdTemp);
                        }
                        //  else if(pSpecial != null)
                        // {
                        // CObject_Special *pSpecial = (CObject_Special*)pObj;
                        // }
                    }
                }
                pObj.SetMsgTime(GameProcedure.s_pTimeSystem.GetTimeNow());
            }

            return(NET_RESULT_DEFINE.PACKET_EXE.PACKET_EXE_CONTINUE);
        }
    private void DoLogicEvent_Damage(_LOGIC_EVENT pLogicEvent)
    {
        _DAMAGE_INFO pDamageInfo = pLogicEvent.m_damage;

        switch (pDamageInfo.m_nType)
        {
        case _DAMAGE_INFO.DAMAGETYPE.TYPE_INVALID:
            break;

        case _DAMAGE_INFO.DAMAGETYPE.TYPE_EFFECT:
        {
            LogManager.Log("_DAMAGE_INFO.DAMAGETYPE.TYPE_EFFECT " + m_Character.ServerID);
            if (pDamageInfo.m_nImpactID != MacroDefine.INVALID_ID)
            {
                _DBC_DIRECT_IMPACT pDirectImpact = CDirectlyImpactMgr.Instance.GetDirectlyImpact((uint)pDamageInfo.m_nImpactID);
                if (pDirectImpact != null)
                {
                    Vector3 fvPos = new Vector3();

                    if (m_Character.GetRenderInterface() != null && pDirectImpact.m_pszEffectLocator.Length != 0)
                    {
                        m_Character.GetRenderInterface().GetLocator(pDirectImpact.m_pszEffectLocator, ref fvPos);
                    }
                    else
                    {
                        fvPos = m_Character.GetPosition();
                    }

                    if (pDirectImpact.m_pszEffect.Length > 0)
                    {
                        CObject_Effect pObjEffect = CObjectManager.Instance.NewEffect(-1);
                        if (pObjEffect != null)
                        {
                            SObject_EffectInit initEffect = new SObject_EffectInit();
                            initEffect.m_fvPos         = fvPos;
                            initEffect.m_fvRot         = new Vector3(0.0f, 0.0f, 0.0f);
                            initEffect.m_pszEffectName = pDirectImpact.m_pszEffect;
                            initEffect.m_bLoopEffect   = false;
                            pObjEffect.Initial(initEffect);
                        }
                    }

                    if (pDirectImpact.m_pszSound.Length > 0)
                    {
                        fvPos = m_Character.GetPosition();
                        // Vector3 fvGame = new Vector3();

                        //if(!CGameProcedure::s_pGfxSystem.Axis_Trans(CRenderSystem::AX_GAME, fvPos,
                        //    CRenderSystem::AX_GFX, fvGame))
                        //{
                        //    return;
                        //}
                        //CSoundSystemFMod::_PlaySoundFunc( pDirectlyImpact.m_pszSound, &fvGame.x, false );
                    }
                }
            }
        }
        break;

        case _DAMAGE_INFO.DAMAGETYPE.TYPE_HEAL_AND_DAMAGE:
        {
            LogManager.Log("_DAMAGE_INFO.DAMAGETYPE.TYPE_HEAL_AND_DAMAGE " + this.m_Character.ServerID + " pDamageInfo.m_nHealthIncrement " + pDamageInfo.m_nHealthIncrement);
            if (pDamageInfo.m_nHealthIncrement < 0)
            {
                this.m_Character.SetFightState(true);
                LogManager.Log("pDamageInfo.m_nHealthIncrement " + this.m_Character.ServerID + " CharacterLogic_Get " + m_Character.CharacterLogic_Get());
                if (m_Character.CharacterLogic_Get() == ENUM_CHARACTER_LOGIC.CHARACTER_LOGIC_IDLE)
                {
                    LogManager.Log("pDamageInfo.BASE_ACTION_F_BE_HIT " + this.m_Character.ServerID);
                    m_Character.ChangeAction((int)ENUM_BASE_ACTION.BASE_ACTION_F_BE_HIT, 1.0f, false, CObject_Character.sDefaultActionFuseTime);
                }
            }
            // 显示伤血信息
            DisplayDamageBoard(pDamageInfo);
        }
        break;

        case _DAMAGE_INFO.DAMAGETYPE.TYPE_DROP_BOX:
        {
            uint  ObjID   = (uint)pDamageInfo.m_aAttachedParams[0];
            int   idOwner = pDamageInfo.m_aAttachedParams[1];
            float fX      = pDamageInfo.m_aAttachedParams[2] / 1000.0f;
            float fZ      = pDamageInfo.m_aAttachedParams[3] / 1000.0f;
            //创建ItemBox
            CTripperObject_ItemBox pBox = CObjectManager.Instance.NewTripperItemBox((int)ObjID);
            pBox.Initial(null);
            //设置位置
            pBox.SetMapPosition(fX, fZ);
            //设置掉落箱的归属
            pBox.SetOwnerGUID((uint)idOwner);
        }
        break;

        case _DAMAGE_INFO.DAMAGETYPE.TYPE_SKILL_TEXT:
        {
            // 显示未击中和免疫信息
            DisplayMissImmuAndSoOn(pDamageInfo);
        }
        break;

        case _DAMAGE_INFO.DAMAGETYPE.TYPE_DIE:
        {
            m_Character.OnDead(true);
        }
        break;

        default:
            break;
        }
    }