Ejemplo n.º 1
0
        public static Universe ReadUniverseFromFile(PlanetSim parent, int id)
        {
            try
            {
                using (StreamReader reader = new StreamReader(CreateFileName(id)))
                {
                    Universe createdUniverse = new Universe(parent, id);

                    string[] source = reader.ReadToEnd().Split('\n');
                    for (int i = 0; i < source.Length; i++)
                    {
                        source[i] = source[i].Trim();
                    }

                    if (source[0].IndexOf(UniverseHeader) > 0)
                    {
                        return(null);
                    }

                    ReadUniverseParameters(createdUniverse, source);
                    ReadPlanets(createdUniverse, source);

                    return(createdUniverse);
                }
            }
            catch { }

            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        static void Main(string[] args)
        {
            int  screenWidth       = 1920;
            int  screenHeight      = 1080;
            int  maxProcessorsUsed = 0;
            bool freeFPS           = false;

            try
            {
                if (args.Length > 0)
                {
                    maxProcessorsUsed = Convert.ToInt32(args[0]);
                }
            }
            catch
            {
                maxProcessorsUsed = 0;
            }

            if (maxProcessorsUsed < 0)
            {
                maxProcessorsUsed = 0;
            }

            try
            {
                if (args.Length > 2)
                {
                    screenWidth  = Convert.ToInt32(args[1]);
                    screenHeight = Convert.ToInt32(args[2]);
                }
            }
            catch
            {
                screenWidth  = 1920;
                screenHeight = 1080;
            }

            try
            {
                if (args.Length > 3)
                {
                    freeFPS = Convert.ToInt32(args[3]) > 0;
                }
            }
            catch
            {
                freeFPS = false;
            }

            using (PlanetSim game = new PlanetSim(maxProcessorsUsed, screenWidth, screenHeight, freeFPS))
            {
                game.Run();
            }
        }
Ejemplo n.º 3
0
        public Universe(PlanetSim parent, int id) : base(parent)
        {
            Planets          = new PlanetCollection();
            SelectedPlanets  = new List <Planet>();
            Camera           = new UniverseCamera(Parent.GraphicsDevice.Viewport);
            GravityHandler   = parent.GravityHandler;
            CollisionHandler = parent.CollisionHandler;
            MultiProcessing  = parent.MultiProcessing;
            ID = id;

            Reset();
        }