Beispiel #1
0
        /// <summary>
        /// Loads the entities in memory.
        /// </summary>
        public void LoadContent()
        {
            string itemPath         = Path.Combine(ApplicationPaths.EntitiesDirectory, "items.xml");
            string mobPath          = Path.Combine(ApplicationPaths.EntitiesDirectory, "mobs.xml");
            string prayerPath       = Path.Combine(ApplicationPaths.EntitiesDirectory, "prayers.xml");
            string spellPath        = Path.Combine(ApplicationPaths.EntitiesDirectory, "spells.xml");
            string terrainsPath     = Path.Combine(ApplicationPaths.EntitiesDirectory, "terrains.xml");
            string worldObjectsPath = Path.Combine(ApplicationPaths.EntitiesDirectory, "worldObjects.xml");

            ItemRepository        itemRepository        = new ItemRepository(itemPath);
            MobRepository         mobRepository         = new MobRepository(mobPath);
            TerrainRepository     terrainRepository     = new TerrainRepository(terrainsPath);
            WorldObjectRepository worldObjectRepository = new WorldObjectRepository(worldObjectsPath);

            items              = itemRepository.GetAll().ToDomainModels().ToList();
            mobDefinitions     = mobRepository.GetAll().ToDomainModels().ToList();
            terrainDefinitions = terrainRepository.GetAll().ToDomainModels().ToList();
            objectDefinitions  = worldObjectRepository.GetAll().ToDomainModels().ToList();

            mobs = new Dictionary <string, Mob>();

            Mob player = new Mob();

            player.Id    = playerId;
            player.MobId = "player";

            mobs.Add(player.Id, player);

            mobs.Add("mobtest", new Mob
            {
                Id       = "mobtest",
                MobId    = "player",
                Location = new PointF2D(4, 6)
            });
        }
Beispiel #2
0
    private void SetNeighboringChunks()
    {
        var neighbors = TerrainRepository.GetChunksWithinDistance(_unnormalizedCenter);

        if (neighbors.Left != null)
        {
            _terrainChunkGameObject.Left = neighbors.Left._terrainChunkGameObject;
            neighbors.Left._terrainChunkGameObject.Right = _terrainChunkGameObject;
        }

        if (neighbors.Right != null)
        {
            _terrainChunkGameObject.Right = neighbors.Right._terrainChunkGameObject;
            neighbors.Right._terrainChunkGameObject.Left = _terrainChunkGameObject;
        }

        if (neighbors.Above != null)
        {
            _terrainChunkGameObject.Above = neighbors.Above._terrainChunkGameObject;
            neighbors.Above._terrainChunkGameObject.Below = _terrainChunkGameObject;
        }

        if (neighbors.Below != null)
        {
            _terrainChunkGameObject.Below = neighbors.Below._terrainChunkGameObject;
            neighbors.Below._terrainChunkGameObject.Above = _terrainChunkGameObject;
        }
    }
Beispiel #3
0
        public static Biome GenerateRelativeBiome(Vector2 origin)
        {
            var nearbyChunks = TerrainRepository.GetChunksWithinDistance(origin).Flatten().ToList();

            if (!nearbyChunks.Any())
            {
                return(new Biome());
            }

            var biomes          = nearbyChunks.Select(c => c.Biome);
            var biomeDictionary = new Dictionary <Biome, int>();

            foreach (var biome in biomes)
            {
                if (!biomeDictionary.ContainsKey(biome))
                {
                    biomeDictionary.Add(biome, 0);
                }
                biomeDictionary[biome]++;
            }

            var numOfBiomes    = biomeDictionary.Keys.Count;
            var weightedBiomes = new List <KeyValuePair <float, Biome> >();

            foreach (var pair in biomeDictionary)
            {
                weightedBiomes.Add(new KeyValuePair <float, Biome>((float)pair.Value / numOfBiomes, pair.Key));
            }

            var max = weightedBiomes.Max(c => c.Key);
            var randomNumberBetweenZeroAndMax = Random.Range(0.0f, max);


            return(weightedBiomes.First(c => c.Key >= randomNumberBetweenZeroAndMax).Value);
        }
 public PlanetController()
 {
     context            = new ApplicationDbContext();
     planetRepository   = new PlanetRepository(context);
     climateRepository  = new ClimateRepository(context);
     terrainRepository  = new TerrainRepository(context);
     filePathRepository = new FilePathRepository(context);
     unitOfWork         = new UnitOfWork(context);
 }
Beispiel #5
0
    private static float[,] NormalizeHeightsToNeighboringMeshes(float[,] heightMap, Vector2 coord)
    {
        var nearbyChunks = TerrainRepository.GetChunksWithinDistance(coord);

        //heightMap = heightMap.NormalizeLeftSide(GetHeightMapOrEmptyMap(nearbyChunks.Left).RightEdge);
        //heightMap = heightMap.NormalizeRightSide(GetHeightMapOrEmptyMap(nearbyChunks.Right).LeftEdge);
        heightMap = heightMap.NormalizeBottomSide(GetHeightMapOrEmptyMap(nearbyChunks.Below).TopEdge);
        //heightMap = heightMap.NormalizeTopSide(GetHeightMapOrEmptyMap(nearbyChunks.Above).BottomEdge);
        return(heightMap);
    }
        /// <summary>
        /// Loads the content.
        /// </summary>
        public void LoadContent()
        {
            string terrainPath     = Path.Combine(ApplicationPaths.EntitiesDirectory, "terrains.xml");
            string worldObjectPath = Path.Combine(ApplicationPaths.EntitiesDirectory, "world_objects.xml");

            TerrainRepository     terrainRepository     = new TerrainRepository(terrainPath);
            WorldObjectRepository worldObjectRepository = new WorldObjectRepository(worldObjectPath);

            terrains     = terrainRepository.GetAll().ToDomainModels().ToList();
            worldObjects = worldObjectRepository.GetAll().ToDomainModels().ToList();
        }
 public DatabaseStatisticController()
 {
     context = new ApplicationDbContext();
     ApplicationUserRepository    = new ApplicationUserRepository(context);
     climateRepository            = new ClimateRepository(context);
     terrainRepository            = new TerrainRepository(context);
     ticketRepository             = new TicketRepository(context);
     flightRepository             = new FlightRepository(context);
     orderRepository              = new OrderRepository(context);
     raceRepository               = new RaceRepository(context);
     raceClassificationRepository = new RaceClassificationRepository(context);
     starshipRepository           = new StarshipRepository(context);
     flightPathRepository         = new FlightPathRepository(context);
     planetRepository             = new PlanetRepository(context);
 }
Beispiel #8
0
 private void CreateOrigin()
 {
     for (int x = 0; x < 5; x++)
     {
         for (int y = 0; y < 5; y++)
         {
             var newChunk = new TerrainChunk(new Vector2(x, y), heightMapSettings, meshSettings, colliderLODIndex, transform, viewer, mapMaterial);
             TerrainRepository.AddChunk(newChunk);
             newChunk.OnVisibilityChanged += OnTerrainChunkVisibilityChanged;
             newChunk.Load();
             foreach (var terrainChunk in TerrainRepository.TerrainChunkDictionary.Values)
             {
                 terrainChunk.SetVisible(true);
             }
         }
     }
 }
 public TerrainController()
 {
     context           = new ApplicationDbContext();
     terrainRepository = new TerrainRepository(context);
     unitOfWork        = new UnitOfWork(context);
 }