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


C# Level.AddUpdate方法代码示例

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


在下文中一共展示了Level.AddUpdate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 rocketTail = lvl.GetTile((ushort)(x + cx), (ushort)(y + cy), (ushort)(z + cz));
                if (rocketTail != Block.fire) continue;
                
                int headIndex = lvl.PosToInt((ushort)(x - cx), (ushort)(y - cy), (ushort)(z - cz));
                byte rocketHead = headIndex < 0 ? Block.Zero : lvl.blocks[headIndex];                
                bool unblocked = !lvl.ListUpdate.Exists(u => u.b == headIndex || u.b == C.b);
                
                if (unblocked && (rocketHead == Block.air || rocketHead == Block.rocketstart)) {
                    lvl.AddUpdate(headIndex, Block.rockethead);
                    lvl.AddUpdate(C.b, Block.fire);
                } else if (rocketHead == Block.fire) {
                } else {
                    if (lvl.physics > 2)
                        lvl.MakeExplosion(x, y, z, 2);
                    else
                        lvl.AddUpdate(C.b, Block.fire);
                }
            }
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:30,代码来源:RocketPhysics.cs

示例2: 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

示例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);
            
            if (lvl.GetTile(x, (ushort)(y - 1), z) != Block.lavastill)
                return;
            
            if (lvl.GetTile(x, (ushort)(y + 1), z) == Block.air) {
                bool keepGoing = true;
                if ((lvl.Height * 80 / 100) < y)
                    keepGoing = rand.Next(1, 20) > 1;

                if (keepGoing) {
                    int bAbove = lvl.PosToInt(x, (ushort)(y + 1), z);
                    bool unblocked = !lvl.ListUpdate.Exists(u => u.b == bAbove);
                    if (unblocked) {
                        lvl.AddUpdate(bAbove, Block.firework, false);
                        lvl.AddUpdate(C.b, Block.lavastill, false, "wait 1 dissipate 100");
                        C.extraInfo = "wait 1 dissipate 100";
                        return;
                    }
                }
            }
            Firework(x, y, z, 4, lvl, rand);
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:25,代码来源:FireworkPhysics.cs

示例4: DoWaterOrLava

		public unsafe static void DoWaterOrLava(Level lvl, Check C, Random rand) {
			ushort x, y, z;
			lvl.IntToPos(C.b, out x, out y, out z);
			
			byte tileBelow = lvl.GetTile(x, (ushort)(y - 1), z);
			if (tileBelow == Block.air) {
				lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), lvl.blocks[C.b], false, C.extraInfo);
				lvl.AddUpdate(C.b, Block.air);
				C.extraInfo = "";
			} else if (tileBelow == Block.waterstill || tileBelow == Block.lavastill) {
				lvl.AddUpdate(C.b, Block.air);
				C.extraInfo = "";
			} else {
				const int count = 25;
				int* indices = stackalloc int[count];
				for (int i = 0; i < count; ++i)
					indices[i] = i;

				for (int k = count - 1; k > 1; --k) {
					int randIndx = rand.Next(k);
					int temp = indices[k];
					indices[k] = indices[randIndx]; // move random num to end of list.
					indices[randIndx] = temp;
				}

				for (int j = 0; j < count; j++) {
					int i = indices[j];
					ushort posX = (ushort)(x + (i / 5) - 2);
					ushort posZ = (ushort)(z + (i % 5) - 2);
					if (lvl.GetTile(posX, (ushort)(y - 1), posZ) == Block.air &&
					    lvl.GetTile(posX, y, posZ) == Block.air)
					{
						if (posX < x)
							posX = (ushort)(Math.Floor((double)(posX + x) / 2));
						else
							posX = (ushort)(Math.Ceiling((double)(posX + x) / 2));
						if (posZ < z)
							posZ = (ushort)(Math.Floor((double)(posZ + z) / 2));
						else
							posZ = (ushort)(Math.Ceiling((double)(posZ + z) / 2));

						int index = lvl.PosToInt(posX, y, posZ);
						if (index >= 0 && lvl.blocks[index] == Block.air &&
						    lvl.AddUpdate(index, lvl.blocks[C.b], false, C.extraInfo))
						{
							lvl.AddUpdate(C.b, Block.air);
							C.extraInfo = "";
							return;
						}
					}
				}
			}
		}
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:53,代码来源:FinitePhysics.cs

示例5: ExpandDiagonal

		static void ExpandDiagonal(Level lvl, ushort x, ushort y, ushort z,
		                           int xOffset, int yOffset, int zOffset) {
			if (!Block.FireKill(lvl.GetTile((ushort)(x + xOffset),
			                                (ushort)(y + yOffset), (ushort)(z + zOffset))))
				return;
			
			if (xOffset != 0)
				lvl.AddUpdate(lvl.PosToInt((ushort)(x + xOffset), y, z), Block.fire);
			if (yOffset != 0)
				lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y + yOffset), z), Block.fire);
			if (zOffset != 0)
				lvl.AddUpdate(lvl.PosToInt(x, y, (ushort)(z + zOffset)), Block.fire);
		}
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:13,代码来源:FirePhysics.cs

示例6: FlyTo

		static void FlyTo(Level lvl, Check C, int x, int y, int z) {
			int index = lvl.PosToInt((ushort)x, (ushort)y, (ushort)z);
			if (index < 0) 
				return;
			
			switch (lvl.blocks[index]) {
				case Block.air:
					lvl.AddUpdate(index, lvl.blocks[C.b]);
					break;
				case Block.op_air:
					break;
				default:
					lvl.AddUpdate(C.b, Block.red, false, "dissipate 25");
					break;
			}
		}
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:16,代码来源:BirdPhysics.cs

示例7: ExpandSimple

		static bool ExpandSimple(Level lvl, int x, int y, int z) {
			int index = lvl.PosToInt((ushort)x, (ushort)y, (ushort)z);
			if (index < 0 || lvl.blocks[index] != Block.air) return false;
			
			lvl.AddUpdate(index, Block.fire);
			return true;
		}
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:7,代码来源:FirePhysics.cs

示例8: DoFlood

 public static void DoFlood(Level lvl, Check C, Random rand, AirFlood mode, byte block) {
     if (C.time >= 1) {
         lvl.AddUpdate(C.b, 0);
         C.time = 255; return;
     }
     ushort x, y, z;
     lvl.IntToPos(C.b, out x, out y, out z);
     
     FloodAir(lvl, lvl.PosToInt((ushort)(x + 1), y, z), block);
     FloodAir(lvl, lvl.PosToInt((ushort)(x - 1), y, z), block);
     FloodAir(lvl, lvl.PosToInt(x, y, (ushort)(z + 1)), block);
     FloodAir(lvl, lvl.PosToInt(x, y, (ushort)(z - 1)), block);
     
     switch (mode) {
         case AirFlood.Full:
             FloodAir(lvl, lvl.PosToInt(x, (ushort)(y - 1), z), block);
             FloodAir(lvl, lvl.PosToInt(x, (ushort)(y + 1), z), block);
             break;
         case AirFlood.Layer:
             break;
         case AirFlood.Down:
             FloodAir(lvl, lvl.PosToInt(x, (ushort)(y - 1), z), block);
             break;
         case AirFlood.Up:
             FloodAir(lvl, lvl.PosToInt(x, (ushort)(y + 1), z), block);
             break;
     }
     C.time++;
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:29,代码来源:AirPhysics.cs

示例9: DoGeyser

        public static void DoGeyser(Level lvl, Check C, Random rand) {
            C.time++;
            ushort x, y, z;
            lvl.IntToPos(C.b, out x, out y, out z);
            byte below = lvl.GetTile(x, (ushort)(y - 1), z);
            
            if (below == Block.air) {
                lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), Block.geyser);
            } else if (below != Block.geyser) {
                byte block = lvl.blocks[C.b];
                lvl.PhysWater(lvl.PosToInt((ushort)(x + 1), y, z), block);
                lvl.PhysWater(lvl.PosToInt((ushort)(x - 1), y, z), block);
                lvl.PhysWater(lvl.PosToInt(x, y, (ushort)(z + 1)), block);
                lvl.PhysWater(lvl.PosToInt(x, y, (ushort)(z - 1)), block);
            }

            if (lvl.physics <= 1 || C.time <= 10) return;
            C.time = 0;
            bool flowUp = false;
            
            GeyserFlow(lvl, x - 1, y, z, ref flowUp);
            GeyserFlow(lvl, x + 1, y, z, ref flowUp);
            GeyserFlow(lvl, x, y - 1, z, ref flowUp);
            GeyserFlow(lvl, x, y, z - 1, ref flowUp);
            GeyserFlow(lvl, x, y, z + 1, ref flowUp);
            if (flowUp)
                GeyserFlow(lvl, x, y + 1, z, ref flowUp);
        }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:28,代码来源:ExtLiquidPhysics.cs

示例10: MagmaFlow

 static void MagmaFlow(Level lvl, int x, int y, int z, ref bool flowUp) {
     int index = lvl.PosToInt((ushort)x, (ushort)y, (ushort)z);
     if (index >= 0 && Block.LavaKill(lvl.blocks[index])) {
         lvl.AddUpdate(index, Block.magma);
         flowUp = true;
     }
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:7,代码来源:ExtLiquidPhysics.cs

示例11: Expand

		static bool Expand(Level lvl, int x, int y, int z) {
			int index = lvl.PosToInt((ushort)x, (ushort)y, (ushort)z);
			if (index >= 0 && lvl.blocks[index] == Block.air &&
			    lvl.AddUpdate(index, Block.finiteWater)) {
				return true;
			}
			return false;
		}
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:8,代码来源:FinitePhysics.cs

示例12: Firework

 static void Firework(ushort x, ushort y, ushort z, int size, Level lvl, Random rand) {
     if (lvl.physics < 1 || lvl.physics == 5) return;
     int rand1 = rand.Next(Block.red, Block.white);
     int rand2 = rand.Next(Block.red, Block.white);
     int min = Math.Min(rand1, rand2), max = Math.Max(rand1, rand2);
     // Not using override, since override = true makes it more likely that a colored block will be
     // generated with no extraInfo, because it sets a Check for that position with no extraInfo.
     lvl.AddUpdate(lvl.PosToInt(x, y, z), Block.air);
     
     for (ushort yy = (ushort)(y - (size + 1)); yy <= (ushort)(y + (size + 1)); ++yy)
         for (ushort zz = (ushort)(z - (size + 1)); zz <= (ushort)(z + (size + 1)); ++zz)
             for (ushort xx = (ushort)(x - (size + 1)); xx <= (ushort)(x + (size + 1)); ++xx)
     {
         if (lvl.GetTile(xx, yy, zz) == Block.air && rand.Next(1, 40) < 2)
             lvl.AddUpdate(lvl.PosToInt(xx, yy, zz), (byte)rand.Next(min, max), 
                           false, "drop 100 dissipate 25");
     }
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:18,代码来源:FireworkPhysics.cs

示例13: Checktdoor

 static void Checktdoor(Level lvl, int index) {
     if (index < 0 || index >= lvl.blocks.Length) return;
     byte block = lvl.blocks[index];
     
     if (Block.tDoor(block)) {
         lvl.AddUpdate(index, Block.air, false,
                       "wait 10 door 1 revert " + block.ToString());
     }
 }
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:9,代码来源:ExtraInfoPhysics.cs

示例14: ExpandAvanced

		static void ExpandAvanced(Level lvl, int x, int y, int z) {
			int index = lvl.PosToInt((ushort)x, (ushort)y, (ushort)z);
			if (index < 0) return;
			byte block = lvl.blocks[index];
			
			if (Block.FireKill(block))
				lvl.AddUpdate(index, Block.fire);
			else if (block == Block.tnt)
				lvl.MakeExplosion((ushort)x, (ushort)y, (ushort)z, -1);
		}
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:10,代码来源:FirePhysics.cs

示例15: 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);

			switch (rand.Next(1, 15)) {
				case 1:
					if (lvl.GetTile(x, (ushort)(y - 1), z) == Block.air)
						lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y - 1), z), lvl.blocks[C.b]);
					else goto case 3;
					break;
				case 2:
					if (lvl.GetTile(x, (ushort)(y + 1), z) == Block.air)
						lvl.AddUpdate(lvl.PosToInt(x, (ushort)(y + 1), z), lvl.blocks[C.b]);
					else goto case 6;
					break;
				case 3:
				case 4:
				case 5:
					FlyTo(lvl, C, x - 1, y, z);
					break;
				case 6:
				case 7:
				case 8:
					FlyTo(lvl, C, x + 1, y, z);
					break;
				case 9:
				case 10:
				case 11:
					FlyTo(lvl, C, x, y, z - 1);
					break;
				default:
					FlyTo(lvl, C, x, y, z + 1);
					break;
			}
			lvl.AddUpdate(C.b, Block.air);
			C.time = 255;
		}
开发者ID:tommyz56,项目名称:MCGalaxy,代码行数:37,代码来源:BirdPhysics.cs


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