示例#1
0
        protected override void Update()
        {
            base.Update();

            //buff的持续周期
            if (MBuffMeta.Duration > 0)
            {
                bool b = m_durationReg.Update();
                if (b)
                {
                    OnFinal();
                }
            }


            if (MBuffMeta.Period > 0)
            {
                bool b = m_dotReg.Update();
                if (b)
                {
                    OnPeriod();
                }
            }
            else if (CMathUtil.IsZero(MBuffMeta.Period))
            {
                OnPeriod();
            }
        }
示例#2
0
        public virtual void SyncSpeed(float value)
        {
            Vector3 v = m_velocity;

            if (!CMathUtil.ZeroVector3(v))
            {
                SetVelicity(value * v.normalized);
            }
        }
示例#3
0
 /// <summary>
 /// 在xz平面方向上的矢量
 /// </summary>
 /// <param name="value">value的值是基于NDC空间的.0度旋转是vect3.right</param>
 public void SetDirection(Vector3 value)
 {
     value.y = 0;
     if (CMathUtil.ZeroVector3(value))
     {
         return;
     }
     SetRotationByVelocity(value);
     m_trans.localEulerAngles = new Vector3(0, m_rotationDegree, 0);
 }
示例#4
0
        /// <summary>
        /// 开始奔跑, 传入单位速度矢量
        /// 但记住如果之前开始了不受控制, 那请关闭它
        /// </summary>
        /// <param name="value">方向矢量</param>
        /// <param name="changeDirection">是否更新朝向</param>
        public void Move(Vector3 value, bool changeDirection = true)
        {
            if (CMathUtil.ZeroVector3(value))
            {
                Stop();
                return;
            }

            m_currState.SetVelicity(MaxSpeed * value);
            if (changeDirection)
            {
                m_spacial.SetDirection(value);
            }
        }
示例#5
0
        public static List <Vector3> FunnelPath(List <Vector3> path)
        {
            List <Vector3> temp = new List <Vector3>();

            if (path.Count <= 2)
            {
                temp.AddRange(path);
                return(temp);
            }

            Dictionary <int, bool> removed = new Dictionary <int, bool>();

            for (int i = 0; i < path.Count; i++)
            {
                removed[i] = false;
            }

            for (int i = 0; i < path.Count - 1; i++)
            {
                if (removed[i])
                {
                    continue;
                }

                Vector3 prev = path[i];
                for (int j = i + 1; j < path.Count - 1; j++)
                {
                    if (removed[j])
                    {
                        continue;
                    }

                    Vector3 now  = path[j];
                    Vector3 next = path[j + 1];

                    //横着一条线
                    if (CMathUtil.FloatEqual(prev.x, now.x) &&
                        CMathUtil.FloatEqual(next.x, now.x))
                    {
                        removed[j] = true;
                        continue;
                    }

                    //竖着一条线
                    if (CMathUtil.FloatEqual(prev.z, now.z) &&
                        CMathUtil.FloatEqual(next.z, now.z))
                    {
                        removed[j] = true;
                        continue;
                    }

                    //斜着一条线
                    float dx1 = now.x - prev.x;
                    float dx2 = next.x - now.x;
                    float dz1 = now.z - prev.z;
                    float dz2 = next.z - now.z;
                    if (dx1 * dx2 > 0 &&
                        dz1 * dz2 > 0 &&
                        CMathUtil.FloatEqual(dz1 / dx1, dz2 / dx2))
                    {
                        removed[j] = true;
                        continue;
                    }
                }
            }



            temp.Clear();
            for (int i = 0; i < path.Count; i++)
            {
                if (removed[i])
                {
                    continue;
                }
                temp.Add(path[i]);
            }

            return(temp);
        }