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


C# Level.IntOffset方法代码示例

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


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

示例1: Do

		public static void Do(Level lvl, Check C, Random rand) {
			int dirX = rand.Next(1, 10) <= 5 ? 1 : -1;
			int dirY = rand.Next(1, 10) <= 5 ? 1 : -1;
			int dirZ = rand.Next(1, 10) <= 5 ? 1 : -1;
			ushort x, y, z;
			lvl.IntToPos(C.b, out x, out y, out z);

			for (int cx = -dirX; cx != 2 * dirX; cx += dirX)
				for (int cy = -dirY; cy != 2 * dirY; cy += dirY)
					for (int cz = -dirZ; cz != 2 * dirZ; cz += dirZ)
			{
				byte tileBelow = lvl.GetTile((ushort)(x + cx),(ushort)(y + cy - 1), (ushort)(z + cz));
				byte tile = lvl.GetTile((ushort)(x + cx),(ushort)(y + cy), (ushort)(z + cz));
				
				if ((tileBelow == Block.red || tileBelow == Block.op_air) &&
				    (tile == Block.air || tile == Block.water)) {
					lvl.AddUpdate(lvl.PosToInt((ushort)(x + cx), 
					                           (ushort)(y + cy), (ushort)(z + cz)), Block.train);
					lvl.AddUpdate(C.b, Block.air);
					
					byte newBlock = tileBelow == Block.red ? Block.obsidian : Block.glass;
					lvl.AddUpdate(lvl.IntOffset(C.b, 0, -1, 0), newBlock, true,
					          "wait 5 revert " + tileBelow.ToString());
					return;
				}
			}
		}
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:27,代码来源:TrainPhysics.cs

示例2: DoDoorsOnly

        public static bool DoDoorsOnly(Level lvl, Check C, Random rand) {
            if (!C.extraInfo.Contains("wait") && lvl.blocks[C.b] == Block.air)
                C.extraInfo = "";

            bool wait = false, door = false;
            int waitTime = 0;
            string[] parts = C.extraInfo.Split(' ');
            for (int i = 0; i < parts.Length; i++) {
                if (i % 2 != 0) continue;
                
                switch (parts[i]) {
                    case "wait":
                        waitTime = int.Parse(parts[i + 1]);
                        wait = true; break;
                    case "door":
                        door = true; break;
                }
            }
            if (!wait)
                return false;
            
            if (door && C.time < 2) {
                // TODO: perhaps do proper bounds checking
                Checktdoor(lvl, lvl.IntOffset(C.b, -1, 0, 0));
                Checktdoor(lvl, lvl.IntOffset(C.b, 1, 0, 0));
                Checktdoor(lvl, lvl.IntOffset(C.b, 0, -1, 0));
                Checktdoor(lvl, lvl.IntOffset(C.b, 0, 1, 0));
                Checktdoor(lvl, lvl.IntOffset(C.b, 0, 0, -1));
                Checktdoor(lvl, lvl.IntOffset(C.b, 0, 0, 1));
            }

            if (C.time > waitTime) {
                int waitIndex = C.extraInfo.IndexOf("wait ");
                C.extraInfo =
                    C.extraInfo.Substring(0, waitIndex) +
                    C.extraInfo.Substring(C.extraInfo.IndexOf(' ', waitIndex + 5) + 1);
                return false;
            }
            C.time++;
            return true;
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:41,代码来源:ExtraInfoPhysics.cs

示例3: Do

        public static void Do(Level lvl, Check C, Random rand) {
            ushort x, y, z;
            lvl.IntToPos(C.b, out x, out y, out z);
            int dirsVisited = 0, index = 0;
            Player foundPlayer = AIPhysics.ClosestPlayer(lvl, C);
            
            if (foundPlayer != null && rand.Next(1, 20) < 19) {
                switch (rand.Next(1, 10)) {
                    case 1:
                    case 2:
                    case 3:
                        index = lvl.PosToInt((ushort)(x + Math.Sign((foundPlayer.pos[0] / 32) - x)), y, z);
                        if (index != C.b && MoveSnake(lvl, C, index)) return;
                        
                        dirsVisited++;
                        if (dirsVisited >= 3) break;
                        goto case 4;
                    case 4:
                    case 5:
                    case 6:
                        index = lvl.PosToInt(x, (ushort) (y + Math.Sign((foundPlayer.pos[1] / 32) - y)), z);
                        if (index != C.b && MoveSnakeY(lvl, C, index)) return;
                        
                        dirsVisited++;
                        if (dirsVisited >= 3) break;
                        goto case 7;
                    case 7:
                    case 8:
                    case 9:
                        index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((foundPlayer.pos[2] / 32) - z)));
                        if (index != C.b && MoveSnake(lvl, C, index)) return;
                        
                        dirsVisited++;
                        if (dirsVisited >= 3) break;
                        goto case 1;
                }
            }
            
            dirsVisited = 0;
            switch (rand.Next(1, 13)) {
                case 1:
                case 2:
                case 3:
                    index = lvl.IntOffset(C.b, -1, 0, 0);
                    if (MoveSnake(lvl, C, index)) return;

                    dirsVisited++;
                    if (dirsVisited >= 4) return;
                    goto case 4;
                case 4:
                case 5:
                case 6:
                    index = lvl.IntOffset(C.b, 1, 0, 0);
                    if (MoveSnake(lvl, C, index)) return;

                    dirsVisited++;
                    if (dirsVisited >= 4) return;
                    goto case 7;
                case 7:
                case 8:
                case 9:
                    index = lvl.IntOffset(C.b, 0, 0, 1);
                    if (MoveSnake(lvl, C, index)) return;

                    dirsVisited++;
                    if (dirsVisited >= 4) return;
                    goto case 10;
                case 10:
                case 11:
                case 12:
                default:
                    index = lvl.IntOffset(C.b, 0, 0, -1);
                    if (MoveSnake(lvl, C, index)) return;
                    
                    dirsVisited++;
                    if (dirsVisited >= 4) return;
                    goto case 1;
            }
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:79,代码来源:SnakePhysics.cs

示例4: MoveSnakeY

 static bool MoveSnakeY(Level lvl, Check C, int index ) {
     byte block = lvl.GetTile(index);
     byte blockAbove = lvl.GetTile(lvl.IntOffset(index, 0, 1, 0));
     byte block2Above = lvl.GetTile(lvl.IntOffset(index, 0, 2, 0));
     
     if (block == Block.air &&
         (blockAbove == Block.grass ||
          blockAbove == Block.dirt && block2Above == Block.air)) {
         if (lvl.AddUpdate(index, lvl.blocks[C.b])) {
             lvl.AddUpdate(C.b, Block.snaketail, true, "wait 5 revert 0");
             return true;
         }            
     }
     return false;
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:15,代码来源:SnakePhysics.cs

示例5: MoveSnake

        static bool MoveSnake(Level lvl, Check C, int index) {
            if (
                lvl.GetTile(lvl.IntOffset(index, 0, -1, 0)) == Block.air &&
                lvl.GetTile(index) == Block.air) {
                index = lvl.IntOffset(index, 0, -1, 0);
            } else if (
                lvl.GetTile(index) == Block.air &&
                lvl.GetTile(lvl.IntOffset(index, 0, 1, 0)) == Block.air) {
            } else if (
                lvl.GetTile(lvl.IntOffset(index, 0, 2, 0)) == Block.air &&
                lvl.GetTile(lvl.IntOffset(index, 0, 1, 0)) == Block.air) {
                index = lvl.IntOffset(index, 0, 1, 0);
            }

            if (lvl.AddUpdate(index, lvl.blocks[C.b])) {
                lvl.AddUpdate(C.b, Block.snaketail, true, "wait 5 revert 0");
                return true;
            }
            return false;
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:20,代码来源:SnakePhysics.cs

示例6: Do

        public static void Do(Level lvl, Check C, Random rand) {
            ushort x, y, z;
            lvl.IntToPos(C.b, out x, out y, out z);
            
            // Make zombie fall down
            if (lvl.GetTile(x, (ushort)(y - 1), z) == Block.air) {
                lvl.AddUpdate(C.b, Block.zombiehead);
                lvl.AddUpdate(lvl.IntOffset(C.b, 0, -1, 0), lvl.blocks[C.b]);
                lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
                return;
            }
            bool checkTime = true;
            int index = 0;
            Player closest = AIPhysics.ClosestPlayer(lvl, C);

            if (closest != null && rand.Next(1, 20) < 18) {
                if (rand.Next(1, 7) <= 3) {
                    index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
                    if (index != C.b && MoveZombie(lvl, C, index)) return;
                    
                    index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
                    if (index != C.b && MoveZombie(lvl, C, index)) return;
                } else {
                    index = lvl.PosToInt(x, y, (ushort)(z + Math.Sign((closest.pos[2] / 32) - z)));
                    if (index != C.b && MoveZombie(lvl, C, index)) return;
                    
                    index = lvl.PosToInt((ushort)(x + Math.Sign((closest.pos[0] / 32) - x)), y, z);
                    if (index != C.b && MoveZombie(lvl, C, index)) return;
                }
                checkTime = false;
            }
            
            if (checkTime && C.time < 3) {
                C.time++;
                return;
            }

            int dirsVisited = 0;
            switch (rand.Next(1, 13))
            {
                case 1:
                case 2:
                case 3:
                    index = lvl.IntOffset(C.b, -1, 0, 0);
                    if (MoveZombie(lvl, C, index)) return;

                    dirsVisited++;
                    if (dirsVisited >= 4) return;
                    goto case 4;

                case 4:
                case 5:
                case 6:
                    index = lvl.IntOffset(C.b, 1, 0, 0);
                    if (MoveZombie(lvl, C, index)) return;

                    dirsVisited++;
                    if (dirsVisited >= 4) return;
                    goto case 7;

                case 7:
                case 8:
                case 9:
                    index = lvl.IntOffset(C.b, 0, 0, 1);
                    if (MoveZombie(lvl, C, index)) return;

                    dirsVisited++;
                    if (dirsVisited >= 4) return;
                    goto case 10;
                case 10:
                case 11:
                case 12:
                    index = lvl.IntOffset(C.b, 0, 0, -1);
                    if (MoveZombie(lvl, C, index)) return;

                    dirsVisited++;
                    if (dirsVisited >= 4) return;
                    goto case 1;
            }
            lvl.AddUpdate(C.b, Block.air);
            lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:82,代码来源:ZombiePhysics.cs

示例7: MoveZombie

        static bool MoveZombie(Level lvl, Check C, int index) {
            if(
                lvl.GetTile(lvl.IntOffset(index, 0, -1, 0)) == Block.air &&
                lvl.GetTile(index) == Block.air) {
                index = lvl.IntOffset(index, 0, -1, 0);
            } else if (
                lvl.GetTile(index) == Block.air &&
                lvl.GetTile(lvl.IntOffset(index, 0, 1, 0)) == Block.air) {
            } else if (
                lvl.GetTile(lvl.IntOffset(index, 0, 2, 0)) == Block.air &&
                lvl.GetTile(lvl.IntOffset(index, 0, 1, 0)) == Block.air) {
                index = lvl.IntOffset(index, 0, 1, 0);
            } else {
                return false;
            }

            if (lvl.AddUpdate(index, lvl.blocks[C.b])) {
                lvl.AddUpdate(lvl.IntOffset(index, 0, 1, 0), Block.zombiehead);
                lvl.AddUpdate(C.b, Block.air);
                lvl.AddUpdate(lvl.IntOffset(C.b, 0, 1, 0), Block.air);
                return true;
            }
            return false;
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:24,代码来源:ZombiePhysics.cs

示例8: odoorPhysics

 public static void odoorPhysics(Level lvl, Check C) {
     if (C.time != 0) {
         C.time = 0;
         return;
     }
     
     odoorNeighbour(lvl, C, lvl.IntOffset(C.b, -1, 0, 0));
     odoorNeighbour(lvl, C, lvl.IntOffset(C.b, +1, 0, 0));
     odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, -1, 0));
     odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, +1, 0));
     odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, 0, -1));
     odoorNeighbour(lvl, C, lvl.IntOffset(C.b, 0, 0, +1));
     C.time++;
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:14,代码来源:DoorPhysics.cs

示例9: AnyDoor

 static void AnyDoor(Level lvl, Check C, ushort x, ushort y, ushort z, int timer, bool instaUpdate = false) {
     if (C.time != 0) {
         CheckDoorRevert(lvl, C, timer);
         return;
     }
     PhysDoor(lvl, (ushort)(x + 1), y, z, instaUpdate);
     PhysDoor(lvl, (ushort)(x - 1), y, z, instaUpdate);
     PhysDoor(lvl, x, y, (ushort)(z + 1), instaUpdate);
     PhysDoor(lvl, x, y, (ushort)(z - 1), instaUpdate);
     PhysDoor(lvl, x, (ushort)(y - 1), z, instaUpdate);
     PhysDoor(lvl, x, (ushort)(y + 1), z, instaUpdate);
     
     if (lvl.blocks[C.b] != Block.door8_air) {
         CheckDoorRevert(lvl, C, timer);
         return;
     }
     
     for (int xx = -1; xx <= 1; xx++)
         for (int yy = -1; yy <= 1; yy++)
             for (int zz = -1; zz <= 1; zz++)
     {
         byte b = lvl.GetTile(lvl.IntOffset(C.b, xx, yy, zz));
         if (b == Block.rocketstart) {
             if (lvl.physics == 5) {
                 lvl.Blockchange(x, y, z, Block.air);
                 return;
             }
             int b1 = lvl.IntOffset(C.b, xx * 3, yy * 3, zz * 3);
             int b2 = lvl.IntOffset(C.b, xx * 2, yy * 2, zz * 2);
             bool unblocked = lvl.GetTile(b1) == Block.air && lvl.GetTile(b2) == Block.air &&
                 !lvl.ListUpdate.Exists(u => u.b == b1) &&
                 !lvl.ListUpdate.Exists(u => u.b == b2);
             
             if (unblocked) {
                 lvl.AddUpdate(b1, Block.rockethead);
                 lvl.AddUpdate(b2, Block.fire);
             }
         } else if (b == Block.firework) {
             if (lvl.physics == 5) {
                 lvl.Blockchange(x, y, z, Block.air);
                 return;
             }
             int b1 = lvl.IntOffset(C.b, xx, yy + 1, zz);
             int b2 = lvl.IntOffset(C.b, xx, yy + 2, zz);
             bool unblocked = lvl.GetTile(b1) == Block.air && lvl.GetTile(b2) == Block.air &&
                 !lvl.ListUpdate.Exists(u => u.b == b1) &&
                 !lvl.ListUpdate.Exists(u => u.b == b2);
             
             if (unblocked) {
                 lvl.AddUpdate(b2, Block.firework);
                 lvl.AddUpdate(b1, Block.lavastill, false, "dissipate 100");
             }
         } else if (b == Block.tnt) {
             if (lvl.physics == 5) {
                 lvl.Blockchange(x, y, z, Block.air);
                 return;
             }
             lvl.MakeExplosion((ushort)(x + xx), (ushort)(y + yy), (ushort)(z + zz), 0);
         }
     }
     CheckDoorRevert(lvl, C, timer);
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:62,代码来源:DoorPhysics.cs

示例10: DoComplex

        public static bool DoComplex(Level lvl, Check C, Random rand) {
            if (!C.extraInfo.Contains("wait") && lvl.blocks[C.b] == Block.air)
                C.extraInfo = "";

            bool wait = false, drop = false, dissipate = false, revert = false, door = false;
            int waitTime = 0, dropnum = 0, dissipatenum = 0; byte reverttype = 0;
            string[] parts = C.extraInfo.Split(' ');
            
            for (int i = 0; i < parts.Length; i++) {
                if (i % 2 != 0) continue;
                
                switch (parts[i]) {
                    case "wait":
                        waitTime = int.Parse(parts[i + 1]);
                        wait = true; break;
                    case "drop":
                        dropnum = int.Parse(parts[i + 1]);
                        drop = true; break;
                    case "dissipate":
                        dissipatenum = int.Parse(parts[i + 1]);
                        dissipate = true; break;
                    case "revert":
                        reverttype = byte.Parse(parts[i + 1]);
                        revert = true; break;
                    case "door":
                        door = true; break;
                }
            }

            if (wait) {
                if (door && C.time < 2) {
                    Checktdoor(lvl, lvl.IntOffset(C.b, -1, 0, 0));
                    Checktdoor(lvl, lvl.IntOffset(C.b, 1, 0, 0));
                    Checktdoor(lvl, lvl.IntOffset(C.b, 0, -1, 0));
                    Checktdoor(lvl, lvl.IntOffset(C.b, 0, 1, 0));
                    Checktdoor(lvl, lvl.IntOffset(C.b, 0, 0, -1));
                    Checktdoor(lvl, lvl.IntOffset(C.b, 0, 0, 1));
                }

                if (C.time > waitTime) {
                    int waitIndex = C.extraInfo.IndexOf("wait ");
                    C.extraInfo =
                        C.extraInfo.Substring(0, waitIndex) +
                        C.extraInfo.Substring(C.extraInfo.IndexOf(' ', waitIndex + 5) + 1);
                    DoOther(lvl, C, rand, revert, dissipate, drop, reverttype, dissipatenum, dropnum);
                    return false;
                }
                C.time++;
                return true;
            }
            DoOther(lvl, C, rand, revert, dissipate, drop, reverttype, dissipatenum, dropnum);
            return false;
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:53,代码来源:ExtraInfoPhysics.cs


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