Beispiel #1
0
        public BuildInstruction(BuildShape shape, Dimension dimension, Location location, IElement toBuild)
        {
            _shape = shape;
            _dimension = dimension;
            _toBuild = toBuild;

            Width = dimension.Width*toBuild.Width;
            Depth = dimension.Depth*toBuild.Depth;
            Height = dimension.Height*toBuild.Height;

            Location = location;
        }
        private BuildStatement ParseBuild()
        {
            var shape = BuildShape.Box;
            var dimension = Dimension.Default;
            var location = new Location();
            if (Current.Kind == TokenKind.Operation)
            {
                shape = ParseBuildShape(Current.Value);
                Advance();
            }

            if (Current.Kind == TokenKind.Dimension)
            {
                dimension = Dimension.Parse(Current.Value);
                Advance();
            }

            if (Current.Kind == TokenKind.Location)
            {
                location = Location.Parse(Current.Value);
                Advance();
            }

            if (Current.Kind == TokenKind.Identifier)
            {
                var ident = Current;
                Advance(TokenKind.EndOfLine);
                _tokens.MoveNext();
                return new BuildByIdentifier(shape, dimension, location, ident.Value.Substring(1));
            }
            else
            {
                var statements = ParseStatementBlock();
                return new BuildByStatements(shape, dimension, location, statements);
            }
        }
Beispiel #3
0
 public Location Adjust(Location location)
 {
     return new Location(location.X + X, location.Z + Z, location.Y + Y);
 }
Beispiel #4
0
 public void ItParsesBuildStatements(string input,BuildShape shape , Dimension dim, Location loc, string element)
 {
     var tokens = new MineDefineLexer(new MemoryStream(Encoding.UTF8.GetBytes(input))).Lex();
     var build = (BuildByIdentifier)new MineDefineParser(tokens).Parse().Statements.Single();
     Assert.AreEqual(shape, build.Shape);
     Assert.AreEqual(dim, build.Dimension);
     Assert.AreEqual(loc, build.Location);
     Assert.AreEqual(element, build.Identifier);
 }
Beispiel #5
0
 public void PlaceBlock(AlphaBlock block, Location loc)
 {
     _blockManager.SetID(loc.X, loc.Y, loc.Z,block.ID);
 }
Beispiel #6
0
 public void PlaceBlock(AlphaBlock block, Location loc)
 {
     _world.GetBlockManager().SetBlock(loc.X, loc.Y, loc.Z, block);
 }
Beispiel #7
0
 public void PlaceBlock(AlphaBlock block, Location loc)
 {
     placements[loc] = block;
 }
Beispiel #8
0
 public void AssertPlaced(int x, int z, int y)
 {
     var loc = new Location(x, z, y);
     AssertPlaced(loc);
 }
Beispiel #9
0
 public void AssertPlaced(Location loc)
 {
     var isPlaced = placements.ContainsKey(loc);
     Assert.IsTrue(isPlaced, "Expected a block to be placed at " + loc);
 }
 public BuildStatement(BuildShape shape, Dimension dimension, Location location)
 {
     Shape = shape;
     Dimension = dimension;
     Location = location;
 }
 public BuildByStatements(BuildShape shape, Dimension dimension, Location location, IEnumerable<IStatement> statements)
     : base(shape, dimension, location)
 {
     Statements = ImmutableList.CreateRange(statements);
 }
 public BuildByIdentifier(BuildShape shape, Dimension dimension, Location location, string identifier)
     : base(shape, dimension, location)
 {
     Identifier = identifier;
 }