コード例 #1
0
ファイル: Element.cs プロジェクト: heneryville/MineDefine
        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;
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
ファイル: Transform.cs プロジェクト: heneryville/MineDefine
 public Location Adjust(Location location)
 {
     return new Location(location.X + X, location.Z + Z, location.Y + Y);
 }
コード例 #4
0
ファイル: ParserTest.cs プロジェクト: heneryville/MineDefine
 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);
 }
コード例 #5
0
ファイル: WorldStamp.cs プロジェクト: heneryville/MineDefine
 public void PlaceBlock(AlphaBlock block, Location loc)
 {
     _blockManager.SetID(loc.X, loc.Y, loc.Z,block.ID);
 }
コード例 #6
0
ファイル: BlockStamp.cs プロジェクト: heneryville/MineDefine
 public void PlaceBlock(AlphaBlock block, Location loc)
 {
     _world.GetBlockManager().SetBlock(loc.X, loc.Y, loc.Z, block);
 }
コード例 #7
0
ファイル: FakeStamp.cs プロジェクト: heneryville/MineDefine
 public void PlaceBlock(AlphaBlock block, Location loc)
 {
     placements[loc] = block;
 }
コード例 #8
0
ファイル: FakeStamp.cs プロジェクト: heneryville/MineDefine
 public void AssertPlaced(int x, int z, int y)
 {
     var loc = new Location(x, z, y);
     AssertPlaced(loc);
 }
コード例 #9
0
ファイル: FakeStamp.cs プロジェクト: heneryville/MineDefine
 public void AssertPlaced(Location loc)
 {
     var isPlaced = placements.ContainsKey(loc);
     Assert.IsTrue(isPlaced, "Expected a block to be placed at " + loc);
 }
コード例 #10
0
 public BuildStatement(BuildShape shape, Dimension dimension, Location location)
 {
     Shape = shape;
     Dimension = dimension;
     Location = location;
 }
コード例 #11
0
 public BuildByStatements(BuildShape shape, Dimension dimension, Location location, IEnumerable<IStatement> statements)
     : base(shape, dimension, location)
 {
     Statements = ImmutableList.CreateRange(statements);
 }
コード例 #12
0
 public BuildByIdentifier(BuildShape shape, Dimension dimension, Location location, string identifier)
     : base(shape, dimension, location)
 {
     Identifier = identifier;
 }