Example #1
0
        private static MapSettings GetMapSettings(Map map,
                                                  IEnumerable <Wall> walls,
                                                  IEnumerable <Bonus> bonuses,
                                                  IEnumerable <Trap> traps,
                                                  IEnumerable <StartPoint> startPoints,
                                                  IEnumerable <MapBot> mapBots)
        {
            var mapSettings = new MapSettings(
                map.Id,
                map.Width,
                map.Height,
                map.InitialPower,
                map.StrengthWeight,
                map.StaminaWeight,
                map.RangedWeight,
                map.MaxStepCount ?? int.MaxValue,
                map.BonusSpawnInterval,
                map.BulletSpeed,
                map.ActionTimeout,
                map.MemoryLimit,
                walls.Select(w => new BotWorld.Wall(w.Id, w.X, w.Y)).ToList(),
                bonuses.Select(b => new BotWorld.Bonus(b.Id, b.X, b.Y, b.Power)).ToList(),
                traps.Select(t => new BotWorld.Trap(t.Id, t.X, t.Y, t.Damage)).ToList(),
                startPoints.Select(p => new Core.StartPoint(p.X, p.Y, mapBots.FirstOrDefault(mb => mb.StartPointId == p.Id)?.BotId)).ToList());

            return(mapSettings);
        }
Example #2
0
        private Dictionary <int, string> GetImagesForViewModel(Map map, Dictionary <int, int> wallImages, Dictionary <int, int> bonusImages,
                                                               Dictionary <int, int> trapImages, IEnumerable <int> botImageIds)
        {
            var imageIds = new List <int> {
                map.BackgroundImageId
            };

            imageIds.AddRange(wallImages.Values);
            imageIds.AddRange(bonusImages.Values);
            imageIds.AddRange(trapImages.Values);
            imageIds.AddRange(botImageIds);
            var images = ImageDataService.Get(imageIds.Distinct().ToList()).ToDictionary(i => i.Id, i => i.FileName);

            return(images);
        }