public void Undo() { UndoPlace(); foreach (var removedObject in _removedObjects) { Layout.PlaceObject(removedObject.Type, removedObject.Position); } _removedObjects.Clear(); }
public void Undo() { foreach (var removedConnection in _removedConnections) { _layout.AddNodeConnections(removedConnection); } foreach (var removedObject in _removedObjects) { _layout.PlaceObject(removedObject.Type, removedObject.Position); } }
public void LoadFromFlatLayout(FlatLayout savedLayout, PuzzleLayout gameLayout) { savedLayout.Connections.ForEach(gameLayout.AddNodeConnections); savedLayout.Objects.ForEach(puzzleObject => { var properties = new SetProperties(); puzzleObject.Properties.ForEach(property => { var type = Type.GetType(property.Type); var converter = System.ComponentModel.TypeDescriptor.GetConverter(type); var value = converter.ConvertFromInvariantString(property.Value); properties.Add(property.Key, value); }); gameLayout.PlaceObject(puzzleObject.Type, puzzleObject.Position, properties); }); }
public void SavesObjectToLayout() { var position = new TilePos(1, 1); _layoutToSave.PlaceObject("object", position, new SetProperties().Add("property", true)); var savedLayout = _sut.SaveToFlatLayout(_layoutToSave); savedLayout.Objects.Should().HaveCount(1); savedLayout.Objects[0].Type.Should().Be("object"); savedLayout.Objects[0].Position.Should().Be(position); savedLayout.Objects[0].Properties.Should().HaveCount(1); var property = savedLayout.Objects[0].Properties[0]; property.Key.Should().Be("property"); property.Type.Should().Be("System.Boolean"); property.Value.Should().Be("True"); }
public void DoesNotCreateOverlappingTiles() { var layout = new PuzzleLayout(); layout.AddNodeConnections(new NodeConnection(new TilePos(0, 0), new TilePos(1, 0))); layout.PlaceObject("Trap", new TilePos(0, 0)); var pool = new TestGamePool(); new Systems() .Add(pool.CreateSystem <PositionsCacheUpdateSystem>()) .Add(pool.CreateSystem(new GameLevelLoaderSystem(layout))) .Initialize(); var tilesAtPosition = pool.GetEntitiesAt(new TilePos(0, 0), e => e.IsTile()); tilesAtPosition.Count.Should().Be(1); }
public void Undo() { _layout.PlaceObject(_previousPuzzleObject.Type, _position); }
public T ObjectAt(string type, TilePos position, SetProperties properties = null) { Sut.PlaceObject(type, position, properties); return(This); }
private LevelLoadingTests ObjectAt(string type, TilePos position) { _layout.PlaceObject(type, position); return(this); }