private BulletTriggerCollisionEnter m_TriggerCollisionEnter; //碰撞检测器

    public override void OnInitialize(IBulletAppearanceProperty property)
    {
        m_Property = property;
        m_BulletTf = m_Property.GetTransform();

        CfgEternityProxy cfgEternity = GameFacade.Instance.RetrieveProxy(ProxyName.CfgEternityProxy) as CfgEternityProxy;
        int flyerdataId = m_Property.GetFlyerDataId();

        m_FlyerData = cfgEternity.GetFlyerData(flyerdataId);

        BaseEntity bulletOwerEntity = GameplayManager.Instance.GetEntityManager().GetEntityById <BaseEntity>(m_Property.GetOwnerSpacecaftEntityId());
        BaseEntity targetEnity      = m_Property.IsHaveTarget() ? GameplayManager.Instance.GetEntityManager().GetEntityById <BaseEntity>(m_Property.GetTargetEntityID()) : null;
        Vector3    targetPoint      = m_Property.GetTargetPoint();

        m_TriggerCollisionEnter = m_BulletTf.GetOrAddComponent <BulletTriggerCollisionEnter>();

        m_TriggerCollisionEnter.Init(bulletOwerEntity,                       //子弹拥有者Enity
                                     m_Property.GetOwner(),                  //子弹Enity
                                     m_FlyerData.BaseData.Value.IsRigibody,  //碰撞后单位是否继续飞 ,刚体爆炸,非刚体继续飞
                                     m_Property.IsHaveTarget(),              //是否指定了目标
                                     targetEnity,                            //指定的飞向的目标
                                     targetPoint,                            //指定的飞向的点
                                     m_FlyerData.BaseData.Value.FactionType, //碰撞后的阵营判断
                                     TriggerToEnitity);                      //碰撞后的回调函数


        string assetPath = m_FlyerData.BaseData.Value.ApperanceAddress;

        if (!string.IsNullOrEmpty(assetPath))
        {
            AssetUtil.InstanceAssetAsync(assetPath,
                                         (pathOrAddress, returnObject, userData) =>
            {
                if (returnObject != null)
                {
                    GameObject pObj = (GameObject)returnObject;
                    OnLoadModel(pObj);
                }
                else
                {
                    Debug.LogError(string.Format("资源加载成功,但返回null,  pathOrAddress = {0}", pathOrAddress));
                }
            });
        }
    }
Exemple #2
0
        /// <summary>
        /// 其他上下文需要携带的数据
        /// </summary>
        private void ContextAddOtherObject()
        {
            FlyerData flyerData = m_CfgEternityProxy.GetFlyerData(m_FlyerProprety.GetFlyerDataId());

            m_Context.AddObject <FlyerData>(flyerData);
        }