Esempio n. 1
0
        private static V2RV2 ParseShortV2RV2(string s)
        {
            // Format: <float;float:float> ; args are rx,ry,angle resp.
            int   ii   = 0;
            int   from = 1;
            float x    = 0;

            while (++ii < s.Length)
            {
                if (s[ii] == ';')
                {
                    x    = Float(s, from, ii);
                    from = ii + 1;
                    break;
                }
            }
            while (++ii < s.Length)
            {
                if (s[ii] == ':')
                {
                    float y = Float(s, from, ii);
                    from = ii + 1;
                    return(V2RV2.Rot(x, y, Float(s, from, s.Length - 1)));
                }
            }
            throw new FormatException("Bad V2RV2 formatting: " + s);
        }
Esempio n. 2
0
        public static V2RV2 ParseV2RV2(string s)
        {
            // Format: <float;float:float;float:float> (nx,ny,rx,ry,angle)
            // OR the RV2 format (rx,ry,angle).
            if (s == "<>")
            {
                return(V2RV2.Zero);
            }
            if (s.CountOf(':') == 0)
            {
                return(V2RV2.Angle(Float(s, 1, s.Length - 1)));
            }
            if (s.CountOf(':') == 1)
            {
                return(ParseShortV2RV2(s));
            }
            int ii   = 0;
            int from = 1;
            var nx   = NextFloat(s, ref from, ref ii, ';');
            var ny   = NextFloat(s, ref from, ref ii, ':');
            var rx   = NextFloat(s, ref from, ref ii, ';');
            var ry   = NextFloat(s, ref from, ref ii, ':');

            return(new V2RV2(nx, ny, rx, ry, Float(s, from, s.Length - 1)));
        }
Esempio n. 3
0
 /// <summary>
 /// Create a velocity configuration.
 /// </summary>
 /// <param name="path">Movement descriptor</param>
 /// <param name="parentLoc">Global location of parent. Set to zero if using a transform parent</param>
 /// <param name="localLoc">Location of this relative to parent. Only distinguished from parent for applying modifiers.</param>
 public Movement(VTP path, Vector2 parentLoc, V2RV2 localLoc)
 {
     angle        = localLoc.angle;
     cos_rot      = M.CosDeg(localLoc.angle);
     sin_rot      = M.SinDeg(localLoc.angle);
     vtp          = path;
     flipX        = 1;
     flipY        = 1;
     this.rootPos = parentLoc + localLoc.TrueLocation;
 }
Esempio n. 4
0
 /// <summary>
 /// Create a shell velocity configuration with no movement.
 /// </summary>
 /// <param name="parentLoc">Global location of parent. Set to zero if using a transform parent</param>
 /// <param name="localPos">Location of this relative to parent</param>
 public Movement(Vector2 parentLoc, V2RV2 localPos) : this(VTPRepo.NoVTP, parentLoc, localPos)
 {
 }