A fast random number generator for .NET Colin Green, January 2005
Esempio n. 1
0
 /// <summary>
 /// this function physically initializes the world.
 /// </summary>
 public void start_world(string world_name, GraphicsDevice g)
 {
     input.ctrl_state      = 0;
     input.saved_delta     = new Vector2();
     input.last_ctrl_press = 0;
     if (settings.use_seed)
     {
         rand = new Lidgren.Network.NetRandom(settings.seed_id);
     }
     else
     {
         rand = new Lidgren.Network.NetRandom((int)System.DateTime.Now.Ticks);
     }
     if (cur_open_world != world_name)
     {
         world = new World(world_name, g);
     }
     else
     {
         world.world_ending = false;
     }
     cur_open_world = world_name;
     network_client.send_user_info(saved_players.players[cur_using_local_id]);
 }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            r        = new System.IO.StreamReader("exilania.ini");
            settings = new Settings(r);
            r.Close();
            // TODO: Add your initialization logic here
            if (!settings.use_custom_dimensions)
            {
                graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
                graphics.PreferredBackBufferWidth  = GraphicsDevice.DisplayMode.Width;
                screen_size = new Point(GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height);
            }
            else
            {
                try
                {
                    graphics.PreferredBackBufferHeight = settings.custom_height;
                    graphics.PreferredBackBufferWidth  = settings.custom_width;
                    screen_size = new Point(settings.custom_width, settings.custom_height);
                }
                catch
                {
                    graphics.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height;
                    graphics.PreferredBackBufferWidth  = GraphicsDevice.DisplayMode.Width;
                    screen_size = new Point(GraphicsDevice.DisplayMode.Width, GraphicsDevice.DisplayMode.Height);
                }
            }
            graphics.ToggleFullScreen();
            GraphicsDevice.SamplerStates[1] = SamplerState.LinearClamp;
            graphics.ApplyChanges();
            screen_size = new Point(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height);
            try
            {
                System.IO.Directory.CreateDirectory(@"logs");
            }
            catch
            {
            }
            text_stream           = new System.IO.StreamWriter(@"logs/debug" + DateTime.Now.Ticks.ToString() + ".txt");
            text_stream.AutoFlush = true;
            text_stream.WriteLine("Open the document");

            block_types = new BlockManager();
            BlockData.enum_blocks();
            World.liquid_blocks = new int[] { 0, (int)block_types.get_block_by_name("Water") };
            //BlockData.export_block_data(block_types.blocks);
            item_manager             = new ItemManager();
            furniture_manager        = new FurnitureManager();
            plant_manager            = new PlantManager();
            material_manager         = new MaterialManager();
            crafting_manager         = new CraftManager();
            world_manager            = new WorldManager();
            world_definition_manager = new WorldCreator();
            particle_manager         = new ParticleManager();

            if (settings.use_seed)
            {
                rand = new Lidgren.Network.NetRandom(settings.seed_id);
            }
            else
            {
                rand = new Lidgren.Network.NetRandom((int)System.DateTime.Now.Ticks);
            }
            menu           = new MainMenu();
            body_templates = new List <BodyTemplate>();
            r = new System.IO.StreamReader("bodies.txt");
            while (!r.EndOfStream)
            {
                body_templates.Add(new BodyTemplate(r, body_templates.Count));
            }
            r.Close();
            saved_players = new SavedPlayers();
            draw_debug    = settings.debugging;
            seed_id       = (int)DateTime.Now.Ticks;
            if (settings.use_seed)
            {
                seed_id = settings.seed_id;
            }
            display.add_message(Display.color_code + "00Welcome to Exilania. Seed ID: " + seed_id.ToString());
            rand   = new Lidgren.Network.NetRandom(seed_id);
            sounds = new Sounds();

            //CubicSpline cs = new CubicSpline(new double[]{1,10,30,60,100},new double[]{1,2,5,9,13});
            CubicSpline cs         = new CubicSpline(new double[] { 0, 4, 10, 30, 100 }, new double[] { .05, .4, .7, 1, 1 });
            int         total_cost = 0;

            for (float i = 0; i < 100.1f; i += .5f)
            {
                total_cost += (int)cs.get_val_at(i);
                //Exilania.display.add_message("@05Cubic Spline[" + (i).ToString().PadLeft(3,'0') + "]:" + cs.get_val_at(i));
                //text_stream.WriteLine(Acc.sanitize_text_color(display.messages[display.messages.Count - 1]));
            }
            //Exilania.display.add_message("@06To get to level 100, you would need " + total_cost + " points.");

            base.Initialize();
        }