static public int constructor(IntPtr l)
 {
     try {
         GameFramework.Skill.Trigers.TriggerUtil o;
         o = new GameFramework.Skill.Trigers.TriggerUtil();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Beispiel #2
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            GameObject target = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj    = senderObj.TrackEffectObj;
                target = senderObj.GfxObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (m_IsForRoundMove)
            {
                Vector3 srcPos    = obj.transform.position;
                Vector3 targetPos = Vector3.zero;
                if (null != target)
                {
                    targetPos = target.transform.position;
                }
                TriggerUtil.GetSkillStartPosition(srcPos, senderObj.ConfigData, instance, senderObj.ActorId, senderObj.TargetActorId, ref targetPos);
                if (targetPos.sqrMagnitude > Geometry.c_FloatPrecision)
                {
                    instance.CustomDatas.AddData <Vector3>(targetPos);
                }
            }
            else
            {
                Vector3 pos = obj.transform.position;
                instance.CustomDatas.AddData <Vector3>(pos);
            }
            return(false);
        }
Beispiel #3
0
        private AudioSource CreateNewAudioSource(GameObject obj)
        {
            if (string.IsNullOrEmpty(m_AudioSourceName))
            {
                return(null);
            }
            GameObject audiosource_obj = ResourceSystem.Instance.NewObject(
                m_AudioSourceName,
                (StartTime + m_AudioSourceLifeTime) / 1000.0f) as GameObject;

            if (audiosource_obj == null)
            {
                return(null);
            }
            if (m_IsBoneSound)
            {
                Transform attach_node = TriggerUtil.GetChildNodeByName(obj, m_BoneName);
                if (attach_node != null)
                {
                    audiosource_obj.transform.SetParent(attach_node);
                    audiosource_obj.transform.rotation = Quaternion.identity;
                    audiosource_obj.transform.position = Vector3.zero;
                    if (!m_IsAttach)
                    {
                        audiosource_obj.transform.SetParent(null);
                    }
                }
                else
                {
                    audiosource_obj.transform.position = obj.transform.TransformPoint(m_Position);
                    if (m_IsAttach)
                    {
                        audiosource_obj.transform.SetParent(obj.transform);
                    }
                }
            }
            else
            {
                audiosource_obj.transform.position = obj.transform.TransformPoint(m_Position);
                if (m_IsAttach)
                {
                    audiosource_obj.transform.SetParent(obj.transform);
                }
            }
            return(audiosource_obj.GetComponentInChildren <AudioSource>());
        }
        private void AttachToObject(GameObject obj, GameObject owner)
        {
            Transform parent = TriggerUtil.GetChildNodeByName(owner, m_BoneName);

            if (parent == null)
            {
                parent = owner.transform;
            }
            obj.transform.SetParent(parent);
            Vector3 world_pos = parent.TransformPoint(m_Postion);

            TriggerUtil.MoveObjTo(obj, world_pos);
            obj.transform.localRotation = Quaternion.Euler(m_Rotate);
            if (!m_IsAttach)
            {
                obj.transform.SetParent(null);
            }
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (obj == null)
            {
                return(false);
            }
            GameObject targetObj = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj       = senderObj.TrackEffectObj;
                targetObj = senderObj.GfxObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (StartTime + m_DurationTime < curSectionTime)
            {
                return(false);
            }
            if (null != targetObj && m_ObjPath == "vector3")
            {
                Vector3 pos = targetObj.transform.TransformPoint(m_RelativeOffset);
                TriggerUtil.MoveObjTo(obj, pos);
            }
            else
            {
                var tobj = GameObject.Find(m_ObjPath);
                if (null != tobj)
                {
                    TriggerUtil.MoveObjTo(obj, tobj.transform.position);
                }
            }
            return(true);
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            GameObject targetObj = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj       = senderObj.TrackEffectObj;
                targetObj = senderObj.GfxObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            else if (curSectionTime <= StartTime + m_Duration)
            {
                if (!Prepare(senderObj, obj, targetObj))
                {
                    return(false);
                }
                float   t         = (float)(int)(curSectionTime - StartTime) / 1000.0f;
                float   disty     = m_YVelocity * t - m_G * t * t / 2;
                float   dist      = TriggerUtil.ConvertToSecond(delta) * m_Velocity;
                Vector3 targetPos = obj.transform.position + m_Forward * dist;
                targetPos.y = m_InitY + disty;
                TriggerUtil.MoveObjTo(obj, targetPos);
                return(true);
            }
            else
            {
                return(false);
            }
        }
 private void EnableMoveAgent(GameObject obj, bool isEnable)
 {
     try {
         EntityViewModel npcView = (EntityViewModel)EntityController.Instance.GetEntityView(obj);
         if (npcView != null)
         {
             if (isEnable)
             {
                 //贴地
                 var pos = obj.transform.position;
                 TriggerUtil.GetRayCastPosInNavMesh(pos + UnityEngine.Vector3.up * 500, pos + UnityEngine.Vector3.down * 500, ref pos);
                 obj.transform.position = pos;
             }
             npcView.SetMoveAgentEnable(isEnable);
         }
     } catch (Exception ex) {
         LogSystem.Warn("SetMoveAgentEnable exception:{0}", ex.Message);
     }
 }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            Scene      scene = senderObj.Scene;
            EntityInfo obj   = senderObj.GfxObj;

            if (obj == null)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            int targetType = scene.EntityController.GetTargetType(senderObj.ActorId, senderObj.ConfigData, senderObj.Seq);
            int impactId   = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData);
            int senderId;
            int targetId;

            scene.EntityController.CalcSenderAndTarget(senderObj, out senderId, out targetId);
            if (senderObj.ConfigData.aoeType != (int)SkillAoeType.Unknown)
            {
                float minDistSqr = float.MaxValue;
                TriggerUtil.AoeQuery(senderObj, instance, senderId, targetType, m_RelativeCenter, m_RelativeToTarget, (float distSqr, int objId) => {
                    if (distSqr < minDistSqr)
                    {
                        minDistSqr = distSqr;
                        targetId   = objId;
                    }
                    return(true);
                });
            }
            Dictionary <string, object> args;

            TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args);
            scene.EntityController.SendImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ActorId, senderId, targetId, impactId, args);
            return(false);
        }
Beispiel #9
0
        private Vector3 Move(EntityInfo obj, Vector3 speed_vect, Vector3 accel_vect, float time)
        {
            Vector3 local_motion = speed_vect * time + accel_vect * time * time / 2;
            Vector3 word_target_pos;

            while (local_motion.Length() > m_MaxMoveStep)
            {
                Vector3 child = local_motion;
                child.Normalize();
                child          *= m_MaxMoveStep;
                local_motion    = local_motion - child;
                word_target_pos = Geometry.TransformPoint(m_StartPos, child, m_StartDir);
                TriggerUtil.MoveObjTo(obj, word_target_pos);
                m_StartPos = word_target_pos;
            }
            word_target_pos = Geometry.TransformPoint(m_StartPos, local_motion, m_StartDir);
            TriggerUtil.MoveObjTo(obj, word_target_pos);
            return(speed_vect + accel_vect * time);
        }
Beispiel #10
0
        private Vector3 Move(GameObject obj, Vector3 speed_vect, Vector3 accel_vect, float time)
        {
            m_StartTransform.transform.position = obj.transform.position;
            m_StartTransform.transform.rotation = obj.transform.rotation;
            Vector3 local_motion = speed_vect * time + accel_vect * time * time / 2;
            Vector3 word_target_pos;

            while (local_motion.magnitude > m_MaxMoveStep)
            {
                Vector3 child = Vector3.ClampMagnitude(local_motion, m_MaxMoveStep);
                local_motion    = local_motion - child;
                word_target_pos = m_StartTransform.transform.TransformPoint(child);
                TriggerUtil.MoveObjTo(obj, word_target_pos);
                m_StartTransform.transform.position = obj.transform.position;
            }
            word_target_pos = m_StartTransform.transform.TransformPoint(local_motion);
            TriggerUtil.MoveObjTo(obj, word_target_pos);
            return(speed_vect + accel_vect * time);
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            Scene      scene = senderObj.Scene;
            EntityInfo obj   = senderObj.GfxObj;

            if (obj == null)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            int senderId;
            int targetId;

            scene.EntityController.CalcSenderAndTarget(senderObj, out senderId, out targetId);
            int impactId = senderObj.ConfigData.impact;

            if (senderObj.ConfigData.type != (int)SkillOrImpactType.Skill)
            {
                if (impactId <= 0)
                {
                    int skillId           = scene.EntityController.GetImpactSkillId(senderObj.ActorId, senderObj.SkillId, senderObj.Seq);
                    TableConfig.Skill cfg = TableConfig.SkillProvider.Instance.GetSkill(skillId);
                    if (null != cfg)
                    {
                        impactId = cfg.impact;
                    }
                }
            }
            Dictionary <string, object> args;

            TriggerUtil.CalcImpactConfig(0, 0, instance, senderObj.ConfigData, out args);
            scene.EntityController.SendImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ActorId, senderId, targetId, impactId, args);
            return(false);
        }
Beispiel #12
0
        public static void MoveChildToNode(GameObject obj, string childname, string nodename)
        {
            Transform child = GetChildNodeByName(obj, childname);

            if (child == null)
            {
                GameFramework.LogSystem.Info("----not find child! {0} on {1}", childname, obj.name);
                return;
            }
            Transform togglenode = TriggerUtil.GetChildNodeByName(obj, nodename);

            if (togglenode == null)
            {
                GameFramework.LogSystem.Info("----not find node! {0} on {1}", nodename, obj.name);
                return;
            }
            child.parent        = togglenode;
            child.localRotation = Quaternion.identity;
            child.localPosition = Vector3.zero;
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            EntityInfo obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            switch (m_RelativeType)
            {
            case "RelativeSelf":
                SetTransformRelativeSelf(obj);
                break;

            case "RelativeTarget":
                SetTransformRelativeTarget(obj, senderObj.TargetGfxObj);
                break;

            case "RelativeWorld":
                obj.GetMovementStateInfo().SetPosition(m_Postion);
                obj.GetMovementStateInfo().SetFaceDir(Geometry.DegreeToRadian(m_Rotate.Y));
                break;
            }
            if (m_IsUseTerrainHeight)
            {
                Vector3 terrain_pos = TriggerUtil.GetGroundPos(obj.GetMovementStateInfo().GetPosition3D());
                obj.GetMovementStateInfo().SetPosition(terrain_pos);
            }
            return(false);
        }
        private void AttachToObjectForRandomRotate(GameObject obj, GameObject owner)
        {
            Transform parent = TriggerUtil.GetChildNodeByName(owner, m_BoneName);

            if (parent == null)
            {
                parent = owner.transform;
            }
            obj.transform.SetParent(parent);
            Vector3 world_pos = parent.TransformPoint(m_Postion);

            TriggerUtil.MoveObjTo(obj, world_pos);
            Vector3 resultrotate = new Vector3(
                m_Rotate.x + UnityEngine.Random.Range(m_RandomRotate.x / -2, m_RandomRotate.x / 2),
                m_Rotate.y + UnityEngine.Random.Range(m_RandomRotate.y / -2, m_RandomRotate.y / 2),
                m_Rotate.z + UnityEngine.Random.Range(m_RandomRotate.z / -2, m_RandomRotate.z / 2));

            obj.transform.localRotation = Quaternion.Euler(resultrotate);
            if (!m_IsAttach)
            {
                obj.transform.SetParent(null);
            }
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            Scene      scene = senderObj.Scene;
            EntityInfo obj   = senderObj.GfxObj;

            if (obj == null)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            int senderId   = 0;
            int targetType = scene.EntityController.GetTargetType(senderObj.ActorId, senderObj.ConfigData, senderObj.Seq);
            int impactId   = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData);

            if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill)
            {
                senderId = senderObj.ActorId;
            }
            else
            {
                senderId = senderObj.TargetActorId;
            }

            float range = 0;

            TableConfig.Skill cfg = senderObj.ConfigData;
            if (null != cfg)
            {
                range = cfg.aoeSize;
            }
            float   angle  = obj.GetMovementStateInfo().GetFaceDir();
            Vector3 center = Geometry.TransformPoint(obj.GetMovementStateInfo().GetPosition3D(), m_RelativeCenter, angle);

            if (!m_IsStarted)
            {
                m_IsStarted = true;
                m_LastPos   = center;
            }
            else if ((center - m_LastPos).LengthSquared() >= 0.25f || StartTime + m_DurationTime < curSectionTime)
            {
                Vector3 c           = (m_LastPos + center) / 2;
                Vector3 angleu      = center - m_LastPos;
                float   queryRadius = range + angleu.Length() / 2;

                int  ct        = 0;
                bool isCollide = false;
                scene.KdTree.Query(c.X, c.Y, c.Z, queryRadius, (float distSqr, KdTreeObject kdTreeObj) => {
                    int targetId = kdTreeObj.Object.GetId();
                    if (targetType == (int)SkillTargetType.Enemy && CharacterRelation.RELATION_ENEMY == scene.EntityController.GetRelation(senderId, targetId) ||
                        targetType == (int)SkillTargetType.Friend && CharacterRelation.RELATION_FRIEND == scene.EntityController.GetRelation(senderId, targetId))
                    {
                        bool isMatch = Geometry.IsCapsuleDiskIntersect(new ScriptRuntime.Vector2(center.X, center.Z), new ScriptRuntime.Vector2(angleu.X, angleu.Z), range, new ScriptRuntime.Vector2(kdTreeObj.Position.X, kdTreeObj.Position.Z), kdTreeObj.Radius);
                        if (isMatch)
                        {
                            isCollide = true;
                            if (!m_SingleHit || !m_Targets.Contains(targetId))
                            {
                                m_Targets.Add(targetId);
                                Dictionary <string, object> args;
                                TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args);
                                scene.EntityController.SendImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ActorId, senderId, targetId, impactId, args);
                                ++ct;
                                if (senderObj.ConfigData.maxAoeTargetCount <= 0 || ct < senderObj.ConfigData.maxAoeTargetCount)
                                {
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    return(true);
                });

                m_LastPos = center;

                if (isCollide && m_FinishOnCollide)
                {
                    return(false);
                }
            }
            if (StartTime + m_DurationTime < curSectionTime)
            {
                instance.StopCurSection();
                return(false);
            }
            return(true);
        }
Beispiel #16
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            Scene      scene = senderObj.Scene;
            EntityInfo obj   = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            bool isTower = scene.EntityController.GetEntityType(senderObj.GfxObj) == (int)EntityTypeEnum.Tower;

            if (isTower)
            {
                return(false);
            }
            if (!m_TargetChecked)
            {
                m_TargetChecked = true;

                m_RealDuration = m_Duration;
                m_RealVelocity = m_Velocity;
                if (m_RealDuration <= 0)
                {
                    m_RealDuration += instance.CurSectionDuration;
                }
                if (m_RealDuration <= 0)
                {
                    LogSystem.Warn("jump duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
                    return(false);
                }
                EntityInfo targetObj = senderObj.TargetGfxObj;
                if (null != targetObj)
                {
                    Vector3 srcPos               = obj.GetMovementStateInfo().GetPosition3D();
                    Vector3 targetPos            = targetObj.GetMovementStateInfo().GetPosition3D();
                    float   degree               = Geometry.GetYRadian(new ScriptRuntime.Vector2(srcPos.X, srcPos.Z), new ScriptRuntime.Vector2(targetPos.X, targetPos.Z));
                    ScriptRuntime.Vector2 newPos = new ScriptRuntime.Vector2(targetPos.X, targetPos.Z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.X, m_Offset.Z), degree);
                    targetPos = new Vector3(newPos.X, targetPos.Y + m_Offset.Y, newPos.Y);
                    if (m_StopAtTarget == (int)StopAtTargetType.AdjustVelocity)
                    {
                        m_RealVelocity = (long)(1000.0f * (targetPos - srcPos).Length() / m_RealDuration);
                    }
                    else if (m_StopAtTarget == (int)StopAtTargetType.AdjustTime)
                    {
                        m_RealDuration = (long)(1000.0f * (targetPos - targetPos).Length() / m_RealVelocity);
                        CalcYVelocityAndG();
                    }
                    m_Forward = targetPos - srcPos;
                    m_Forward.Normalize();
                }
                else
                {
                    m_Forward = Geometry.GetRotate(new Vector3(0, 0, 1), obj.GetMovementStateInfo().GetFaceDir());
                }
                m_InitY = obj.GetMovementStateInfo().PositionY;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            else if (curSectionTime <= m_RealDuration)
            {
                float   t         = (float)(int)(curSectionTime - StartTime) / 1000.0f;
                float   disty     = m_YVelocity * t - m_G * t * t / 2;
                float   dist      = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity;
                Vector3 targetPos = obj.GetMovementStateInfo().GetPosition3D() + m_Forward * dist;
                targetPos.Y = m_InitY + disty;

                TriggerUtil.MoveObjTo(obj, targetPos);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #17
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            Scene      scene = senderObj.Scene;
            EntityInfo obj   = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            bool isTower = scene.EntityController.GetEntityType(senderObj.GfxObj) == (int)EntityTypeEnum.Tower;

            if (isTower)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (!m_IsCurveMoving)
            {
                return(false);
            }
            if (!m_IsInited)
            {
                Init(obj, senderObj.TargetGfxObj, instance);
            }
            if (m_SectionListCopy.Count == 0)
            {
                m_IsCurveMoving = false;
                return(false);
            }

            m_Now += TriggerUtil.ConvertToSecond((long)(instance.OriginalDelta * instance.MoveScale));
            MoveSectionInfo cur_section = m_SectionListCopy[0];

            if (m_Now - cur_section.startTime > cur_section.moveTime)
            {
                float end_time  = cur_section.startTime + cur_section.moveTime;
                float used_time = end_time - cur_section.lastUpdateTime;
                cur_section.curSpeedVect = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, used_time);
                m_SectionListCopy.RemoveAt(0);
                if (m_SectionListCopy.Count > 0)
                {
                    cur_section                = m_SectionListCopy[0];
                    cur_section.startTime      = end_time;
                    cur_section.lastUpdateTime = end_time;
                    cur_section.curSpeedVect   = cur_section.speedVect;
                }
                else
                {
                    m_IsCurveMoving = false;
                }
            }
            else
            {
                cur_section.curSpeedVect   = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, m_Now - cur_section.lastUpdateTime);
                cur_section.lastUpdateTime = m_Now;
            }
            return(true);
        }
Beispiel #18
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill)
            {
                return(false);//track只能在impact或buff里使用
            }
            GameObject obj = senderObj.GfxObj;

            if (null != obj)
            {
                if (curSectionTime >= StartTime)
                {
                    if (!m_IsStarted)
                    {
                        m_IsStarted = true;
                        Vector3 dest;
                        string  trackBone = m_TrackBone.Get(instance);
                        m_BoneTransform = Utility.FindChildRecursive(obj.transform, trackBone);
                        if (null != m_BoneTransform)
                        {
                            dest = m_BoneTransform.position;
                        }
                        else
                        {
                            dest    = obj.transform.position;
                            dest.y += 1.5f;
                            LogSystem.Warn("[skill:{0} dsl skill id:{1}] track bone {2} can't find.", senderObj.SkillId, instance.DslSkillId, trackBone);
                        }
                        m_StartPos = EntityController.Instance.GetImpactSenderPosition(senderObj.ObjId, senderObj.SkillId, senderObj.Seq);
                        dest       = Utility.FrontOfTarget(m_StartPos, dest, 0.1f);
                        object speedObj;
                        if (instance.Variables.TryGetValue("emitSpeed", out speedObj))
                        {
                            m_Speed = (float)speedObj;
                        }
                        else
                        {
                            return(false);
                        }
                        float duration = m_Duration.Get(instance);
                        if (duration > Geometry.c_FloatPrecision)
                        {
                            float d = duration / 1000.0f;
                            m_Lifetime = d;
                            m_Speed    = (dest - m_StartPos).magnitude / m_Lifetime;
                        }
                        else
                        {
                            m_Lifetime = 1.0f;
                            if (m_Speed > Geometry.c_FloatPrecision)
                            {
                                m_Lifetime = (dest - m_StartPos).magnitude / m_Speed;
                            }
                        }
                        long newSectionDuration = StartTime + (long)(m_Lifetime * 1000);
                        if (instance.CurSectionDuration < newSectionDuration)
                        {
                            instance.SetCurSectionDuration(newSectionDuration);
                        }
                        Quaternion dir;
                        object     dirObj;
                        if (instance.Variables.TryGetValue("emitDir", out dirObj))
                        {
                            dir = (Quaternion)dirObj;
                        }
                        else
                        {
                            dir = Quaternion.identity;
                        }
                        Vector3 scale;
                        object  scaleObj;
                        if (instance.Variables.TryGetValue("emitScale", out scaleObj))
                        {
                            scale = (Vector3)scaleObj;
                        }
                        else
                        {
                            scale = Vector3.one;
                        }
                        Vector3    lookDir = dest - m_StartPos;
                        Quaternion q       = Quaternion.LookRotation(lookDir);
                        m_ControlPos = m_StartPos + Vector3.Scale(q * dir * Vector3.forward, scale * lookDir.magnitude * 0.5f);
                        string effectPath = SkillParamUtility.RefixResourceVariable("emitEffect", instance, senderObj.ConfigData.resources);
                        m_Effect = ResourceSystem.Instance.NewObject(effectPath, m_Lifetime) as GameObject;
                        if (null != m_Effect)
                        {
                            senderObj.TrackEffectObj = m_Effect;
                            TriggerUtil.SetObjVisible(m_Effect, true);
                            m_Effect.SetActive(false);
                            m_Effect.transform.position      = m_StartPos;
                            m_Effect.transform.localRotation = q;
                            m_Effect.SetActive(true);
                        }
                        else
                        {
                            if (string.IsNullOrEmpty(effectPath))
                            {
                                LogSystem.Warn("[skill:{0} dsl skill id:{1}] track effect is empty.", senderObj.SkillId, instance.DslSkillId);
                            }
                            else
                            {
                                LogSystem.Warn("[skill:{0} dsl skill id:{1}] track effect {2} can't find.", senderObj.SkillId, instance.DslSkillId, effectPath);
                            }
                        }
                    }
                    else if (null != m_Effect)
                    {
                        if (!m_NotMove && !m_IsHit)
                        {
                            Vector3 dest;
                            if (null != m_BoneTransform)
                            {
                                dest = m_BoneTransform.position;
                            }
                            else
                            {
                                dest    = obj.transform.position;
                                dest.y += 1.5f;
                            }
                            dest = Utility.FrontOfTarget(m_StartPos, dest, 0.1f);
                            //m_Effect.transform.position = Vector3.MoveTowards(m_Effect.transform.position, dest, m_RealSpeed * Time.deltaTime);
                            m_Effect.transform.position = Utility.GetBezierPoint(m_StartPos, m_ControlPos, dest, (curSectionTime - StartTime) / 1000.0f / m_Lifetime);
                            if ((dest - m_Effect.transform.position).sqrMagnitude <= 0.01f)
                            {
                                m_HitEffectRotation = Quaternion.LookRotation(m_StartPos - dest);
                                if (m_NoImpact)
                                {
                                    instance.SetVariable("hitEffectRotation", m_HitEffectRotation);
                                }
                                else
                                {
                                    int impactId = EntityController.Instance.GetTrackSendImpact(senderObj.ObjId, senderObj.Seq, instance.Variables);
                                    Dictionary <string, object> args;
                                    TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args);
                                    if (args.ContainsKey("hitEffectRotation"))
                                    {
                                        args["hitEffectRotation"] = m_HitEffectRotation;
                                    }
                                    else
                                    {
                                        args.Add("hitEffectRotation", m_HitEffectRotation);
                                    }
                                    EntityController.Instance.TrackSendImpact(senderObj.ObjId, senderObj.SkillId, senderObj.Seq, impactId, args);
                                    int senderId, targetId;
                                    EntityController.Instance.CalcSenderAndTarget(senderObj, out senderId, out targetId);
                                }
                                m_IsHit = true;
                            }
                        }
                        if (curSectionTime > StartTime + m_Lifetime * 1000)
                        {
                            m_Effect.SetActive(false);
                            ResourceSystem.Instance.RecycleObject(m_Effect);
                            m_Effect = null;
                            instance.StopCurSection();
                            return(false);
                        }
                    }
                    else
                    {
                        return(false);
                    }

                    //GameFramework.LogSystem.Debug("EmitEffectTriger:{0}", m_EffectPath);
                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                instance.StopCurSection();
                return(false);
            }
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            GameObject target = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj    = senderObj.TrackEffectObj;
                target = senderObj.GfxObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            switch (m_RelativeType)
            {
            case "RelativeSelf":
                SetTransformRelativeSelf(obj);
                break;

            case "RelativeTarget":
                SetTransformRelativeTarget(obj, target);
                break;

            case "RelativeWorld":
                if (m_PosObjPath == "vector3")
                {
                    obj.transform.position = m_Postion;
                }
                else
                {
                    var tobj = GameObject.Find(m_PosObjPath);
                    if (null != tobj)
                    {
                        obj.transform.position = tobj.transform.position;
                    }
                }
                if (m_RotateObjPath == "eular")
                {
                    obj.transform.rotation = Quaternion.Euler(m_Rotate);
                }
                else
                {
                    var tobj = GameObject.Find(m_RotateObjPath);
                    if (null != tobj)
                    {
                        obj.transform.rotation = tobj.transform.rotation;
                    }
                }
                break;
            }
            if (m_IsUseTerrainHeight)
            {
                Vector3 terrain_pos = TriggerUtil.GetGroundPos(obj.transform.position);
                obj.transform.position = terrain_pos;
            }
            return(false);
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill)
            {
                return(false);//track只能在impact或buff里使用
            }
            Scene      scene = senderObj.Scene;
            EntityInfo obj   = senderObj.GfxObj;

            if (null != obj)
            {
                if (curSectionTime >= StartTime)
                {
                    if (!m_IsStarted)
                    {
                        m_IsStarted = true;

                        Vector3 dest = obj.GetMovementStateInfo().GetPosition3D();
                        dest.Y += 1.5f;

                        Vector3 pos = scene.EntityController.GetImpactSenderPosition(senderObj.ActorId, senderObj.SkillId, senderObj.Seq);
                        object  speedObj;
                        if (instance.Variables.TryGetValue("emitSpeed", out speedObj))
                        {
                            m_Speed = (float)speedObj;
                        }
                        else
                        {
                            return(false);
                        }

                        float duration = m_Duration;
                        if (duration > Geometry.c_FloatPrecision)
                        {
                            float d = duration / 1000.0f;
                            m_Lifetime = d;
                            m_Speed    = (dest - m_StartPos).Length() / m_Lifetime;
                        }
                        else
                        {
                            m_Lifetime = 1.0f;
                            if (m_Speed > Geometry.c_FloatPrecision)
                            {
                                m_Lifetime = (dest - m_StartPos).Length() / m_Speed;
                            }
                        }
                    }
                    else if (curSectionTime > StartTime + (long)(m_Lifetime * 1000))
                    {
                        m_HitEffectRotation = Quaternion.Identity;
                        if (m_NoImpact)
                        {
                            instance.SetVariable("hitEffectRotation", m_HitEffectRotation);
                        }
                        else
                        {
                            int impactId = scene.EntityController.GetTrackSendImpact(senderObj.ActorId, senderObj.Seq, instance.Variables);
                            Dictionary <string, object> args;
                            TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args);
                            if (args.ContainsKey("hitEffectRotation"))
                            {
                                args["hitEffectRotation"] = m_HitEffectRotation;
                            }
                            else
                            {
                                args.Add("hitEffectRotation", m_HitEffectRotation);
                            }
                            scene.EntityController.TrackSendImpact(senderObj.ActorId, senderObj.SkillId, senderObj.Seq, impactId, args);
                            int senderId, targetId;
                            scene.EntityController.CalcSenderAndTarget(senderObj, out senderId, out targetId);
                        }
                        instance.StopCurSection();
                        return(false);
                    }

                    //GameFramework.LogSystem.Debug("EmitEffectTriger:{0}", m_EffectPath);
                    return(true);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                instance.StopCurSection();
                return(false);
            }
        }
        private void AttachToObject(EntityInfo obj, EntityInfo owner)
        {
            Vector3 world_pos = TriggerUtil.TransformPoint(owner.GetMovementStateInfo().GetPosition3D(), m_Postion, owner.GetMovementStateInfo().GetFaceDir());

            TriggerUtil.MoveObjTo(obj, world_pos);
        }
Beispiel #22
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            GameObject targetObj = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj       = senderObj.TrackEffectObj;
                targetObj = senderObj.GfxObj;
            }
            bool isTower = !EntityController.Instance.IsMovableEntity(obj);

            if (isTower)
            {
                return(false);
            }
            if (!m_TargetChecked)
            {
                m_TargetChecked = true;
                m_RealDuration  = m_Duration;
                m_RealVelocity  = m_Velocity;
                if (m_RealDuration <= 0)
                {
                    m_RealDuration += instance.CurSectionDuration;
                }
                if (m_RealDuration <= 0)
                {
                    LogSystem.Warn("jump duration is 0, skill id:{0} dsl skill id:{1}", senderObj.SkillId, instance.DslSkillId);
                    return(false);
                }
                if (null != targetObj || m_IsForRoundMove)
                {
                    Vector3 srcPos    = obj.transform.position;
                    Vector3 targetPos = Vector3.zero;
                    if (null != targetObj)
                    {
                        targetPos = targetObj.transform.position;
                    }
                    if (m_IsForRoundMove)
                    {
                        TriggerUtil.GetSkillStartPosition(srcPos, senderObj.ConfigData, instance, senderObj.ActorId, senderObj.TargetActorId, ref targetPos);
                    }
                    if (targetPos.sqrMagnitude > Geometry.c_FloatPrecision)
                    {
                        float degree = Geometry.GetYRadian(new ScriptRuntime.Vector2(srcPos.x, srcPos.z), new ScriptRuntime.Vector2(targetPos.x, targetPos.z));
                        ScriptRuntime.Vector2 newPos = new ScriptRuntime.Vector2(targetPos.x, targetPos.z) + Geometry.GetRotate(new ScriptRuntime.Vector2(m_Offset.x, m_Offset.z), degree);
                        targetPos   = new Vector3(newPos.X, targetPos.y + m_Offset.y, newPos.Y);
                        m_TargetPos = targetPos;
                        if (m_StopAtTarget == (int)StopAtTargetType.AdjustVelocity)
                        {
                            m_RealVelocity = (long)(1000.0f * (targetPos - srcPos).magnitude / m_RealDuration);
                        }
                        else if (m_StopAtTarget == (int)StopAtTargetType.AdjustTime)
                        {
                            m_RealDuration = (long)(1000.0f * (targetPos - srcPos).magnitude / m_RealVelocity);
                            CalcYVelocityAndG();
                        }
                        m_Forward   = targetPos - srcPos;
                        m_Forward.y = 0;
                        m_Forward.Normalize();
                    }
                    else
                    {
                        m_Forward = obj.transform.forward;
                    }
                }
                else
                {
                    m_Forward = obj.transform.forward;
                }
                m_InitY = obj.transform.position.y;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            else if (curSectionTime <= StartTime + m_RealDuration)
            {
                float   t         = (float)(int)(curSectionTime - StartTime) / 1000.0f;
                float   disty     = m_YVelocity * t - m_G * t * t / 2;
                float   dist      = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity;
                Vector3 targetPos = obj.transform.position + m_Forward * dist;
                targetPos.y = m_InitY + disty;
                TriggerUtil.MoveObjTo(obj, targetPos);
                return(true);
            }
            else
            {
                Vector3 srcPos = obj.transform.position;
                if (m_IsForRoundMove && m_TargetPos.sqrMagnitude > Geometry.c_FloatPrecision)
                {
                    srcPos = m_TargetPos;
                }
                obj.transform.position = new Vector3(srcPos.x, m_InitY, srcPos.z);
                return(false);
            }
        }
Beispiel #23
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            if (null != senderObj.TrackEffectObj)
            {
                obj = senderObj.TrackEffectObj;
            }
            bool isTower = !EntityController.Instance.IsMovableEntity(obj);

            if (isTower)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (!m_IsCurveMoving)
            {
                if (m_IsForRoundMove && m_TargetPos.sqrMagnitude > Geometry.c_FloatPrecision)
                {
                    obj.transform.position = m_TargetPos;
                }
                return(false);
            }
            if (!m_IsInited)
            {
                Init(senderObj, instance);
            }
            if (m_SectionListCopy.Count == 0)
            {
                m_IsCurveMoving = false;
                return(false);
            }
            m_Now += TriggerUtil.ConvertToSecond((long)(instance.OriginalDelta * instance.MoveScale));
            MoveSectionInfo cur_section = m_SectionListCopy[0];

            if (m_Now - cur_section.startTime > cur_section.moveTime)
            {
                float end_time  = cur_section.startTime + cur_section.moveTime;
                float used_time = end_time - cur_section.lastUpdateTime;
                cur_section.curSpeedVect = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, used_time);
                m_SectionListCopy.RemoveAt(0);
                if (m_SectionListCopy.Count > 0)
                {
                    cur_section                = m_SectionListCopy[0];
                    cur_section.startTime      = end_time;
                    cur_section.lastUpdateTime = end_time;
                    cur_section.curSpeedVect   = cur_section.speedVect;
                }
                else
                {
                    m_IsCurveMoving = false;
                }
            }
            else
            {
                cur_section.curSpeedVect   = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, m_Now - cur_section.lastUpdateTime);
                cur_section.lastUpdateTime = m_Now;
            }
            return(true);
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            if (null != senderObj.TrackEffectObj)
            {
                obj = senderObj.TrackEffectObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            if (!m_IsCurveMoving)
            {
                return(false);
            }
            if (!m_IsInited)
            {
                Init(senderObj, instance);
            }
            if (m_SectionListCopy.Count == 0)
            {
                m_IsCurveMoving = false;
                return(false);
            }
            m_Now += TriggerUtil.ConvertToSecond((long)(instance.OriginalDelta * instance.MoveScale));
            MoveSectionInfo cur_section = m_SectionListCopy[0];

            if (m_Now - cur_section.startTime > cur_section.moveTime)
            {
                float end_time  = cur_section.startTime + cur_section.moveTime;
                float used_time = end_time - cur_section.lastUpdateTime;
                cur_section.curSpeedVect = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, used_time);
                m_SectionListCopy.RemoveAt(0);
                if (m_SectionListCopy.Count > 0)
                {
                    cur_section                = m_SectionListCopy[0];
                    cur_section.startTime      = end_time;
                    cur_section.lastUpdateTime = end_time;
                    cur_section.curSpeedVect   = cur_section.speedVect;
                }
                else
                {
                    m_IsCurveMoving = false;
                }
            }
            else
            {
                cur_section.curSpeedVect   = Move(obj, cur_section.curSpeedVect, cur_section.accelVect, m_Now - cur_section.lastUpdateTime);
                cur_section.lastUpdateTime = m_Now;
            }
            return(true);
        }
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (null == obj)
            {
                return(false);
            }
            GameObject targetObj = senderObj.TargetGfxObj;

            if (null != senderObj.TrackEffectObj)
            {
                obj       = senderObj.TrackEffectObj;
                targetObj = senderObj.GfxObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            else if (curSectionTime <= StartTime + m_RealDuration)
            {
                if (!Prepare(senderObj, instance, obj, targetObj))
                {
                    return(false);
                }
                if (null != m_Curve && m_Curve.keys.Length >= 2)
                {
                    float   time      = Mathf.Clamp01((curSectionTime - StartTime) * 1.0f / m_RealDuration);
                    float   val       = m_Curve.Evaluate(time);
                    Vector3 targetPos = Vector3.SlerpUnclamped(new Vector3(m_StartPos.x, m_StartPos.y, m_StartPos.z), new Vector3(m_TargetPos.x, m_StartPos.y, m_StartPos.z), val);
                    if (!m_IsFreeMove)
                    {
                        if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos))
                        {
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                        else
                        {
                            targetPos = TriggerUtil.GetGroundPos(targetPos);
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                    }
                    else
                    {
                        TriggerUtil.MoveObjTo(obj, targetPos);
                    }
                }
                else
                {
                    float   dist      = TriggerUtil.ConvertToSecond(delta) * m_RealVelocity;
                    Vector3 targetPos = obj.transform.position + m_Forward * dist;
                    if (!m_IsFreeMove)
                    {
                        if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos))
                        {
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                        else
                        {
                            targetPos = TriggerUtil.GetGroundPos(targetPos);
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                    }
                    else
                    {
                        TriggerUtil.MoveObjTo(obj, targetPos);
                    }
                }
                return(true);
            }
            else
            {
                Vector3 diff = m_TargetPos - obj.transform.position;
                if (diff.sqrMagnitude > 0.01f)
                {
                    Vector3 targetPos = m_TargetPos;
                    if (!m_IsFreeMove)
                    {
                        if (!TriggerUtil.RaycastNavmesh(obj.transform.position, targetPos))
                        {
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                        else
                        {
                            targetPos = TriggerUtil.GetGroundPos(targetPos);
                            TriggerUtil.MoveObjTo(obj, targetPos);
                        }
                    }
                    else
                    {
                        TriggerUtil.MoveObjTo(obj, targetPos);
                    }
                }
                return(false);
            }
        }
Beispiel #26
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (obj == null)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            int senderId;
            int targetId;

            EntityController.Instance.CalcSenderAndTarget(senderObj, out senderId, out targetId);
            int impactId = senderObj.ConfigData.impacttoself;

            if (senderObj.ConfigData.type != (int)SkillOrImpactType.Skill)
            {
                if (impactId <= 0)
                {
                    int skillId           = EntityController.Instance.GetImpactSkillId(senderObj.ObjId, senderObj.SkillId, senderObj.Seq);
                    TableConfig.Skill cfg = TableConfig.SkillProvider.Instance.GetSkill(skillId);
                    if (null != cfg)
                    {
                        impactId = cfg.impacttoself;
                    }
                }
            }
            if (m_Radius <= Geometry.c_FloatPrecision)
            {
                Dictionary <string, object> args;
                TriggerUtil.CalcImpactConfig(0, 0, instance, senderObj.ConfigData, out args);
                EntityController.Instance.SendImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ObjId, senderId, senderId, impactId, true, args);
            }
            else
            {
                GameObject targetObj = senderObj.TargetGfxObj;
                int        ct        = 0;
                List <int> targetIds = new List <int>();
                TriggerUtil.AoeQuery(obj, targetObj, m_AoeType, m_Radius, m_AngleOrLength, instance, senderId, (int)SkillTargetType.Friend, m_RelativeCenter, m_RelativeToTarget, (float distSqr, int objId) => {
                    Dictionary <string, object> args;
                    TriggerUtil.CalcImpactConfig(0, 0, instance, senderObj.ConfigData, out args);
                    EntityController.Instance.SendImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ObjId, senderId, objId, impactId, true, args);
                    targetIds.Add(objId);
                    ++ct;
                    if (m_MaxCount <= 0 || ct < m_MaxCount)
                    {
                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                });
            }
            return(false);
        }
Beispiel #27
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            Scene      scene = senderObj.Scene;
            EntityInfo obj   = senderObj.GfxObj;

            if (null != obj)
            {
                if (curSectionTime >= StartTime)
                {
                    int senderId;
                    int targetId;
                    scene.EntityController.CalcSenderAndTarget(senderObj, out senderId, out targetId);
                    string effectPath = SkillParamUtility.RefixResourceVariable(m_EffectPath, instance, senderObj.ConfigData.resources);
                    string emitBone   = SkillParamUtility.RefixStringVariable(m_EmitBone, instance);
                    float  emitSpeed  = m_EmitSpeed;
                    if (!string.IsNullOrEmpty(effectPath))
                    {
                        EntityInfo target = scene.EntityController.GetGameObject(targetId);
                        if (null != target)
                        {
                            int emitImpact = m_EmitImpact;
                            if (!m_IsExternalImpact)
                            {
                                emitImpact = SkillInstance.GenInnerEmitSkillId(m_EmitImpact <= 0 ? 1 : m_EmitImpact);
                            }
                            int impactId = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData);
                            Dictionary <string, object> args;
                            TriggerUtil.CalcImpactConfig(emitImpact, impactId, instance, senderObj.ConfigData, out args);
                            Dictionary <string, object> addArgs = new Dictionary <string, object>()
                            {
                                { "emitEffect", effectPath }, { "emitSpeed", emitSpeed }, { "emitDir", m_Dir }, { "emitScale", m_Scale }
                            };
                            foreach (var pair in addArgs)
                            {
                                if (args.ContainsKey(pair.Key))
                                {
                                    args[pair.Key] = pair.Value;
                                }
                                else
                                {
                                    args.Add(pair.Key, pair.Value);
                                }
                            }
                            scene.EntityController.TrackImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ActorId, senderId, targetId, emitBone, m_EmitImpact, m_Pos, args);
                        }
                    }
                    else
                    {
                        LogSystem.Warn("[skill:{0} dsl skill id:{1}] emit effect is empty.", senderObj.SkillId, instance.DslSkillId);
                    }
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #28
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (obj == null)
            {
                return(false);
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            long durationTime = m_DurationTime.Get(instance);
            long intervalTime = m_IntervalTime.Get(instance);

            if (curSectionTime > StartTime + durationTime)
            {
                return(false);
            }
            if (m_LastTime + intervalTime < curSectionTime)
            {
                m_LastTime = curSectionTime;
                int ct = m_Targets.Count;
                if (ct <= 0)
                {
                    int targetType = EntityController.Instance.GetTargetType(senderObj.ObjId, senderObj.ConfigData, senderObj.Seq);
                    int impactId   = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData);
                    if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill)
                    {
                        m_SenderId = senderObj.ObjId;
                    }
                    else
                    {
                        m_SenderId = senderObj.TargetObjId;
                    }
                    TriggerUtil.AoeQuery(senderObj, instance, m_SenderId, targetType, m_RelativeCenter, m_RelativeToTarget, (float distSqr, int objId) => {
                        m_SortedTargets.Add((int)(distSqr * c_MaxObjectId) * c_MaxObjectId + objId, objId);
                        return(true);
                    });
                    var vals = m_SortedTargets.Values;
                    if (senderObj.ConfigData.maxAoeTargetCount > 0 && vals.Count > senderObj.ConfigData.maxAoeTargetCount)
                    {
                        var enumerator = vals.GetEnumerator();
                        for (int ix = 0; ix < senderObj.ConfigData.maxAoeTargetCount; ++ix)
                        {
                            enumerator.MoveNext();
                            m_Targets.Add(enumerator.Current);
                        }
                    }
                    else
                    {
                        m_Targets.AddRange(vals);
                    }
                    m_CurTargetIndex = 0;
                    ct = m_Targets.Count;
                }
                if (ct > 0 && m_CurTargetIndex < ct)
                {
                    Dictionary <string, object> args;
                    TriggerUtil.CalcImpactConfig(0, m_ImpactId, instance, senderObj.ConfigData, out args);
                    EntityController.Instance.SendImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ObjId, m_SenderId, m_Targets[m_CurTargetIndex], m_ImpactId, IsFinal, args);
                    ++m_CurTargetIndex;
                }
                else
                {
                    return(false);
                }
            }
            return(true);
        }
Beispiel #29
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            Scene      scene = senderObj.Scene;
            EntityInfo obj   = senderObj.GfxObj;

            if (null != obj)
            {
                if (curSectionTime >= StartTime)
                {
                    int targetType = scene.EntityController.GetTargetType(senderObj.ActorId, senderObj.ConfigData, senderObj.Seq);
                    int senderId   = 0;
                    if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill)
                    {
                        senderId = senderObj.ActorId;
                    }
                    else
                    {
                        senderId = senderObj.TargetActorId;
                    }
                    string effectPath = SkillParamUtility.RefixResourceVariable(m_EffectPath, instance, senderObj.ConfigData.resources);
                    int    emitImpact = m_EmitImpact;
                    if (!m_IsExternalImpact)
                    {
                        emitImpact = SkillInstance.GenInnerEmitSkillId(m_EmitImpact <= 0 ? 1 : m_EmitImpact);
                    }
                    int    impactId  = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData);
                    string emitBone  = SkillParamUtility.RefixStringVariable(m_EmitBone, instance);
                    float  emitSpeed = m_EmitSpeed;
                    int    ct        = 0;
                    TriggerUtil.AoeQuery(senderObj, instance, senderId, targetType, m_RelativeCenter, m_RelativeToTarget, (float distSqr, int objId) => {
                        Dictionary <string, object> args;
                        TriggerUtil.CalcImpactConfig(emitImpact, impactId, instance, senderObj.ConfigData, out args);
                        Dictionary <string, object> addArgs = new Dictionary <string, object>()
                        {
                            { "emitEffect", effectPath }, { "emitSpeed", emitSpeed }, { "emitDir", m_Dir }, { "emitScale", m_Scale }
                        };
                        foreach (var pair in addArgs)
                        {
                            if (args.ContainsKey(pair.Key))
                            {
                                args[pair.Key] = pair.Value;
                            }
                            else
                            {
                                args.Add(pair.Key, pair.Value);
                            }
                        }
                        scene.EntityController.TrackImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ActorId, senderId, objId, emitBone, emitImpact, m_Pos, args);
                        ++ct;
                        if (senderObj.ConfigData.maxAoeTargetCount <= 0 || ct < senderObj.ConfigData.maxAoeTargetCount)
                        {
                            return(true);
                        }
                        else
                        {
                            return(false);
                        }
                    });
                    //GameFramework.LogSystem.Debug("AoeEmitEffectTriger:{0}", m_EffectPath);
                    return(false);
                }
                else
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }
        }
Beispiel #30
0
        public override bool Execute(object sender, SkillInstance instance, long delta, long curSectionTime)
        {
            GfxSkillSenderInfo senderObj = sender as GfxSkillSenderInfo;

            if (null == senderObj)
            {
                return(false);
            }
            GameObject obj = senderObj.GfxObj;

            if (obj == null)
            {
                return(false);
            }
            if (null != senderObj.TrackEffectObj)
            {
                obj = senderObj.TrackEffectObj;
            }
            if (curSectionTime < StartTime)
            {
                return(true);
            }
            int senderId   = 0;
            int targetType = EntityController.Instance.GetTargetType(senderObj.ObjId, senderObj.ConfigData, senderObj.Seq);
            int impactId   = TriggerUtil.GetSkillImpactId(instance.Variables, senderObj.ConfigData);

            if (senderObj.ConfigData.type == (int)SkillOrImpactType.Skill)
            {
                senderId = senderObj.ObjId;
            }
            else
            {
                senderId = senderObj.TargetObjId;
            }
            float range = 0;

            TableConfig.Skill cfg = senderObj.ConfigData;
            if (null != cfg)
            {
                range = cfg.aoeSize;
            }
            long    duration = m_DurationTime.Get(instance);
            float   angle    = Geometry.DegreeToRadian(obj.transform.localRotation.eulerAngles.y);
            Vector3 center   = obj.transform.TransformPoint(m_RelativeCenter);

            if (!m_IsStarted)
            {
                m_IsStarted = true;
                m_LastPos   = center;
            }
            else if ((center - m_LastPos).sqrMagnitude >= 0.25f || StartTime + duration < curSectionTime)
            {
                Vector3    c           = (m_LastPos + center) / 2;
                Vector3    angleu      = center - m_LastPos;
                float      queryRadius = range + angleu.magnitude / 2;
                int        ct          = 0;
                bool       isCollide   = false;
                List <int> targetIds   = new List <int>();
                GameFramework.PluginFramework.Instance.KdTree.QueryWithFunc(c.x, c.y, c.z, queryRadius, (float distSqr, GameFramework.KdTreeObject kdTreeObj) => {
                    int targetId = kdTreeObj.Object.GetId();
                    if (targetType == (int)SkillTargetType.Enemy && CharacterRelation.RELATION_ENEMY == EntityController.Instance.GetRelation(senderId, targetId) ||
                        targetType == (int)SkillTargetType.Friend && CharacterRelation.RELATION_FRIEND == EntityController.Instance.GetRelation(senderId, targetId))
                    {
                        bool isMatch = Geometry.IsCapsuleDiskIntersect(new ScriptRuntime.Vector2(m_LastPos.x, m_LastPos.z), new ScriptRuntime.Vector2(angleu.x, angleu.z), range, new ScriptRuntime.Vector2(kdTreeObj.Position.X, kdTreeObj.Position.Z), kdTreeObj.Radius);
                        if (isMatch)
                        {
                            isCollide = true;
                            if (!m_SingleHit || !m_Targets.Contains(targetId))
                            {
                                m_Targets.Add(targetId);
                                Dictionary <string, object> args;
                                TriggerUtil.CalcImpactConfig(0, impactId, instance, senderObj.ConfigData, out args);
                                EntityController.Instance.SendImpact(senderObj.ConfigData, senderObj.Seq, senderObj.ObjId, senderId, targetId, impactId, IsFinal, args);
                                targetIds.Add(targetId);
                                ++ct;
                                if (senderObj.ConfigData.maxAoeTargetCount <= 0 || ct < senderObj.ConfigData.maxAoeTargetCount)
                                {
                                    return(true);
                                }
                                else
                                {
                                    return(false);
                                }
                            }
                        }
                    }
                    return(true);
                });
                m_LastPos = center;
                if (isCollide && m_FinishOnCollide)
                {
                    return(false);
                }
            }
            if (StartTime + duration < curSectionTime)
            {
                instance.StopCurSection();
                return(false);
            }
            return(true);
        }