示例#1
0
    /// <summary>
    /// Moves a point current in a straight line towards a target point.
    /// </summary>
    public static Vector4_ MoveTowards(Vector4_ current, Vector4_ target, double maxDistanceDelta)
    {
        var a = target - current;
        var magnitude = a.magnitude;

        return (magnitude <= maxDistanceDelta || magnitude == 0) ? target : current + a / magnitude * maxDistanceDelta;
    }
示例#2
0
    public static PVETriggerCollider Create(SCreateTriggerBehaviour b)
    {
        if (!Level.currentRoot)
        {
            return(null);
        }
        if (!triggerParent)
        {
            triggerParent      = Level.currentRoot.AddNewChild();
            triggerParent.name = "trigger_parent";
        }

        Transform t = triggerParent.AddNewChild();

        t.name = Util.Format("trigger_{0}", b.triggerId.ToString("D2"));
        var c = t.GetComponentDefault <PVETriggerCollider>();
        //必须要返回的示例,避免修改内存中的备份
        SCreateTriggerBehaviour b_new = new SCreateTriggerBehaviour(b.behaviour.DeepClone(), null);
        Vector4_ range = b_new.range;

        if (b_new.isRandom)
        {
            range.x = (new PseudoRandom()).Range(b_new.range.x, b_new.range.y);
            range.y = 0;
        }
        c.InitComponent(b_new, range);
        c.RefreshScenePlayers();
        return(c);
    }
示例#3
0
    private void ResetMotion()
    {
        m_motion = ConfigManager.Get <AnimMotionInfo>((int)(info.animMotion.x));

        motionOffset = Vector3_.zero;

        if (m_motion)
        {
            var count = m_motion.points.Length;

            if (count < 2)
            {
                count = 0;
            }

            m_motionFrame.x = Mathd.Clamp(info.animMotion.y, 1, count - 1);
            m_motionFrame.y = info.animMotion.z < 1 ? count - 1 : Mathd.Clamp(info.animMotion.z, info.animMotion.x, count - 1);
            m_motionFrame.z = (m_motionFrame.y - m_motionFrame.x + 1);
            m_motionFrame.w = m_motionFrame.z * 0.01; // cm -> m

            if (m_motion.offset != Vector3_.zero)
            {
                motionOffset += m_motion.offset * 0.01;
            }

            motionOffset.Set(motionOffset.z, motionOffset.y, motionOffset.x);
        }
        else
        {
            m_motionFrame = Vector4_.zero;
        }
    }
示例#4
0
    public void Scale(Vector4_ scale)
    {
        m_x *= scale.x;
        m_y *= scale.y;
        m_z *= scale.z;
        m_w *= scale.w;

        _CalculateParams();
    }
示例#5
0
 private void InitComponent(SCreateTriggerBehaviour b, Vector4_ range)
 {
     behaviour = b;
     CreateEffectNode();
     isTrigger = true;
     layer     = 0;
     AddLayerToTarget(Creature.COLLIDER_LAYER_HIT);
     SetRange(range);
     PlayParticle();
 }
示例#6
0
 /// <summary>
 /// Returns a vector that is made from the largest components of two vectors.
 /// </summary>
 public static Vector4_ Max(Vector4_ lhs, Vector4_ rhs)
 {
     return new Vector4_(Mathd.Max(lhs.x, rhs.x), Mathd.Max(lhs.y, rhs.y), Mathd.Max(lhs.z, rhs.z), Mathd.Max(lhs.w, rhs.w));
 }
示例#7
0
 /// <summary>
 /// Linearly interpolates between two vectors.
 /// </summary>
 public static Vector4_ LerpUnclamped(Vector4_ a, Vector4_ b, double t)
 {
     return new Vector4_(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t);
 }
示例#8
0
 /// <summary>
 /// Linearly interpolates between two vectors.
 /// </summary>
 public static Vector4_ Lerp(Vector4_ a, Vector4_ b, double t)
 {
     t = Mathd.Clamp01(t);
     return new Vector4_(a.x + (b.x - a.x) * t, a.y + (b.y - a.y) * t, a.z + (b.z - a.z) * t, a.w + (b.w - a.w) * t);
 }
示例#9
0
 /// <summary>
 /// Dot Product of two vectors.
 /// </summary>
 public static double Dot(Vector4_ a, Vector4_ b)
 {
     return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
 }
示例#10
0
 /// <summary>
 /// Returns the distance between a and b.
 /// </summary>
 public static double Distance(Vector4_ a, Vector4_ b)
 {
     var vector = a - b;
     return vector.magnitude;
 }
示例#11
0
 /// <summary>
 /// Cross Product of two vectors.
 /// </summary>
 public static Vector4_ Cross(Vector4_ lhs, Vector4_ rhs)
 {
     return new Vector4_(lhs.y * rhs.z - lhs.z * rhs.y, lhs.z * rhs.x - lhs.x * rhs.z, lhs.x * rhs.y - lhs.y * rhs.x);
 }
示例#12
0
 /// <summary>
 /// Returns a copy of vector with its magnitude clamped to maxLength.
 /// </summary>
 public static Vector4_ ClampMagnitude(Vector4_ vector, double maxLength)
 {
     return vector.sqrMagnitude > maxLength * maxLength ? vector.normalized * maxLength : vector;
 }
示例#13
0
 /// <summary>
 /// Multiplies two vectors component-wise.
 /// </summary>
 public static Vector4_ Scale(Vector4_ a, Vector4_ b)
 {
     return new Vector4_(a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w);
 }
示例#14
0
 /// <summary>
 /// Reflects a vector off the plane defined by a normal.
 /// </summary>
 public static Vector4_ Reflect(Vector4_ inDirection, Vector4_ inNormal)
 {
     return -2 * Dot(inNormal, inDirection) * inNormal + inDirection;
 }
示例#15
0
 /// <summary>
 /// Projects a vector onto a plane defined by a normal orthogonal to the plane.
 /// </summary>
 public static Vector4_ ProjectOnPlane(Vector4_ vector, Vector4_ planeNormal)
 {
     return vector - Project(vector, planeNormal);
 }
示例#16
0
    /// <summary>
    /// Projects a vector onto another vector.
    /// </summary>
    public static Vector4_ Project(Vector4_ vector, Vector4_ onNormal)
    {
        var dot = Dot(onNormal, onNormal);

        return dot < Mathd.Epsilon ? zero : onNormal * Dot(vector, onNormal) / dot;
    }