当前位置: 首页>>代码示例>>C#>>正文


C# Level.GetBlock方法代码示例

本文整理汇总了C#中Level.GetBlock方法的典型用法代码示例。如果您正苦于以下问题:C# Level.GetBlock方法的具体用法?C# Level.GetBlock怎么用?C# Level.GetBlock使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Level的用法示例。


在下文中一共展示了Level.GetBlock方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Tick

 public override void Tick(Level l)
 {
     if (l.GetBlock(X, Z, Y - 1) == Block.BlockList.AIR) {
         Add(l, new Active_Water(X, Z, Y - 1));
         Remove(l);
         //l.BlockChange((ushort)X, (ushort)Z, (ushort)(Y - 1), this);
     }
     else {
         if (l.GetBlock(X + 1, Z, Y) == Block.BlockList.AIR) {
             Add(l, new Active_Water(X + 1, Z, Y));
             //l.BlockChange((ushort)(X + 1), (ushort)Z, (ushort)Y, this);
         }
         if (l.GetBlock(X - 1, Z, Y) == Block.BlockList.AIR) {
             Add(l, new Active_Water(X - 1, Z, Y));
             //l.BlockChange((ushort)(X - 1), (ushort)Z, (ushort)Y, this);
         }
         if (l.GetBlock(X, Z + 1, Y) == Block.BlockList.AIR) {
             Add(l, new Active_Water(X, Z + 1, Y));
             //l.BlockChange((ushort)X, (ushort)(Z + 1), (ushort)Y, this);
         }
         if (l.GetBlock(X, Z - 1, Y) == Block.BlockList.AIR) {
             Add(l, new Active_Water(X, Z - 1, Y));
            // l.BlockChange((ushort)X, (ushort)(Z - 1), (ushort)Y, this);
         }
     }
 }
开发者ID:headdetect,项目名称:MCForge6-Vanilla,代码行数:26,代码来源:Active_Water.cs

示例2: Tick

 public override void Tick(Level l)
 {
     if (Block.CanPassLight(l.GetBlock(X, Z, Y + 1)))
     {
         l.BlockChange((ushort)X, (ushort)Z, (ushort)Y, Block.BlockList.GRASS);
         Remove(l);
     }
 }
开发者ID:ninedrafted,项目名称:MCForge-Vanilla,代码行数:8,代码来源:Dirt.cs

示例3: Tick

 public override void Tick(Level l)
 {
     if (l.GetBlock(X, Z, Y - 1) == Block.BlockList.AIR)
     {
         Remove(l);
         Add(l, new Gravel(X, Z, Y - 1));
         l.BlockChange((ushort)X, (ushort)Z, (ushort)Y, Block.BlockList.AIR);
     }
 }
开发者ID:nullpic,项目名称:MCForge-Vanilla,代码行数:9,代码来源:Gravel.cs

示例4: Tick

 public override void Tick(Level l)
 {
     if (l.GetBlock(X, Z, Y - 1) == Block.BlockList.AIR)
     {
         Remove(l);
         Add(l, new Sand(X, Z, Y - 1));
         l.BlockChange((ushort)X, (ushort)Z, (ushort)Y, Block.BlockList.AIR);
         return;
     }
     
     bool north = l.GetBlock(X + 1, Z, Y) == Block.BlockList.AIR;
     bool south = l.GetBlock(X - 1, Z, Y) == Block.BlockList.AIR;
     bool east = l.GetBlock(X, Z + 1, Y) == Block.BlockList.AIR;
     bool west = l.GetBlock(X, Z - 1, Y) == Block.BlockList.AIR;
     if (!north && !south && !east && !west)
         return;
     List<Vector2D> card = new List<Vector2D>();
     if (north)
         card.Add(new Vector2D(1, 0));
     if (south)
         card.Add(new Vector2D(-1, 0));
     if (east)
         card.Add(new Vector2D(0, 1));
     if (west)
         card.Add(new Vector2D(0, -1));
     List<Vector2D> diag = new List<Vector2D>();
     if (north && east)
         diag.Add(new Vector2D(1, 1));
     if (south && east)
         diag.Add(new Vector2D(-1, 1));
     if (north && west)
         diag.Add(new Vector2D(1, -1));
     if (south && west)
         diag.Add(new Vector2D(-1, -1));
     List<Vector2D> check = new List<Vector2D>();
     while (card.Count > 0)
     {
         int i = new Random().Next(0, card.Count);
         check.Add(card[i]);
         card.RemoveAt(i);
     }
     while (diag.Count > 0)
     {
         int i = new Random().Next(0, diag.Count);
         check.Add(diag[i]);
         diag.RemoveAt(i);
     }
     
     for (int i = 0; i < check.Count; ++i)
     {
         int x = (int)check[i].x;
         int z = (int)check[i].z;
         int y = x * z == 0 ? 1 : 2;
         if (l.GetBlock(X + x, Z + z, Y - y) == Block.BlockList.AIR && l.GetBlock(X + x, Z + z, Y - y + 1) == Block.BlockList.AIR)
         {
             Remove(l);
             Add(l, new Sand(X + x, Z + z, Y - y));
             l.BlockChange((ushort)X, (ushort)Z, (ushort)Y, Block.BlockList.AIR);
             return;
         }
     }
 }
开发者ID:nullpic,项目名称:MCForge-Vanilla,代码行数:62,代码来源:Sand.cs


注:本文中的Level.GetBlock方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。