public void CreateMapFromImage(World world) { Bitmap mapImage = (Bitmap)Bitmap.FromFile(mapFile); world.Tiles = new ITerrain[WORLD_WIDTH, WORLD_HEIGHT]; for (int x = 0; x < WORLD_WIDTH; x++) { for (int y = 0; y < WORLD_HEIGHT; y++) { Vector2 worldIndex = new Vector2(x, y); if (mapImage.GetPixel(x, y).Name == "ff6a4e2f") { world.Tiles[x, y] = TerrainFactory.CreateCaveFloor(worldIndex, world); } else if (mapImage.GetPixel(x, y).Name == "ff8c8c8c") { world.Tiles[x, y] = TerrainFactory.CreateCaveWall(worldIndex, world); } else if (mapImage.GetPixel(x, y).Name == "ff000000") { world.Tiles[x, y] = TerrainFactory.CreateNothing(worldIndex, world); } else if (mapImage.GetPixel(x, y).Name == "ff0000ff") { world.Tiles[x, y] = TerrainFactory.CreateWater(worldIndex, world); } else { Console.WriteLine("ERROR: Unknown terrain type"); } } } }
private void InitializeTerrain(TerrainType type) { terrain = TerrainFactory.GetTerrain(type, this); terrain.LoadHeightmap(Settings.Default.Heightmap); terrain.LoadTexture(Settings.Default.Texture); terrain.Bumpiness = Settings.Default.Bumpiness; terrain.FrustumCullingEnabled = Settings.Default.FrustumCullingEnabled; terrain.BruteForceEnabled = Settings.Default.BruteForceEnabled; terrain.TextureEnabled = Settings.Default.TextureEnabled; terrain.TextureResolution = Settings.Default.TextureResolution; terrain.HeightmapEnabled = Settings.Default.HeightmapEnabled; terrain.GeomorphEnabled = Settings.Default.GeomorphEnabled; terrain.LightEnabled = Settings.Default.LightEnabled; terrain.LightDiffuse = Settings.Default.LightDiffuse; terrain.LightDirection = Settings.Default.LightDirection; terrain.LightAmbient = Settings.Default.LightAmbient; terrain.LightSpecular = Settings.Default.LightSpecular; terrain.LightShininess = Settings.Default.LightShininess; terrain.Quality = Settings.Default.Quality; terrain.TerrainColor = Settings.Default.TerrainColor; terrain.BlockSize = Settings.Default.BlockSize; terrain.MinQuality = Settings.Default.MinQuality; terrain.Initialize(); }
private void ChangeTerrain(TerrainType type) { ITerrain previousTerrain = terrain; terrain = TerrainFactory.GetTerrain(type, this); terrain.Heightmap = previousTerrain.Heightmap; terrain.Texture = previousTerrain.Texture; terrain.Bumpiness = previousTerrain.Bumpiness; terrain.FrustumCullingEnabled = previousTerrain.FrustumCullingEnabled; terrain.BruteForceEnabled = previousTerrain.BruteForceEnabled; terrain.TextureEnabled = previousTerrain.TextureEnabled; terrain.TextureResolution = previousTerrain.TextureResolution; terrain.HeightmapEnabled = previousTerrain.HeightmapEnabled; terrain.GeomorphEnabled = previousTerrain.GeomorphEnabled; terrain.LightEnabled = previousTerrain.LightEnabled; terrain.LightDiffuse = previousTerrain.LightDiffuse; terrain.LightDirection = previousTerrain.LightDirection; terrain.LightAmbient = previousTerrain.LightAmbient; terrain.LightSpecular = previousTerrain.LightSpecular; terrain.LightShininess = previousTerrain.LightShininess; terrain.Quality = previousTerrain.Quality; terrain.TerrainColor = previousTerrain.TerrainColor; terrain.BlockSize = previousTerrain.BlockSize; terrain.MinQuality = previousTerrain.MinQuality; terrain.Initialize(); }
public static void create() { MessageBroker.Default.Receive <TerrainCreated>().Subscribe(x => { //MessageBroker.Default.Publish<sceneUnload>(new sceneUnload { scene_name = SceneName.worldCreating }); PlayerFactory.create(); }); TerrainFactory.create(); }
public void LoadTerrain() { // Load the terrain if (!IsInterior) { TerrainFactory.Create(coordinates); } }
public A3Data() { _camera = new Camera(_windowRect); _terrainFactory = new TerrainFactoryMidpoint(_windowRect, _terrainBox, _camera); _entities = new List <Entity>(); _commandStream = new CommandStream(); }
private void Place(OffsetCoordinates position, TerrainFactory terrainFactory) { var field = new Field( world: this, position: position ); field.Create(terrainFactory); this[position] = field; }
public override void _Ready() { var terrain = new ArrayMap <bool>(40, 40); MapHelper.TileMap = this; MapHelper.FogMap = GetParent().GetNode <TileMap>("FogMap"); QuickGenerators.GenerateCellularAutomataMap(terrain); var map = new GoRogue.GameFramework.Map( width: terrain.Width, height: terrain.Height, numberOfEntityLayers: 1, distanceMeasurement: Distance.CHEBYSHEV ); foreach (var pos in terrain.Positions()) { MapHelper.FogMap.SetCell(pos.X, pos.Y, 0); if (terrain[pos]) { SetCell(pos.X, pos.Y, 0); map.SetTerrain(TerrainFactory.Floor(pos)); MapHelper.EmptyTiles.Add(new Vector2(pos.X, pos.Y)); } else // Wall { map.SetTerrain(TerrainFactory.Wall(pos)); SetCell(pos.X, pos.Y, 1); } } var playerScene = GD.Load <PackedScene>("res://entities/Player.tscn"); var player = playerScene.Instance() as Player; map.AddEntity(player); MapHelper.TileMap.AddChild(player); var enemyScene = GD.Load <PackedScene>("res://entities/Enemy.tscn"); foreach (var e in Enumerable.Range(0, 10)) { var enemy = enemyScene.Instance() as Enemy; map.AddEntity(enemy); MapHelper.TileMap.AddChild(enemy); } MapHelper.CurrentMap = map; GD.Print("Number of entities: " + MapHelper.CurrentMap.Entities.Count); GD.Print("Number of children: " + GetChildCount()); }
void OnEnable() { _factory = target as TerrainFactory; state_Prop = serializedObject.FindProperty("_generationType"); mapIdType_Prop = serializedObject.FindProperty("_mapIdType"); sampleCount_Prop = serializedObject.FindProperty("_sampleCount"); heightMod_Prop = serializedObject.FindProperty("_heightModifier"); mapId_Prop = serializedObject.FindProperty("_mapId"); material_Prop = serializedObject.FindProperty("_baseMaterial"); customMapId_Prop = serializedObject.FindProperty("_customMapId"); script = MonoScript.FromScriptableObject((TerrainFactory)target); }
void OnEnable() { _factory = target as TerrainFactory; mapIdType_Prop = serializedObject.FindProperty("_mapIdType"); sampleCount_Prop = serializedObject.FindProperty("_sampleCount"); heightMod_Prop = serializedObject.FindProperty("_heightModifier"); mapId_Prop = serializedObject.FindProperty("_mapId"); customMapId_Prop = serializedObject.FindProperty("_customMapId"); material_Prop = serializedObject.FindProperty("_baseMaterial"); collider_Prop = serializedObject.FindProperty("_addCollider"); addLayer_Prop = serializedObject.FindProperty("_addToLayer"); layerId_Prop = serializedObject.FindProperty("_layerId"); script = MonoScript.FromScriptableObject((TerrainFactory)target); }
public void CreateBigRoom(World world) { world.Tiles = new ITerrain[World.WORLD_WIDTH, World.WORLD_HEIGHT]; for (int x = 0; x < World.WORLD_WIDTH; x++) { for (int y = 0; y < World.WORLD_HEIGHT; y++) { Vector2 worldIndex = new Vector2(x, y); world.Tiles[x, y] = TerrainFactory.CreateCaveFloor(worldIndex, world); } } }
public override void _Ready() { world = (Spatial)GetNode("/root/MainScene/World"); player = (Player)GetNode("/root/MainScene/World/Player"); terrainFactory = (TerrainFactory)GetNode("/root/MainScene/Main/TerrainFactory"); questFactory = (QuestFactory)GetNode("/root/MainScene/Main/QuestFactory"); noiseTexture = (TextureRect)GetNode("/root/MainScene/Main/NoiseTexture"); noise = ((NoiseTexture)noiseTexture.Texture).Noise; ((LineEdit)GetNode("/root/MainScene/UI/SettingsPanel/SeedLine")).Text = noise.Seed.ToString(); steepness = 50; chunkBorderAreaHeight = 30; chunkCollisionAreaHeight = 500; forestChance = 50; }
public override void Enter(params object[] args) { _screen = new RenderTarget2D(StateMachine.Game.GraphicsDevice, VirtualScreenSize.Width * VirtualScreenSize.ScreenSizeMultiplier, VirtualScreenSize.Height * VirtualScreenSize.ScreenSizeMultiplier); _spriteBatch = new SpriteBatch(StateMachine.Game.GraphicsDevice); bool resetForNewGame = true; if (args.Length > 0 && args[0] is bool) { resetForNewGame = (bool)args[0]; } // Generate map TerrainFactory.GenerateGrid(); TerrainFactory.GenerateResourceGrid(); // Generate available buildings var buildings = BuildingFactory.GenerateAvailableBuildings(); // Create models _playerModel = new PlayerModel(); _playerResourcesModel = new PlayerResourcesModel(); _terrainTileListModel = new TerrainTileListModel(TerrainFactory.Tiles, TerrainFactory.Resources); _buildingListModel = new BuildingListModel(buildings); // Create and add controllers var playerController = new PlayerController(_playerModel, _terrainTileListModel); var backgroundController = new BackgroundController(_playerModel, _terrainTileListModel, _playerResourcesModel); var buildController = new BuildController(_buildingListModel, _playerModel, _playerResourcesModel); _controllers.Add(playerController); _controllers.Add(backgroundController); _controllers.Add(buildController); // Create and add views _views.Add(new BackgroundView(StateMachine.Game.Content, _spriteBatch, _terrainTileListModel, _playerModel)); _views.Add(new PlayerResourcesView(StateMachine.Game.Content, _spriteBatch, _playerResourcesModel, _playerModel)); _views.Add(new PlayerView(StateMachine.Game.Content, _spriteBatch, _playerModel)); _views.Add(new BuildView(StateMachine.Game.Content, _spriteBatch, _buildingListModel, _playerModel, _playerResourcesModel)); }
// as DEM couldn't be transfered via pipes or MMF and was cousing troubles in async, another process was created internal void ProcessDEMExternally() { var psi = new ProcessStartInfo(); psi.FileName = $"{modDirectory}ASCIIParserPL.exe"; psi.CreateNoWindow = true; psi.RedirectStandardOutput = true; psi.RedirectStandardInput = true; psi.RedirectStandardError = true; psi.UseShellExecute = false; psi.Arguments = "\"" + Arguments[0] + "\"" + " " + "\"" + Arguments[1] + "\"" + " " + "\"" + Arguments[4] + "\""; var p = new Process(); p.StartInfo = psi; p.Start(); TerrainFactory terrainFactory = new TerrainFactory(); WaterFactory waterFactory = new WaterFactory(); waterFactory.SetSeaLevelTo0(); while (!p.StandardOutput.EndOfStream) { string line = p.StandardOutput.ReadLine(); List <string> arguments = line.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries).ToList(); if (arguments[0] == "Terrain") { byte[] map = System.Convert.FromBase64String(arguments[1]); terrainFactory.SetTerrain(map); UnityEngine.Debug.Log("DEM imported"); } if (arguments[0] == "Error") { UnityEngine.Debug.Log(arguments[1]); } } }
public Entity FromBsp(BspTag bsp) { return(TerrainFactory.FromBspData(this.Map, bsp)); }
public void Create(TerrainFactory factory) { Terrain = factory.Invoke( location: this ); }
public TerrainManager(ContentManager ContentManager) { this.ContentManager = ContentManager; TerrainFactory = new TerrainFactory(); TerrainContainer = new TerrainContainer(); }
//[SerializeField] //private Color32[] colors; private void Start() { TerrainFactory.Create(coordinates); //colors = LandRecord.LandRecords[coordinate].NormalData.GetNormals().ToArray(); }
public StageInitializer() { _playerFactory = new PlayerFactory(); _terrainFactory = new TerrainFactory(); }
public MapContainer() { _terrainFactory = new TerrainFactory(); }
void Start() { Instance = this; }