示例#1
0
        public static void CreateCliffsLand(GraphicsDevice graphicsDevice)
        {
            int size = 512;

            Map = new MapData[size, size];

            for (int x = 0; x < size; x++)
            {
                for (int y = 0; y < size; y++)
                {
                    float height = ComputeHeight(x * 1.0f, y * 2.0f, size, size, 1.0f, false);
                    float level  = (int)(height / 0.15f) * 0.15f + 0.08f;


                    Map[x, y].Height      = level;
                    Map[x, y].Biome       = BiomeLibrary.GetBiome("DeciduousForest").Biome;
                    Map[x, y].Erosion     = 1.0f;
                    Map[x, y].Weathering  = 0;
                    Map[x, y].Faults      = 1.0f;
                    Map[x, y].Temperature = 0.6f;
                    Map[x, y].Rainfall    = 0.6f;
                }
            }

            Overworld.Name = "Cliffs_" + MathFunctions.Random.Next(9999);
        }
示例#2
0
        protected override void LoadContent()
        {
#if SHARP_RAVEN
            try
            {
#endif
            // Prepare GemGui
            GumInputMapper = new Gui.Input.GumInputMapper(Window.Handle);
            GumInput       = new Gui.Input.Input(GumInputMapper);

            // Register all bindable actions with the input system.
            GumInput.AddAction("TEST", Gui.Input.KeyBindingType.Pressed);

            GumSkin = new RenderData(GraphicsDevice, Content,
                                     "newgui/xna_draw", "Content/newgui/sheets.txt");

            if (SoundManager.Content == null)
            {
                SoundManager.Content = Content;
                SoundManager.LoadDefaultSounds();
#if XNA_BUILD
                //SoundManager.SetActiveSongs(ContentPaths.Music.dwarfcorp, ContentPaths.Music.dwarfcorp_2,
                //    ContentPaths.Music.dwarfcorp_3, ContentPaths.Music.dwarfcorp_4, ContentPaths.Music.dwarfcorp_5);
#endif
            }

            if (GameSettings.Default.DisplayIntro)
            {
                StateManager.PushState(new IntroState(this, StateManager));
            }
            else
            {
                StateManager.PushState(new MainMenuState(this, StateManager));
            }

            BiomeLibrary.InitializeStatics();
            Embarkment.Initialize();
            VoxelChunk.InitializeStatics();
            ControlSettings.Load();
            Drawer2D.Initialize(Content, GraphicsDevice);
            ResourceLibrary.Initialize();
            base.LoadContent();
#if SHARP_RAVEN
        }

        catch (Exception exception)
        {
            if (ravenClient != null)
            {
                ravenClient.Capture(new SentryEvent(exception));
            }
            throw;
        }
#endif
        }
示例#3
0
        protected override void LoadContent()
        {
            // Prepare GemGui
            GumInput = new Gem.GumInputMapper(Window.Handle);
            GumSkin  = new Gum.RenderData(GraphicsDevice, Content,
                                          "newgui/xna_draw", "Content/newgui/sheets.txt");

            if (SoundManager.Content == null)
            {
                SoundManager.Content = Content;
                SoundManager.LoadDefaultSounds();
#if XNA_BUILD
                SoundManager.SetActiveSongs(ContentPaths.Music.dwarfcorp, ContentPaths.Music.dwarfcorp_2,
                                            ContentPaths.Music.dwarfcorp_3, ContentPaths.Music.dwarfcorp_4, ContentPaths.Music.dwarfcorp_5);
#endif
            }
            PlayState playState = new PlayState(this, StateManager);
            BiomeLibrary.InitializeStatics();
            StateManager.States["IntroState"]          = new IntroState(this, StateManager);
            StateManager.States["PlayState"]           = playState;
            StateManager.States["MainMenuState"]       = new MainMenuState(this, StateManager);
            StateManager.States["WorldSetupState"]     = new WorldSetupState(this, StateManager);
            StateManager.States["WorldGeneratorState"] = new WorldGeneratorState(this, StateManager);
            StateManager.States["OptionsState"]        = new OptionsState(this, StateManager);
            StateManager.States["NewOptionsState"]     = new NewOptionsState(this, StateManager);
            StateManager.States["EconomyState"]        = new EconomyState(this, StateManager, playState);
            StateManager.States["CompanyMakerState"]   = new CompanyMakerState(this, StateManager);
            StateManager.States["WorldLoaderState"]    = new WorldLoaderState(this, StateManager);
            StateManager.States["GameLoaderState"]     = new GameLoaderState(this, StateManager);
            StateManager.States["LoseState"]           = new LoseState(this, StateManager, playState);

            if (GameSettings.Default.DisplayIntro)
            {
                StateManager.PushState("IntroState");
            }
            else
            {
                StateManager.PushState("MainMenuState");
            }

            StateManager.States["IntroState"].OnEnter();
            StateManager.States["MainMenuState"].OnEnter();
            StateManager.States["OptionsState"].OnEnter();
            StateManager.States["CompanyMakerState"].OnEnter();


            //TestBehaviors.RunTests();

            base.LoadContent();
        }
示例#4
0
        public static void CreateOceanLand(GraphicsDevice graphicsDevice, float seaLevel)
        {
            int size = 512;

            Map = new MapData[size, size];

            for (int x = 0; x < size; x++)
            {
                for (int y = 0; y < size; y++)
                {
                    Map[x, y].Biome       = BiomeLibrary.GetBiome("Grassland").Biome;
                    Map[x, y].Erosion     = 1.0f;
                    Map[x, y].Weathering  = 0;
                    Map[x, y].Faults      = 1.0f;
                    Map[x, y].Temperature = size;
                    Map[x, y].Rainfall    = size;
                    Map[x, y].Height      = 0.05f; //ComputeHeight(x, y, size0, size0, 5.0f, false);
                }
            }

            Overworld.Name = "ocean_" + MathFunctions.Random.Next(9999);
        }
示例#5
0
        protected override void LoadContent()
        {
            PlayState playState = new PlayState(this, StateManager);

            BiomeLibrary.InitializeStatics();
            StateManager.States["IntroState"]          = new IntroState(this, StateManager);
            StateManager.States["PlayState"]           = playState;
            StateManager.States["MainMenuState"]       = new MainMenuState(this, StateManager);
            StateManager.States["WorldSetupState"]     = new WorldSetupState(this, StateManager);
            StateManager.States["WorldGeneratorState"] = new WorldGeneratorState(this, StateManager);
            StateManager.States["OptionsState"]        = new OptionsState(this, StateManager);
            StateManager.States["EconomyState"]        = new EconomyState(this, StateManager, playState);
            StateManager.States["CompanyMakerState"]   = new CompanyMakerState(this, StateManager);
            StateManager.States["WorldLoaderState"]    = new WorldLoaderState(this, StateManager);
            StateManager.States["GameLoaderState"]     = new GameLoaderState(this, StateManager);
            StateManager.States["LoseState"]           = new LoseState(this, StateManager, playState);

            if (GameSettings.Default.DisplayIntro)
            {
                StateManager.PushState("IntroState");
            }
            else
            {
                StateManager.PushState("MainMenuState");
            }

            StateManager.States["IntroState"].OnEnter();
            StateManager.States["MainMenuState"].OnEnter();
            StateManager.States["OptionsState"].OnEnter();
            StateManager.States["CompanyMakerState"].OnEnter();


            //TestBehaviors.RunTests();

            base.LoadContent();
        }
示例#6
0
        protected override void LoadContent()
        {
#if SHARP_RAVEN && !DEBUG
            try
            {
#endif
            AssetManager.Initialize(Content, GraphicsDevice, GameSettings.Default);

            //var palette = TextureTool.ExtractPaletteFromDirectoryRecursive("Entities/Dwarf");
            //var paletteTexture = TextureTool.Texture2DFromMemoryTexture(GraphicsDevice, TextureTool.MemoryTextureFromPalette(palette));
            //paletteTexture.SaveAsPng(System.IO.File.OpenWrite("palette.png"), paletteTexture.Width, paletteTexture.Height);

            // Prepare GemGui
            if (GumInputMapper == null)
            {
                GumInputMapper = new Gui.Input.GumInputMapper(Window.Handle);
                GumInput       = new Gui.Input.Input(GumInputMapper);
            }
            // Register all bindable actions with the input system.
            //GumInput.AddAction("TEST", Gui.Input.KeyBindingType.Pressed);

            GuiSkin = new RenderData(GraphicsDevice, Content);

            // Create console.
            ConsoleGui = new Gui.Root(GuiSkin);
            ConsoleGui.RootItem.AddChild(new Gui.Widgets.AutoGridPanel
            {
                Rows       = 2,
                Columns    = 4,
                AutoLayout = AutoLayout.DockFill
            });

            ConsoleGui.RootItem.Layout();
            if (_logwriter != null)
            {
                _logwriter.SetConsole(GetConsoleTile("LOG"));
            }

            Console.Out.WriteLine("Console created.");

            if (SoundManager.Content == null)
            {
                SoundManager.Content = Content;
                SoundManager.LoadDefaultSounds();
#if XNA_BUILD
                //SoundManager.SetActiveSongs(ContentPaths.Music.dwarfcorp, ContentPaths.Music.dwarfcorp_2,
                //    ContentPaths.Music.dwarfcorp_3, ContentPaths.Music.dwarfcorp_4, ContentPaths.Music.dwarfcorp_5);
#endif
            }

            if (StateManager.StateStack.Count == 0)
            {
                if (GameSettings.Default.DisplayIntro)
                {
                    StateManager.PushState(new IntroState(this, StateManager));
                }
                else
                {
                    StateManager.PushState(new MainMenuState(this, StateManager));
                }
            }
            BiomeLibrary.InitializeStatics();
            EmbarkmentLibrary.InitializeDefaultLibrary();
            VoxelChunk.InitializeStatics();
            ControlSettings.Load();
            Drawer2D.Initialize(Content, GraphicsDevice);
            ResourceLibrary.Initialize();
            base.LoadContent();
#if SHARP_RAVEN && !DEBUG
        }

        catch (Exception exception)
        {
            if (ravenClient != null)
            {
                ravenClient.Capture(new SentryEvent(exception));
            }
            throw;
        }
#endif
        }
示例#7
0
        public void GenerateCaves(VoxelChunk chunk, WorldManager world)
        {
            if (CaveLevels == null)
            {
                CaveLevels = new List <int>();
                var caveStep = 48 / world.GenerationSettings.NumCaveLayers;

                for (var i = 0; i < world.GenerationSettings.NumCaveLayers; ++i)
                {
                    CaveLevels.Add(4 + (caveStep * i));
                }
            }

            Vector3   origin    = chunk.Origin;
            BiomeData biome     = BiomeLibrary.GetBiome("Cave");
            var       hellBiome = BiomeLibrary.GetBiome("Hell");

            for (int x = 0; x < VoxelConstants.ChunkSizeX; x++)
            {
                for (int z = 0; z < VoxelConstants.ChunkSizeZ; z++)
                {
                    var topVoxel = VoxelHelpers.FindFirstVoxelBelow(new VoxelHandle(
                                                                        chunk, new LocalVoxelCoordinate(x, VoxelConstants.ChunkSizeY - 1, z)));

                    for (int i = 0; i < CaveLevels.Count; i++)
                    {
                        int y = CaveLevels[i];
                        if (y <= 0 || y >= topVoxel.Coordinate.Y)
                        {
                            continue;
                        }

                        var frequency = i < CaveFrequencies.Count ? CaveFrequencies[i] : CaveFrequencies[CaveFrequencies.Count - 1];
                        var caveBiome = (y <= HellLevel) ? hellBiome : biome;

                        Vector3 vec       = new Vector3(x, y, z) + chunk.Origin;
                        double  caveNoise = CaveNoise.GetValue((x + origin.X) * CaveNoiseScale * frequency,
                                                               (y + origin.Y) * CaveNoiseScale * 3.0f, (z + origin.Z) * CaveNoiseScale * frequency);

                        double heightnoise = NoiseGenerator.Noise((x + origin.X) * NoiseScale * frequency,
                                                                  (y + origin.Y) * NoiseScale * 3.0f, (z + origin.Z) * NoiseScale * frequency);

                        int caveHeight = Math.Min(Math.Max((int)(heightnoise * 5), 1), 3);

                        if (!(caveNoise > CaveSize))
                        {
                            continue;
                        }

                        bool invalidCave = false;
                        for (int dy = 0; dy < caveHeight; dy++)
                        {
                            if (y - dy <= 0)
                            {
                                continue;
                            }

                            var voxel = new VoxelHandle(chunk, new LocalVoxelCoordinate(x, y - dy, z));

                            foreach (var coord in VoxelHelpers.EnumerateAllNeighbors(voxel.Coordinate))
                            {
                                VoxelHandle v = new VoxelHandle(Manager.ChunkData, coord);
                                if (!v.IsValid || (v.Sunlight))
                                {
                                    invalidCave = true;
                                    break;
                                }
                            }

                            if (!invalidCave)
                            {
                                voxel.RawSetType(VoxelLibrary.emptyType);
                            }
                            else
                            {
                                break;
                            }
                        }

                        if (!invalidCave && caveNoise > CaveSize * 1.8f && y - caveHeight > 0 && y > LavaLevel)
                        {
                            GenerateCaveVegetation(chunk, x, y, z, caveHeight, caveBiome, vec, world, NoiseGenerator);
                        }
                    }
                }
            }

            /*
             * // Second pass sets the caves to empty as needed
             * for (int x = 0; x < VoxelConstants.ChunkSizeX; x++)
             * {
             *  for (int y = 0; y < VoxelConstants.ChunkSizeY; y++)
             *  {
             *      for (int z = 0; z < VoxelConstants.ChunkSizeZ; z++)
             *      {
             *          VoxelHandle handle = new VoxelHandle(chunk, new LocalVoxelCoordinate(x, y, z));
             *          if (handle.Type == magicCube)
             *          {
             *              handle.RawSetType(VoxelLibrary.emptyType);
             *          }
             *      }
             *  }
             * }
             */
        }
示例#8
0
        protected override void LoadContent()
        {
            // Prepare GemGui
            GumInputMapper = new Gum.Input.GumInputMapper(Window.Handle);
            GumInput       = new Gum.Input.Input(GumInputMapper);

            // Register all bindable actions with the input system.
            GumInput.AddAction("TEST", Gum.Input.KeyBindingType.Pressed);

            GumSkin = new RenderData(GraphicsDevice, Content,
                                     "newgui/xna_draw", "Content/newgui/sheets.txt");

            if (SoundManager.Content == null)
            {
                SoundManager.Content = Content;
                SoundManager.LoadDefaultSounds();
#if XNA_BUILD
                SoundManager.SetActiveSongs(ContentPaths.Music.dwarfcorp, ContentPaths.Music.dwarfcorp_2,
                                            ContentPaths.Music.dwarfcorp_3, ContentPaths.Music.dwarfcorp_4, ContentPaths.Music.dwarfcorp_5);
#endif
            }

            // The thing keeping this from working is that some states are tied tightly to the play state.
            // Ideally the solution is to stop caching these at all, so there's no point in trying to make
            // an implementation work just to throw it out.

            /*
             * foreach (var type in System.Reflection.Assembly.GetExecutingAssembly().GetTypes())
             * {
             *  if (type.IsSubclassOf(typeof(GameState)))
             *  {
             *      var instance = Activator.CreateInstance(type, this, StateManager);
             *      StateManager.States.Add(type.Name, instance as GameState);
             *  }
             * }
             */

            /*
             * PlayState playState = new PlayState(this, StateManager);
             * StateManager.States["IntroState"] = new IntroState(this, StateManager);
             * StateManager.States["PlayState"] = playState;
             * StateManager.States["MainMenuState"] = new MainMenuState(this, StateManager);
             * StateManager.States["NewGameChooseWorldState"] = new NewGameChooseWorldState(this, StateManager);
             * StateManager.States["NewGameCreateDebugWorldState"] = new NewGameCreateDebugWorldState(this, StateManager);
             * StateManager.States["WorldSetupState"] = new WorldSetupState(this, StateManager);
             * StateManager.States["WorldGeneratorState"] = new WorldGeneratorState(this, StateManager);
             * StateManager.States["OptionsState"] = new OptionsState(this, StateManager);
             * StateManager.States["NewOptionsState"] = new NewOptionsState(this, StateManager);
             * StateManager.States["EconomyState"] = new EconomyState(this, StateManager);
             * StateManager.States["CompanyMakerState"] = new CompanyMakerState(this, StateManager);
             * StateManager.States["WorldLoaderState"] = new WorldLoaderState(this, StateManager);
             * StateManager.States["GameLoaderState"] = new GameLoaderState(this, StateManager);
             * StateManager.States["LoseState"] = new LoseState(this, StateManager, playState);
             * StateManager.States["LoadState"] = new LoadState(this, StateManager);
             */

            if (GameSettings.Default.DisplayIntro)
            {
                StateManager.PushState(new IntroState(this, StateManager));
            }
            else
            {
                StateManager.PushState(new MainMenuState(this, StateManager));
            }

            BiomeLibrary.InitializeStatics();
            Embarkment.Initialize();
            VoxelChunk.InitializeStatics();
            ControlSettings.Load();
            Drawer2D.Initialize(Content, GraphicsDevice);
            ResourceLibrary.Initialize();

            base.LoadContent();
        }
示例#9
0
        public void GenerateCaves(VoxelChunk chunk, WorldManager world)
        {
            Vector3   origin = chunk.Origin;
            BiomeData biome  = BiomeLibrary.GetBiome("Cave");

            for (int x = 0; x < VoxelConstants.ChunkSizeX; x++)
            {
                for (int z = 0; z < VoxelConstants.ChunkSizeZ; z++)
                {
                    var topVoxel = VoxelHelpers.FindFirstVoxelBelow(new VoxelHandle(
                                                                        chunk, new LocalVoxelCoordinate(x, VoxelConstants.ChunkSizeY - 1, z)));

                    for (int i = 0; i < CaveLevels.Count; i++)
                    {
                        int y = CaveLevels[i];
                        if (y <= 0 || y >= topVoxel.Coordinate.Y)
                        {
                            continue;
                        }
                        Vector3 vec       = new Vector3(x, y, z) + chunk.Origin;
                        double  caveNoise = CaveNoise.GetValue((x + origin.X) * CaveNoiseScale * CaveFrequencies[i],
                                                               (y + origin.Y) * CaveNoiseScale * 3.0f, (z + origin.Z) * CaveNoiseScale * CaveFrequencies[i]);

                        double heightnoise = NoiseGenerator.Noise((x + origin.X) * NoiseScale * CaveFrequencies[i],
                                                                  (y + origin.Y) * NoiseScale * 3.0f, (z + origin.Z) * NoiseScale * CaveFrequencies[i]);

                        int caveHeight = Math.Min(Math.Max((int)(heightnoise * 5), 1), 3);

                        if (!(caveNoise > CaveSize))
                        {
                            continue;
                        }

                        bool invalidCave = false;
                        for (int dy = 0; dy < caveHeight; dy++)
                        {
                            if (y - dy <= 0)
                            {
                                continue;
                            }

                            var voxel = new VoxelHandle(chunk, new LocalVoxelCoordinate(x, y - dy, z));

                            foreach (var coord in VoxelHelpers.EnumerateAllNeighbors(voxel.Coordinate))
                            {
                                VoxelHandle v = new VoxelHandle(Manager.ChunkData, coord);
                                if (v.IsValid && (v.LiquidLevel > 0 || v.Sunlight))
                                {
                                    invalidCave = true;
                                    break;
                                }
                            }

                            if (!invalidCave)
                            {
                                voxel.RawSetType(VoxelLibrary.emptyType);
                            }
                            else
                            {
                                break;
                            }
                        }

                        if (!invalidCave && caveNoise > CaveSize * 1.8f && y - caveHeight > 0)
                        {
                            GenerateCaveVegetation(chunk, x, y, z, caveHeight, biome, vec, world, NoiseGenerator);
                            GenerateCaveFauna(chunk, world, biome, y - caveHeight, x, z);
                        }
                    }
                }
            }

            /*
             * // Second pass sets the caves to empty as needed
             * for (int x = 0; x < VoxelConstants.ChunkSizeX; x++)
             * {
             *  for (int y = 0; y < VoxelConstants.ChunkSizeY; y++)
             *  {
             *      for (int z = 0; z < VoxelConstants.ChunkSizeZ; z++)
             *      {
             *          VoxelHandle handle = new VoxelHandle(chunk, new LocalVoxelCoordinate(x, y, z));
             *          if (handle.Type == magicCube)
             *          {
             *              handle.RawSetType(VoxelLibrary.emptyType);
             *          }
             *      }
             *  }
             * }
             */
        }