Exemplo n.º 1
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);
                }
            }
        }
    }
    //// 没用到 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);
            }
        }
    }