public Vector3D GetMove(double distance, Vector3D towards)
        {
            Vector3D ret = new Vector3D(x, z, y);

            ret.Move(distance, towards);
            return(ret);
        }
Exemple #2
0
 public Vector3D GetMove(double distance, Vector3D towards)
 {
     Vector3D ret = new Vector3D(x, z, y);
     ret.Move(distance, towards);
     return ret;
 }
Exemple #3
0
        /// <summary>
        /// Creates a path to another vector
        /// </summary>
        /// <param name="vectorTo">The vector to.</param>
        /// <returns>An enumeration of a path from a vector to a vector</returns>
        public IEnumerable<Vector3S> PathTo(Vector3S vectorTo)
        {
            Vector3D pos = new Vector3D(this);
            Vector3S rounded = pos.GetRounded();
            while (rounded != vectorTo) {
                yield return rounded;
                pos.Move(1, new Vector3D(vectorTo));
                rounded = pos.GetRounded();
            }
            yield return vectorTo;
            yield break;

            Vector3S tempThis = new Vector3S(this);
            Vector3S a = vectorTo - this;
            Vector3S b = MathUtils.SignVector(a);
            a = MathUtils.AbsVector(a);
            Vector3S c = a * 2;

            int x, z, y;
            if ((a.x >= a.y) && (a.x >= a.z)) {
                x = 0; z = 1; y = 2;
            }
            else if ((a.y >= a.x) && (a.y >= a.z)) {
                x = 1; z = 2; y = 0;
            }
            else {
                x = 2; z = 0; y = 1;
            }

            int right = c.GetDimention(y) - a.GetDimention(x);
            int left = c.GetDimention(z) - a.GetDimention(x);
            for (int j = 0; j < a.GetDimention(x); j++) {
                yield return tempThis;

                if (right > 0) {
                    tempThis.SetValueInDimention(y, (short)(b.GetDimention(y) + tempThis.GetDimention(y)));
                    right -= c.GetDimention(x);
                }

                if (left > 0) {
                    tempThis.SetValueInDimention(z, (short)(b.GetDimention(z) + tempThis.GetDimention(z)));
                    left -= c.GetDimention(x);
                }
                right += c.GetDimention(y);
                left += c.GetDimention(z);
                tempThis.SetValueInDimention(x, (short)(b.GetDimention(x) + tempThis.GetDimention(x)));
            }
            yield return vectorTo;
        }
        /// <summary>
        /// Creates a path to another vector
        /// </summary>
        /// <param name="vectorTo">The vector to.</param>
        /// <returns>An enumeration of a path from a vector to a vector</returns>
        public IEnumerable <Vector3S> PathTo(Vector3S vectorTo)
        {
            Vector3D pos     = new Vector3D(this);
            Vector3S rounded = pos.GetRounded();

            while (rounded != vectorTo)
            {
                yield return(rounded);

                pos.Move(1, new Vector3D(vectorTo));
                rounded = pos.GetRounded();
            }
            yield return(vectorTo);

            yield break;

            Vector3S tempThis = new Vector3S(this);
            Vector3S a        = vectorTo - this;
            Vector3S b        = MathUtils.SignVector(a);

            a = MathUtils.AbsVector(a);
            Vector3S c = a * 2;

            int x, z, y;

            if ((a.x >= a.y) && (a.x >= a.z))
            {
                x = 0; z = 1; y = 2;
            }
            else if ((a.y >= a.x) && (a.y >= a.z))
            {
                x = 1; z = 2; y = 0;
            }
            else
            {
                x = 2; z = 0; y = 1;
            }

            int right = c.GetDimention(y) - a.GetDimention(x);
            int left  = c.GetDimention(z) - a.GetDimention(x);

            for (int j = 0; j < a.GetDimention(x); j++)
            {
                yield return(tempThis);

                if (right > 0)
                {
                    tempThis.SetValueInDimention(y, ( short )(b.GetDimention(y) + tempThis.GetDimention(y)));
                    right -= c.GetDimention(x);
                }

                if (left > 0)
                {
                    tempThis.SetValueInDimention(z, ( short )(b.GetDimention(z) + tempThis.GetDimention(z)));
                    left -= c.GetDimention(x);
                }
                right += c.GetDimention(y);
                left  += c.GetDimention(z);
                tempThis.SetValueInDimention(x, ( short )(b.GetDimention(x) + tempThis.GetDimention(x)));
            }
            yield return(vectorTo);
        }