예제 #1
0
    protected VInt3 CalculateTargetPoint(VInt3 p, VInt3 a, VInt3 b)
    {
        if (a.x == b.x && a.z == b.z)
        {
            return(a);
        }
        VFactor vFactor = AstarMath.NearestPointFactorXZ(ref a, ref b, ref p);
        long    num     = VInt3.Lerp(a, b, vFactor).XZSqrMagnitude(ref p);
        int     num2    = IntMath.Sqrt(num);
        long    num3    = a.XZSqrMagnitude(ref b);
        int     num4    = IntMath.Sqrt(num3);

        if (num4 == 0)
        {
            return(b);
        }
        int     num5     = Mathf.Clamp(this.forwardLook.i - num2, 0, this.forwardLook.i);
        VFactor vFactor2 = new VFactor((long)num5 * vFactor.den + vFactor.nom * (long)num4, (long)num4 * vFactor.den);

        if (vFactor2 > VFactor.one)
        {
            vFactor2 = VFactor.one;
        }
        else if (vFactor2 < VFactor.zero)
        {
            vFactor2 = VFactor.zero;
        }
        vFactor2.strip();
        return(VInt3.Lerp(a, b, vFactor2));
    }
예제 #2
0
    protected VInt3 CalculateTargetPoint(VInt3 p, VInt3 a, VInt3 b)
    {
        if ((a.x == b.x) && (a.z == b.z))
        {
            return(a);
        }
        VFactor f    = AstarMath.NearestPointFactorXZ(ref a, ref b, ref p);
        int     num3 = IntMath.Sqrt(VInt3.Lerp(a, b, f).XZSqrMagnitude(ref p));
        int     num5 = IntMath.Sqrt(a.XZSqrMagnitude(ref b));

        if (num5 == 0)
        {
            return(b);
        }
        int     num6 = Mathf.Clamp(this.forwardLook.i - num3, 0, this.forwardLook.i);
        VFactor one  = new VFactor((num6 * f.den) + (f.nom * num5), num5 * f.den);

        if (one > VFactor.one)
        {
            one = VFactor.one;
        }
        else if (one < VFactor.zero)
        {
            one = VFactor.zero;
        }
        one.strip();
        return(VInt3.Lerp(a, b, one));
    }
    protected VInt3 CalculateTargetPoint(VInt3 p, VInt3 a, VInt3 b)
    {
        if (a.x == b.x && a.z == b.z)
        {
            return(a);
        }
        VFactor f    = AstarMath.NearestPointFactorXZ(ref a, ref b, ref p);
        long    a2   = VInt3.Lerp(a, b, f).XZSqrMagnitude(ref p);
        int     num  = IntMath.Sqrt(a2);
        long    a3   = a.XZSqrMagnitude(ref b);
        int     num2 = IntMath.Sqrt(a3);

        if (num2 == 0)
        {
            return(b);
        }
        int     num3    = Mathf.Clamp(this.forwardLook.i - num, 0, this.forwardLook.i);
        VFactor vFactor = new VFactor((long)num3 * f.den + f.nom * (long)num2, (long)num2 * f.den);

        if (vFactor > VFactor.one)
        {
            vFactor = VFactor.one;
        }
        else if (vFactor < VFactor.zero)
        {
            vFactor = VFactor.zero;
        }
        vFactor.strip();
        return(VInt3.Lerp(a, b, vFactor));
    }