Example #1
0
        public override void Trigger()
        {
            IBaseActionProperty         property = m_Context.GetObject <IBaseActionProperty>();
            AddEntityPositionEffectData data     = GetData <AddEntityPositionEffectData>();

            EffectActionUtil.CreateEffect(data.Address, property.GetRootTransform().position, property.IsMain());
        }
        public override void SetEnv(IContext context, ActionData data, float timeScale)
        {
            base.SetEnv(context, data, timeScale);
            aeeData  = GetData <AddEmitLinkTargetDurationEffectData>();
            property = m_Context.GetObject <IBaseActionProperty>();

            Duration = aeeData.Duration * timeScale;
        }
        public override void DoEnter()
        {
            m_MoveActionProperty    = m_Context.GetObject <IMoveActionProperty>();
            m_BaseActionProperty    = m_Context.GetObject <IBaseActionProperty>();
            m_IBulletTargetProperty = m_Context.GetObject <IBulletTargetProperty>();

            m_RemainingTime = Duration;
        }
        /// <summary>
        /// 获取最远点
        /// </summary>
        /// <param name="context"></param>
        /// <param name="selectionData"></param>
        /// <returns></returns>
        private static void GetFarthestPostionActionTarget(ref ActionTarget actionTarget, IContext context, Vector3 calculateDirection)
        {
            IBaseActionProperty baseActionProperty = context.GetObject <IBaseActionProperty>();

            if (baseActionProperty.IsMain())
            {
                SkillData           skillData        = context.GetObject <SkillData>();
                MainCameraComponent mainCamComponent = context.GetObject <MainCameraComponent>();

                if (mainCamComponent == null)
                {
                    actionTarget = null;
                    return;
                }
                //最远点
                Vector3 distantPoint = Vector3.zero;


                Vector3 playerPosition = baseActionProperty.GetRootTransform().position;             //玩家位置
                Vector3 CamPosition    = mainCamComponent.GetPosition();                             //摄像机位置

                Vector3 cameDir       = calculateDirection; /*mainCamComponent.GetForward()*/        //摄像机方向向量
                Vector3 camera2Player = playerPosition - CamPosition;                                //摄像机到玩家的向量
                Vector3 verticalPos   = CamPosition + Vector3.Dot(camera2Player, cameDir) * cameDir; //垂线坐标 = 摄像机坐标+ camera2Player在cameDir投影距离 * cameDir向量
                Vector3 Play2VerticaN = (verticalPos - playerPosition).normalized;                   //玩家到垂线点 的单位向量
                float   Play2VerticaD = Vector3.Distance(verticalPos, playerPosition);               //玩家跟垂线点的距离

                float MaxDis = skillData.BaseData.Value.MaxDistance;
                if (MaxDis > Play2VerticaD)
                {
                    distantPoint = Mathf.Sqrt(MaxDis * MaxDis - Play2VerticaD * Play2VerticaD) * cameDir + verticalPos; //最远点 = 三角函数求得垂线点到最远点向量+ 垂线点坐标
                }
                else
                {
                    distantPoint = playerPosition + Play2VerticaN * MaxDis;//垂线上找到距离是 MaxDis 的坐标
                }
                actionTarget.TargetType     = ActionTargetType.Position;
                actionTarget.TargetPosition = distantPoint;
            }
            else
            {
                SkillData skillData      = context.GetObject <SkillData>();
                Vector3   playerPosition = baseActionProperty.GetRootTransform().position;
                float     d = skillData.BaseData.Value.MaxDistance;

                Vector3 distantPoint = playerPosition + calculateDirection * d;
                actionTarget.TargetType     = ActionTargetType.Position;
                actionTarget.TargetPosition = distantPoint;

                //Leyoutech.Utility.DebugUtility.LogError("第三方最远点方向", string.Format("计算最远点 ---->self = {0} , calculateDirection = {1},  PlayPos = {2}  , distantPoint = {3}",
                //    baseActionProperty.EntityId(),
                //    calculateDirection,
                //    playerPosition,
                //    distantPoint
                //    ));
            }
        }
Example #5
0
        public override void Trigger()
        {
            IBaseActionProperty property = m_Context.GetObject <IBaseActionProperty>();

            if (!property.IsMain())
            {
                return;
            }

            //通知准星Size变化
            property.SendEvent(ComponentEventName.PostWeaponFire, null);
        }
        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()
        {
            PlayPointSoundData data = GetData <PlayPointSoundData>();

            IBaseActionProperty baseActionProperty = m_Context.GetObject <IBaseActionProperty>();

            if (baseActionProperty.IsMain())
            {
                WwiseUtil.PlaySound(data.MainSoundID, false, data.Position.Value.ToVector3());
            }
            else
            {
                WwiseUtil.PlaySound(data.ThirdPartSoundID, false, data.Position.Value.ToVector3());
            }
        }
Example #8
0
        public override void Trigger()
        {
            PlayEntityPositionSoundData data = GetData <PlayEntityPositionSoundData>();

            IBaseActionProperty baseActionProperty = m_Context.GetObject <IBaseActionProperty>();
            Vector3             entityPosition     = baseActionProperty.GetRootTransform().position;

            if (baseActionProperty.IsMain())
            {
                WwiseUtil.PlaySound(data.MainSoundID, false, entityPosition);
            }
            else
            {
                WwiseUtil.PlaySound(data.ThirdPartSoundID, false, entityPosition);
            }
        }
        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 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 Trigger()
        {
            //AccumulationForceReleaseData data = GetData<AccumulationForceReleaseData>();

            //蓄力技能强势释放
            IBaseActionProperty baseActionProperty = m_Context.GetObject <IBaseActionProperty>();

            if (!baseActionProperty.IsMain())
            {
                return;
            }

            //通知准星Size变化
            baseActionProperty.SendEvent(ComponentEventName.CoerceSkillButtonUp, null);

            TimelineTrackGroup trackGroup = m_Context.GetObject <TimelineTrackGroup>();

            trackGroup.Pause();
        }
Example #12
0
        public override void Trigger()
        {
            IBaseActionProperty property = m_Context.GetObject <IBaseActionProperty>();

            if (!property.IsMain())
            {
                return;
            }

            AffectCDData cdData    = GetData <AffectCDData>();
            SkillData    skillData = m_Context.GetObject <SkillData>();

            PlayerSkillProxy skillProxy = GameFacade.Instance.RetrieveProxy(ProxyName.PlayerSkillProxy) as PlayerSkillProxy;

            for (int i = 0; i < cdData.CdDatasLength; ++i)
            {
                CdData data = cdData.CdDatas(i).Value;
                skillProxy.AddCD(skillData.Id, data.CdType, data.CdTime);
            }
        }
        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);
                }
            }
        }
        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
            {
            }
        }
Example #16
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);
                }
            }
        }
        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());
        }
        private static CCrossSightLoic.Target GetTargetEntity(IContext context, LinkedList <CCrossSightLoic.Target> entities, BaseEntity ower, TargetSelectionData targetSelection)
        {
            if (entities == null)
            {
                return(null);
            }

            //阵营过滤
            GameplayProxy gameplayProxy = GameFacade.Instance.RetrieveProxy(ProxyName.GameplayProxy) as GameplayProxy;

            LinkedList <CCrossSightLoic.Target> nLinkedList = new LinkedList <CCrossSightLoic.Target>();

            LinkedListNode <CCrossSightLoic.Target> pVertor = entities.First;

            CCrossSightLoic.Target pb = null;
            while (pVertor != null)
            {
                pb      = pVertor.Value;
                pVertor = pVertor.Next;

                BaseEntity entity2 = GameplayManager.Instance.GetEntityManager().GetEntityById <BaseEntity>((uint)pb.target_entityId);
                if (entity2 == null)
                {
                    continue;
                }

                bool same = gameplayProxy.IsBelongToThisFactionType(targetSelection.FactionType, ower, entity2);
                if (same)
                {
                    nLinkedList.AddLast(pb);
                }
            }


            //目标选择
            PerceptronTarget    perceptron         = context.GetObject <PerceptronTarget>();
            IBaseActionProperty baseActionProperty = context.GetObject <IBaseActionProperty>();

            CCrossSightLoic.Target result = null;
            if (targetSelection.Target == TargetType.Target) //表示当前选中的目标(实体,点)
            {
                result = nLinkedList.First?.Value;
            }
            else if (targetSelection.Target == TargetType.TargetNext) ///选中当前的目标,下次选择选中下一个目标
            {
                result = nLinkedList.First?.Value;
                perceptron.RetropositionEntity(nLinkedList.First?.Value);
            }
            else if (targetSelection.Target == TargetType.Self) /// 1.选择自己   2.如果是飞行物的话 自己表示的飞行物本身
            {
                result = new CCrossSightLoic.Target();
                result.target_entityId = baseActionProperty.GetOwner().EntityId();
                result.target_pos      = baseActionProperty.GetOwner().GetRootTransform().position;
            }
            else if (targetSelection.Target == TargetType.Owner) /// 1.选择自己的owner(或者说是caster)  2.如果是飞行物的话还是技能的caster
            {
                BaseEntity fentity = GameplayManager.Instance.GetEntityManager().GetEntityById <BaseEntity>(baseActionProperty.GetEntityFatherOwnerID());
                if (fentity != null)
                {
                    result = new CCrossSightLoic.Target();
                    result.target_entityId = baseActionProperty.GetEntityFatherOwnerID();
                    result.target_pos      = fentity.GetRootTransform().position;
                }
            }

            return(result);
        }
Example #19
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);
        }
        internal static ActionTarget GetActionTarget(IContext context, TargetSelectionData selectionData)
        {
            ActionTarget actionTarget = new ActionTarget();

            IBaseActionProperty baseActionProperty = context.GetObject <IBaseActionProperty>();
            SkillData           skillData          = context.GetObject <SkillData>();
            PerceptronTarget    perceptron         = context.GetObject <PerceptronTarget>();

            Vector3 calculateDirection = Vector3.zero;

            LinkedList <CCrossSightLoic.Target> entities = null;

            if (!skillData.BaseData.Value.CanChangeTarget)
            {   //不能切换
                entities = perceptron.GetCurrQueue(out calculateDirection, false, skillData.BaseData.Value.TagercalculationType);
            }
            else
            {
                //能切换
                entities = perceptron.GetCurrQueue(out calculateDirection, true, skillData.BaseData.Value.TagercalculationType);
            }

            //             //阵营筛选,已经在技能释放前过滤过了,下面不进行
            //             if (entities.Count > 0) //有目标,目标单位为发射方向
            //             {
            CCrossSightLoic.Target cctarget = GetTargetEntity(context, entities, baseActionProperty.GetOwner(), selectionData);
            if (cctarget == null)
            {
                //没目标,最远点为发射方向
                GetFarthestPostionActionTarget(ref actionTarget, context, calculateDirection);
            }
            else
            {
                BaseEntity entity = GameplayManager.Instance.GetEntityManager().GetEntityById <BaseEntity>((uint)cctarget.target_entityId);
                if (entity != null)
                {
                    actionTarget.Entity       = entity;
                    actionTarget.TargetEntity = entity.GetRootTransform();
                    actionTarget.TargetEntityHitPositionOffet = cctarget.target_pos - entity.GetRootTransform().position;
                    actionTarget.TargetType = ActionTargetType.Entity;
                }
                else
                {
                    //没目标,最远点为发射方向
                    GetFarthestPostionActionTarget(ref actionTarget, context, calculateDirection);
                }
            }
            //             }
            //             else
            //             {//没目标,最远点为发射方向
            //
            //                 GetFarthestPostionActionTarget(ref  actionTarget,  context,  calculateDirection);
            //             }

            if (actionTarget.TargetType == ActionTargetType.None)
            {
                return(null);
            }
            else
            {
                return(actionTarget);
            }
        }