getGravityObjects() public method

public getGravityObjects ( ) : List
return List
Esempio n. 1
0
        public static void loadPlanets(string fileString, Map map)
        {
            //Loading just the first one in the file.

            int index1 = 0, index2 = 0;
            //Console.WriteLine("Loading Map:");
            if (((index1 = fileString.IndexOf("<Planet")) > -1) && ((index2 = fileString.IndexOf(">")) > -1) && fileString.Contains("</Planet>"))
            {

                string propriety = fileString.Substring(index1, index2 - index1 + 1);
                fileString = fileString.Remove(index1, index2 - index1 + 1);
                fileString = fileString.Remove(fileString.IndexOf("</Planet>"));

                Planet p = loadPlanetPropriety(propriety);
                map.getGravityObjects().Add(p);
                p.loadMoons(fileString, map);
            }
        }
Esempio n. 2
0
        private void setUpMoons(int spriteId, int number, int radius, int d, int mass, Map map)
        {
            double  angle, sin, cos;
            int distance = this.radius + radius + d;

            double x, y;

            for (int i = 0; i < number; i++)
            {
                angle = 360/number * i;
                sin = Math.Sin(angle);
                cos = Math.Cos(angle);
                x = cos*distance + this.x;
                y = -1 * sin + this.y;

                map.getGravityObjects().Add(new Moon(angle,spriteId, (float)x, (float)y, radius, mass, false));

            }

               //Getting the system acceleration to the moons
            Moon moon = (Moon) map.getGravityObjects().Last();
            moon.calculateGravity();
            double moonSpeed = Math.Sqrt(Math.Pow(moon.speedX,2) + Math.Pow(moon.speedY,2));
            moonSpeed = Math.Sqrt(mass*moonSpeed*distance);
            int sizeList = map.getGravityObjects().Capacity;
            for (int i = sizeList - number; i < sizeList; i++)
            {
                Moon m = (Moon) map.getGravityObjects().ElementAt(i);
                m.speedX = (float) (Math.Cos(m.angle) * moonSpeed);
                m.speedX = (float) (Math.Sin(m.angle) * moonSpeed);
            }
        }