Example #1
0
        internal void Restore(LevelDto dto)
        {
            Name = dto.Name;
            Id   = dto.Id;
            ChangeSize(dto.Width, dto.Height);
            _lastId = 0;

            AvailableConstructionTypes.Clear();

            foreach (var id in dto.AvailableConstructionTypes)
            {
                AvailableConstructionTypes[id] = _types.GetConstructionType(id);
            }

            Constructions.Clear();

            foreach (var constructionDto in dto.Constructions)
            {
                var id     = constructionDto.Id;
                var type   = _types.GetConstructionType(constructionDto.TypeId);
                var center = constructionDto.Center;

                var construction = Build(type, center, id);
                foreach (var bunchDto in constructionDto.Items)
                {
                    construction.AddItemBunch(new ItemBunch(bunchDto, _types));
                }

                if (_lastId < id)
                {
                    _lastId = id;
                }
            }
        }
 internal Construction(ConstructionDto dto, TypeRepository types)
 {
     Id     = dto.Id;
     Type   = types.GetConstructionType(dto.TypeId);
     Center = dto.Center;
     foreach (var itemBunchDto in dto.Items)
     {
         AddItemBunch(new ItemBunch(itemBunchDto, types));
     }
 }
Example #3
0
 public void BuildConstruction(int typeId, Position2 center)
 {
     _level.Build(_typeRepository.GetConstructionType(typeId), center);
 }