public override void Trigger()
        {
            IBaseActionProperty         property         = m_Context.GetObject <IBaseActionProperty>();
            AddBindLinkTargetEffectData data             = GetData <AddBindLinkTargetEffectData>();
            IBindNodeActionProperty     bindNodeProperty = m_Context.GetObject <IBindNodeActionProperty>();

            ActionTarget actionTarget = SelectionTargetUtil.GetActionTarget(m_Context, data.TargetSelection.Value);

            if (actionTarget == null || actionTarget.TargetType == ActionTargetType.None)
            {
                Leyoutech.Utility.DebugUtility.LogWarning("AddBindLinkTargetEffectAction", "AddBindLinkTargetEffectAction::Trigger->target not found");
                return;
            }

            List <Transform> bindTransforms = null;

            if (bindNodeProperty.GetPresentation() == null)
            {
                Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1} " +
                                                                                "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                property.EntityId(),
                                                                                property.GetItemID()));

                bindTransforms = new List <Transform>();
                bindTransforms.Add(property.GetRootTransform());
            }
            else
            {
                bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(data.NodeType.ToLaunchPoint(), data.NodeIndex);
            }


            foreach (var tran in bindTransforms)
            {
                if (actionTarget.TargetType == ActionTargetType.Entity)
                {
                    if (data.TargetSelection.Value.TargetSecondType == Eternity.FlatBuffer.Enums.TargetSecondType.Entity)
                    {
                        EffectActionUtil.CreateEffect(data.Address, tran, property.IsMain(), actionTarget.TargetEntity, Vector3.zero);
                    }
                    else
                    {
                        EffectActionUtil.CreateEffect(data.Address, tran, property.IsMain(), actionTarget.TargetEntity, actionTarget.TargetEntityHitPositionOffet);
                    }
                }
                else
                {
                    EffectActionUtil.CreateEffect(data.Address, tran, property.IsMain(), actionTarget.TargetPosition);
                }
            }
        }
        public override void Trigger()
        {
            EmitSelectionData emitSelectionData = m_Context.GetObject <SkillRunningData>().EmitSelectoin;

            int      assignIndex = GetData <NextLoopEmitNodeData>().AssignIndex;
            EmitData emitData    = emitSelectionData.GetEmit(assignIndex);

            if (emitData != null)
            {
                IBindNodeActionProperty bindNodeProperty = m_Context.GetObject <IBindNodeActionProperty>();
                IBaseActionProperty     property         = m_Context.GetObject <IBaseActionProperty>();

                List <Transform> bindTransforms = null;
                if (bindNodeProperty.GetPresentation() == null)
                {
                    Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1} " +
                                                                                    "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                    property.EntityId(),
                                                                                    property.GetItemID()));

                    bindTransforms = new List <Transform>();
                    bindTransforms.Add(property.GetRootTransform());
                }
                else
                {
                    bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(emitData.NodeType.ToLaunchPoint(), -1);
                }


                if (emitData.NodeIndex + 1 >= bindTransforms.Count)
                {
                    emitData.NodeIndex = 0;
                }
                else
                {
                    emitData.NodeIndex++;
                }
            }
            else
            {
                Debug.LogError($"NextLoopEmitNodeAction::Trigger->EmitData not found.assignIndex = {assignIndex}.");
            }
        }
        public override void DoEnter()
        {
            EmitSelectionData   emitSelectionData = m_Context.GetObject <SkillRunningData>().EmitSelectoin;
            IBaseActionProperty property          = m_Context.GetObject <IBaseActionProperty>();

            AddEmitDurationEffectData data = GetData <AddEmitDurationEffectData>();

            EmitData[] emitDatas = emitSelectionData.GetEmits(data.EmitIndex);
            IBindNodeActionProperty bindNodeProperty = m_Context.GetObject <IBindNodeActionProperty>();

            for (int i = 0; emitDatas != null && i < emitDatas.Length; i++)
            {
                EmitData emitData = emitDatas[i];

                List <Transform> bindTransforms = null;
                if (bindNodeProperty.GetPresentation() == null)
                {
                    Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1} " +
                                                                                    "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                    property.EntityId(),
                                                                                    property.GetItemID()));

                    bindTransforms = new List <Transform>();
                    bindTransforms.Add(property.GetRootTransform());
                }
                else
                {
                    bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(emitData.NodeType.ToLaunchPoint(), emitData.NodeIndex);
                }


                foreach (var tran in bindTransforms)
                {
                    EffectController effect = EffectActionUtil.CreateEffect(data.Address, tran, property.IsMain());
                    effects.Add(effect);
                }
            }
        }
        public override void Trigger()
        {
            PlayEntityBindSoundData data               = GetData <PlayEntityBindSoundData>();
            IBindNodeActionProperty bindNodeProperty   = m_Context.GetObject <IBindNodeActionProperty>();
            IBaseActionProperty     baseActionProperty = m_Context.GetObject <IBaseActionProperty>();

            List <Transform> bindTransforms = null;

            if (bindNodeProperty.GetPresentation() == null)
            {
                Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1} " +
                                                                                "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                baseActionProperty.EntityId(),
                                                                                baseActionProperty.GetItemID()));

                bindTransforms = new List <Transform>();
                bindTransforms.Add(baseActionProperty.GetRootTransform());
            }
            else
            {
                bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(data.NodeType.ToLaunchPoint(), data.NodeIndex);
            }


            foreach (var tran in bindTransforms)
            {
                if (baseActionProperty.IsMain())
                {
                    WwiseUtil.PlaySound(data.MainSoundID, false, tran);
                }
                else
                {
                    WwiseUtil.PlaySound(data.ThirdPartSoundID, false, tran);
                }
            }
        }
Exemplo n.º 5
0
        public override void Trigger()
        {
            EmitSelectionData       emitSelectionData  = m_Context.GetObject <SkillRunningData>().EmitSelectoin;
            IBindNodeActionProperty bindNodeProperty   = m_Context.GetObject <IBindNodeActionProperty>();
            IBaseActionProperty     baseActionProperty = m_Context.GetObject <IBaseActionProperty>();
            PlayEmitSoundData       nodeData           = GetData <PlayEmitSoundData>();

            EmitData[] emitDatas = emitSelectionData.GetEmits(nodeData.EmitIndex);
            if (emitDatas != null && emitDatas.Length > 0)
            {
                foreach (var emitData in emitDatas)
                {
                    List <Transform> bindTransforms = null;
                    if (bindNodeProperty.GetPresentation() == null)
                    {
                        Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1} " +
                                                                                        "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                        baseActionProperty.EntityId(),
                                                                                        baseActionProperty.GetItemID()));

                        bindTransforms = new List <Transform>();
                        bindTransforms.Add(baseActionProperty.GetRootTransform());
                    }
                    else
                    {
                        bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(emitData.NodeType.ToLaunchPoint(), emitData.NodeIndex);
                    }


                    foreach (var tran in bindTransforms)
                    {
                        if (baseActionProperty.IsMain())
                        {
                            WwiseUtil.PlaySound(nodeData.MainSoundID, false, tran);
                        }
                        else
                        {
                            WwiseUtil.PlaySound(nodeData.ThirdPartSoundID, false, tran);
                        }
                    }
                }
            }
            else
            {
            }
        }
        public override void DoEnter()
        {
            EmitSelectionData emitSelectionData = m_Context.GetObject <SkillRunningData>().EmitSelectoin;

            // IBaseActionProperty property = m_Context.GetObject<IBaseActionProperty>();
            // AddEmitLinkTargetDurationEffectData data = GetData<AddEmitLinkTargetDurationEffectData>();
            EmitData[] emitDatas = emitSelectionData.GetEmits(aeeData.EmitIndex);
            if (emitDatas == null || emitDatas.Length == 0)
            {
                Leyoutech.Utility.DebugUtility.LogWarning("AddEmitLinkTargetDurationEffectAction", "AddEmitLinkTargetDurationEffectAction::DoEnter->emitData not found");
                return;
            }

            actionTarget = SelectionTargetUtil.GetActionTarget(m_Context, aeeData.TargetSelection.Value);
            if (actionTarget == null || actionTarget.TargetType == ActionTargetType.None)
            {
                Leyoutech.Utility.DebugUtility.LogWarning("AddEmitLinkTargetDurationEffectAction", "AddEmitLinkTargetDurationEffectAction::DoEnter->target not found");
                return;
            }

            IBindNodeActionProperty bindNodeProperty = m_Context.GetObject <IBindNodeActionProperty>();

            for (int i = 0; i < emitDatas.Length; ++i)
            {
                EmitData emitData = emitDatas[i];

                if (bindNodeProperty.GetPresentation() == null)
                {
                    Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1}" +
                                                                                    "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                    property.EntityId(),
                                                                                    property.GetItemID()
                                                                                    ));

                    bindTransforms = new List <Transform>();
                    bindTransforms.Add(property.GetRootTransform());
                }
                else
                {
                    bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(emitData.NodeType.ToLaunchPoint(), emitData.NodeIndex);
                }

                foreach (var tran in bindTransforms)
                {
                    EffectController effect = null;
                    if (actionTarget.TargetType == ActionTargetType.Entity)
                    {
                        if (aeeData.TargetSelection.Value.TargetSecondType == Eternity.FlatBuffer.Enums.TargetSecondType.Entity)
                        {
                            effect = EffectActionUtil.CreateEffect(aeeData.Address, tran, property.IsMain(), actionTarget.TargetEntity, Vector3.zero);
                        }
                        else
                        {
                            effect = EffectActionUtil.CreateEffect(aeeData.Address, tran, property.IsMain(), actionTarget.TargetEntity, actionTarget.TargetEntityHitPositionOffet);
                        }
                    }
                    else
                    {
                        effect = EffectActionUtil.CreateEffect(aeeData.Address, tran, property.IsMain(), actionTarget.TargetPosition);
                    }
                    if (effect != null)
                    {
                        effects.Add(effect);
                    }
                }
            }
        }
Exemplo n.º 7
0
        public override void Trigger()
        {
            EmitSelectionData       emitSelectionData = m_Context.GetObject <SkillRunningData>().EmitSelectoin;
            TargetNearEmitNodeData  nodeData          = GetData <TargetNearEmitNodeData>();
            IBindNodeActionProperty bindNodeProperty  = m_Context.GetObject <IBindNodeActionProperty>();
            IBaseActionProperty     property          = m_Context.GetObject <IBaseActionProperty>();


            List <Transform> bindTransforms = null;

            if (bindNodeProperty.GetPresentation() == null)
            {
                Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1} " +
                                                                                "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                property.EntityId(),
                                                                                property.GetItemID()));

                bindTransforms = new List <Transform>();
                bindTransforms.Add(property.GetRootTransform());
            }
            else
            {
                bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(nodeData.NodeType.ToLaunchPoint(), -1);
            }



            ActionTarget actionTarget = SelectionTargetUtil.GetActionTarget(m_Context, nodeData.TargetSelection.Value);

            if (actionTarget == null || actionTarget.TargetType == ActionTargetType.None)
            {
                Leyoutech.Utility.DebugUtility.LogWarning("TargetNearEmitNodeAction", "TargetNearEmitNodeAction::Trigger->target not found");
                return;
            }

            Vector3 targetPosition = Vector3.zero;

            if (actionTarget.TargetType == ActionTargetType.Entity)
            {
                targetPosition = actionTarget.TargetEntity.position;
            }
            else
            {
                targetPosition = actionTarget.TargetPosition;
            }
            List <BindTransformDistanceData> distances = new List <BindTransformDistanceData>();

            for (int i = 0; i < bindTransforms.Count; ++i)
            {
                float distance = Vector3.Distance(bindTransforms[i].position, targetPosition);
                distances.Add(new BindTransformDistanceData()
                {
                    Index    = i,
                    Distance = distance,
                });
            }

            distances.Sort((item1, item2) =>
            {
                return(item1.Distance.CompareTo(item2.Distance));
            });
            int emitDataCount = nodeData.Count;

            if (emitDataCount > distances.Count)
            {
                Leyoutech.Utility.DebugUtility.LogError("Action", "TargetNearEmitNodeAction::Trigger->the number of emit in config is less than the count of the node.");
                emitDataCount = distances.Count;
            }

            EmitData[] emitDatas = new EmitData[emitDataCount];
            for (int i = 0; i < nodeData.Count && i < distances.Count; ++i)
            {
                emitDatas[i] = new EmitData()
                {
                    NodeType  = nodeData.NodeType,
                    NodeIndex = distances[i].Index,
                };
            }

            emitSelectionData.AddOrUpdateEmit(nodeData.AssignIndex, emitDatas);
        }
        public override void Trigger()
        {
            AutoRangeEmitNodeData data = GetData <AutoRangeEmitNodeData>();

            IBaseActionProperty     property          = m_Context.GetObject <IBaseActionProperty>();
            IBindNodeActionProperty bindNodeProperty  = m_Context.GetObject <IBindNodeActionProperty>();
            EmitSelectionData       emitSelectionData = m_Context.GetObject <SkillRunningData>().EmitSelectoin;

            List <Transform> bindTransforms = null;

            if (bindNodeProperty.GetPresentation() == null)
            {
                Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1}" +
                                                                                "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                property.EntityId(),
                                                                                property.GetItemID()
                                                                                ));

                bindTransforms = new List <Transform>();
                bindTransforms.Add(property.GetRootTransform());
            }
            else
            {
                bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(data.NodeType.ToLaunchPoint(), -1);
            }


            if (bindTransforms == null || bindTransforms.Count == 0)
            {
                Debug.LogError("AutoRangeEmitNodeAction::Trigger->bind node is null");
                return;
            }
            List <int> orgIndex = new List <int>();

            for (int i = 0; i < bindTransforms.Count; ++i)
            {
                orgIndex.Add(i);
            }
            if (data.Count > orgIndex.Count)
            {
                for (int i = 0; i < data.Count - orgIndex.Count; ++i)
                {
                    Random.InitState((int)DateTime.Now.Ticks);
                    int index = Random.Range(0, orgIndex.Count);
                    orgIndex.Add(index);
                }
            }

            List <EmitData> emitDatas = new List <EmitData>();

            for (int i = 0; i < data.Count; ++i)
            {
                Random.InitState((int)DateTime.Now.Ticks);
                int index = Random.Range(0, orgIndex.Count);
                orgIndex.RemoveAt(orgIndex.IndexOf(index));

                EmitData emitData = new EmitData()
                {
                    NodeType  = data.NodeType,
                    NodeIndex = index,
                };

                emitDatas.Add(emitData);
            }

            emitSelectionData.AddOrUpdateEmit(data.AssignIndex, emitDatas.ToArray());
        }
Exemplo n.º 9
0
        public override void Trigger()
        {
            IBaseActionProperty baseActionProperty = m_Context.GetObject <IBaseActionProperty>();

            Leyoutech.Utility.DebugUtility.LogWarning("释放飞行物", string.Format("触发释放飞行物Action,释放单位自己entity = {0} ", baseActionProperty.EntityId()));

            FlyerEmitData     flyerEmitData     = GetData <FlyerEmitData>();
            SkillData         skillData         = m_Context.GetObject <SkillData>();
            EmitSelectionData emitSelectionData = m_Context.GetObject <SkillRunningData>().EmitSelectoin;

            EmitData[] emitDatas = emitSelectionData.GetEmits(flyerEmitData.EmitIndex);
            IBindNodeActionProperty bindNodeProperty = m_Context.GetObject <IBindNodeActionProperty>();

            for (int i = 0; emitDatas != null && i < emitDatas.Length; i++)
            {
                EmitData emitData = emitDatas[i];


                List <Transform> bindTransforms = null;
                if (bindNodeProperty.GetPresentation() == null)
                {
                    Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1} " +
                                                                                    "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                    baseActionProperty.EntityId(),
                                                                                    baseActionProperty.GetItemID()));

                    bindTransforms = new List <Transform>();
                    bindTransforms.Add(baseActionProperty.GetRootTransform());
                }
                else
                {
                    bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(emitData.NodeType.ToLaunchPoint(), emitData.NodeIndex);
                }


                foreach (var tran in bindTransforms)
                {
                    //发射位置
                    Vector3 flyerPosition = Vector3.zero;
                    if (flyerEmitData.PositionType == FlyerPositionType.Emit) //与发射点的位置重合
                    {
                        flyerPosition = tran.position;
                    }
                    else if (flyerEmitData.PositionType == FlyerPositionType.EmitOffset)//与发射点位置偏移
                    {
                        flyerPosition = tran.position + flyerEmitData.PositionOrOffset.Value.ToVector3();
                    }

                    //发射方向
                    Vector3    flyerDirection = Vector3.zero;
                    Quaternion qq             = Quaternion.identity;

                    //给子弹的目标信息
                    bool       ishaveTarget       = false;
                    BaseEntity targetEntity       = null;
                    uint       targetEnityId      = 0;
                    Vector3    targetPoint        = Vector3.zero;
                    Vector3    calculateDirection = Vector3.zero; //用于计算没有目标时,求最远点的方向

                    //=========================目标设置==============================

                    ActionTarget actionTarget = SelectionTargetUtil.GetActionTarget(m_Context, flyerEmitData.TargetSelection.Value);
                    if (actionTarget == null || actionTarget.TargetType == ActionTargetType.None)
                    {
                        Leyoutech.Utility.DebugUtility.LogWarning("AddBindLinkTargetEffectAction", "AddBindLinkTargetEffectAction::Trigger->target not found");
                        return;
                    }

                    if (actionTarget.TargetType == ActionTargetType.Entity)
                    {//有单位目标
                        targetEntity = actionTarget.Entity;
                        ishaveTarget = targetEntity != null;
                        if (ishaveTarget)
                        {
                            targetEnityId = (uint)targetEntity.EntityId();
                        }

                        Leyoutech.Utility.DebugUtility.LogWarning("释放飞行物", string.Format("-----1-----有目标,释放单位自己entity = {0},目标单位 entiy = {1}",
                                                                                         baseActionProperty.EntityId(),
                                                                                         targetEnityId));
                    }
                    else
                    {//没有单位,点
                        targetPoint = actionTarget.TargetPosition;

                        Leyoutech.Utility.DebugUtility.LogWarning("释放飞行物", string.Format("--------2---没目标,释放单位自己entity = {0},最远点为发射方向  targetPoint = {1}",
                                                                                         baseActionProperty.EntityId(),
                                                                                         targetPoint));
                    }


                    //======================end===目标设置==============================


                    if (flyerEmitData.DirectionType == FlyerDirectionType.Emit)//与发射点的方向相同
                    {
                        flyerDirection = Quaternion.FromToRotation(Vector3.forward, tran.up).eulerAngles;
                        qq             = Quaternion.Euler(flyerDirection);
                    }
                    else if (flyerEmitData.DirectionType == FlyerDirectionType.Entity)//与实体的方向相同
                    {
                        flyerDirection = Quaternion.FromToRotation(Vector3.forward, baseActionProperty.GetRootTransform().forward).eulerAngles;
                        qq             = Quaternion.Euler(flyerDirection);
                    }
                    else if (flyerEmitData.DirectionType == FlyerDirectionType.Target) ///与目标的方向相同
                    {
                        if (ishaveTarget && targetEntity != null)                      //有目标,目标单位为发射方向
                        {
                            Vector3 vector = (targetEntity.GetRootTransform().position - tran.position).normalized;
                            flyerDirection = Quaternion.FromToRotation(Vector3.forward, vector).eulerAngles;
                            qq             = Quaternion.Euler(flyerDirection);
                        }
                        else
                        {//没目标,最远点为发射方向
                            Vector3 vector = (targetPoint - tran.position).normalized;
                            flyerDirection = Quaternion.FromToRotation(Vector3.forward, vector).eulerAngles;
                            qq             = Quaternion.Euler(flyerDirection);

                            GizmosHelper.GetInstance().DrawLine(tran.position, targetPoint, Color.green);
                        }
                    }

                    //创建子弹
                    SpacecraftSkillComponent skillComponent  = m_Context.GetObject <SpacecraftSkillComponent>();
                    CreatBulletData          creatBulletData = (CreatBulletData)Activator.CreateInstance(typeof(CreatBulletData));
                    creatBulletData.flyerDataID   = flyerEmitData.FlyerID;                      //飞行数据ID
                    creatBulletData.OwnerEntityId = (uint)baseActionProperty.EntityId();        //哪个单位ID
                    creatBulletData.owerSkillId   = skillComponent.SkillID;                     //哪个技能ID

                    //位置
                    creatBulletData.posX = flyerPosition.x;
                    creatBulletData.posY = flyerPosition.y;
                    creatBulletData.posZ = flyerPosition.z;

                    //旋转
                    creatBulletData.rotationX = flyerDirection.x;
                    creatBulletData.rotationY = flyerDirection.y;
                    creatBulletData.rotationZ = flyerDirection.z;

                    //子弹要飞去的目标单位ID
                    creatBulletData.isHaveTarget   = ishaveTarget;
                    creatBulletData.targetEntityId = targetEnityId;

                    //子弹的要飞去的目标位置
                    creatBulletData.target_posX = targetPoint.x;
                    creatBulletData.target_posY = targetPoint.y;
                    creatBulletData.target_posZ = targetPoint.z;


                    if (skillData.BaseData.Value.IsNeedTarget && !ishaveTarget)
                    {//需要目标,但目标值为null 则不执行
                        return;
                    }


                    if (flyerPosition == Vector3.zero)
                    {
                        Leyoutech.Utility.DebugUtility.LogWarning("释放飞行物", string.Format("子弹发射初始位置==Vector3.zero 确定正确吗? SkillID = {0} ", skillData.Id));
                    }

                    Leyoutech.Utility.DebugUtility.LogWarning("释放飞行物", string.Format("创建子弹! ------> 释放单位自己entity = {0}, 子弹位置:{1}  , 朝向:{2} , 有目标ID吗?{3}  ,  目标EntityID: {4},  目标点: {5} ",
                                                                                     baseActionProperty.EntityId(),
                                                                                     flyerPosition,
                                                                                     qq * Vector3.forward,
                                                                                     ishaveTarget,
                                                                                     targetEnityId,
                                                                                     targetPoint));

                    GameplayManager.Instance.GetEntityManager().CreateBulletEntity <BulletEntity, CreatBulletData>(creatBulletData);
                }
            }
        }
Exemplo n.º 10
0
        public override void Trigger()
        {
            EmitSelectionData       emitSelectionData = m_Context.GetObject <SkillRunningData>().EmitSelectoin;
            IBaseActionProperty     property          = m_Context.GetObject <IBaseActionProperty>();
            IBindNodeActionProperty bindNodeProperty  = m_Context.GetObject <IBindNodeActionProperty>();

            AddEmitEffectData data = GetData <AddEmitEffectData>();

            bool    isChangeEffectToward = false;
            Vector3 targetPosition       = Vector3.zero;

            if (data.IsTowardToTarget)
            {
                isChangeEffectToward = true;
                ActionTarget actionTarget = SelectionTargetUtil.GetActionTarget(m_Context, data.TargetSelection.Value);
                if (actionTarget == null || actionTarget.TargetType == ActionTargetType.None)
                {
                    Leyoutech.Utility.DebugUtility.LogWarning("AddBindLinkTargetEffectAction", "AddBindLinkTargetEffectAction::Trigger->target not found");
                    isChangeEffectToward = false;
                }
                else if (actionTarget.TargetType == ActionTargetType.Position)
                {
                    targetPosition = actionTarget.TargetPosition;
                }
                else if (actionTarget.TargetType == ActionTargetType.Entity)
                {
                    targetPosition = actionTarget.TargetEntity.position;
                }
            }

            EmitData[] emitDatas = emitSelectionData.GetEmits(data.EmitIndex);//获取发射口  index= -1,表示所有发射口
            if (emitDatas != null && emitDatas.Length > 0)
            {
                for (int i = 0; emitDatas != null && i < emitDatas.Length; i++)
                {
                    EmitData emitData = emitDatas[i];

                    List <Transform> bindTransforms = null;
                    if (bindNodeProperty.GetPresentation() == null)
                    {
                        Leyoutech.Utility.DebugUtility.LogWarning("查找挂点", string.Format("bindNodeProperty.GetPresentation() == null ,Entity = {0} ,ItemId = {1} " +
                                                                                        "模型未加载完毕,挂点脚本未被赋值!, 此时挂点作 root 处理",
                                                                                        property.EntityId(),
                                                                                        property.GetItemID()
                                                                                        ));

                        bindTransforms = new List <Transform>();
                        bindTransforms.Add(property.GetRootTransform());
                    }
                    else
                    {
                        bindTransforms = bindNodeProperty.GetPresentation().GetBindNode(emitData.NodeType.ToLaunchPoint(), emitData.NodeIndex);
                    }


                    foreach (var tran in bindTransforms)
                    {
                        EffectController effect = EffectActionUtil.CreateEffect(data.Address, tran, property.IsMain());
                        if (isChangeEffectToward)
                        {
                            Vector3 dir = (targetPosition - tran.position).normalized;
                            effect.CachedTransform.forward = dir;
                        }
                    }
                }
            }
            else
            {
            }
        }