• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BlockFace类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BlockFace的典型用法代码示例。如果您正苦于以下问题:C# BlockFace类的具体用法?C# BlockFace怎么用?C# BlockFace使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BlockFace类属于命名空间,在下文中一共展示了BlockFace类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            Log.Warn("Player " + player.Username + " should be banned for hacking!");

            var block = world.GetBlock(blockCoordinates);
            if (block is Tnt)
            {
                world.SetBlock(new Air() {Coordinates = block.Coordinates});
                new PrimedTnt(world)
                {
                    KnownPosition = new PlayerLocation(blockCoordinates.X, blockCoordinates.Y, blockCoordinates.Z),
                    Fuse = (byte) (new Random().Next(0, 20) + 10)
                }.SpawnEntity();
            }
            else if (block.IsSolid)
            {
                var affectedBlock = world.GetBlock(GetNewCoordinatesFromFace(blockCoordinates, BlockFace.Up));
                if (affectedBlock.Id == 0)
                {
                    var fire = new Fire
                    {
                        Coordinates = affectedBlock.Coordinates
                    };
                    world.SetBlock(fire);
                }
            }
        }
开发者ID:newchild,项目名称:MiNET,代码行数:27,代码来源:ItemFlintAndSteel.cs


示例2: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     coordinates += MathHelper.BlockFaceToCoordinates(face);
     var descriptor = world.GetBlockData(coordinates);
     LadderDirection direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = LadderDirection.North;
             break;
         case Direction.South:
             direction = LadderDirection.South;
             break;
         case Direction.East:
             direction = LadderDirection.East;
             break;
         default:
             direction = LadderDirection.West;
             break;
     }
     descriptor.Metadata = (byte)direction;
     if (IsSupported(descriptor, user.Server, world))
     {
         world.SetBlockID(descriptor.Coordinates, BlockID);
         world.SetMetadata(descriptor.Coordinates, (byte)direction);
         item.Count--;
         user.Inventory[user.SelectedSlot] = item;
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:29,代码来源:LadderBlock.cs


示例3: Place

        public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace targetSide)
        {
            Player player = entity as Player;
            if (player == null)
                return;

            // TODO: Bugged - should depend on the player's Yaw/Pitch
            switch (player.Client.FacingDirection(4))
            {
                case "N":
                    block.MetaData = (byte)MetaData.Stairs.South;
                    break;
                case "E":
                    block.MetaData = (byte)MetaData.Stairs.West;
                    break;
                case "S":
                    block.MetaData = (byte)MetaData.Stairs.North;
                    break;
                case "W":
                    block.MetaData = (byte)MetaData.Stairs.East;
                    break;
                default:
                    return;
            }
            base.Place(entity, block, targetBlock, targetSide);
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:26,代码来源:BlockCobblestoneStairs.cs


示例4: UseItem

        public override void UseItem(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            var coor = GetNewCoordinatesFromFace(blockCoordinates, face);
            if (face == BlockFace.Up) // On top of block
            {
                // Standing Sign
                var sign = new StandingSign();
                sign.Coordinates = coor;
                // metadata for sign is a value 0-15 that signify the orientation of the sign. Same as PC metadata.
                sign.Metadata = (byte) ((int) (Math.Floor((player.KnownPosition.Yaw + 180)*16/360) + 0.5) & 0x0f);
                world.SetBlock(sign);
            }
            else if (face == BlockFace.North) // At the bottom of block
            {
                // Doesn't work, ignore if that happen.
                return;
            }
            else
            {
                // Wall sign
                var sign = new WallSign();
                sign.Coordinates = coor;
                sign.Metadata = (byte) face;
                world.SetBlock(sign);
            }

            // Then we create and set the sign block entity that has all the intersting data

            var signBlockEntity = new Sign
            {
                Coordinates = coor
            };

            world.SetBlockEntity(signBlockEntity);
        }
开发者ID:GoldishKirby,项目名称:MiNET,代码行数:35,代码来源:ItemSign.cs


示例5: PlaceBlock

		public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
		{
			if (face == BlockFace.Down) return true;

			switch (face)
			{
				case BlockFace.Up:
					Metadata = 5;
					break;
				case BlockFace.East:
					Metadata = 4;
					break;
				case BlockFace.West:
					Metadata = 3;
					break;
				case BlockFace.North:
					Metadata = 2;
					break;
				case BlockFace.South:
					Metadata = 1;
					break;
			}

			world.SetBlock(this);
			return true;
		}
开发者ID:PocketRealms,项目名称:MiNET,代码行数:26,代码来源:Torch.cs


示例6: Interact

        public override bool Interact(Level currentLevel, Player player, BlockCoordinates blockCoordinates, BlockFace face)
        {
            Sign signEntity = currentLevel.GetBlockEntity(blockCoordinates) as Sign;
            if (signEntity == null) return false;

            string world = signEntity.Text1;

            if (player.Level.LevelId.Equals(world)) return true;

            if (!Worlds.ContainsKey(player.Level.LevelId))
            {
                Worlds.Add(player.Level.LevelId, player.Level);
            }

            if (!Worlds.ContainsKey(world))
            {
                var mobHuntLevel = new MobHuntLevel(world, new FlatlandWorldProvider());
                mobHuntLevel.Initialize();
                Worlds.Add(world, mobHuntLevel);
            }

            Level level = Worlds[world];
            player.SpawnLevel(level);
            level.BroadcastTextMessage(string.Format("{0} teleported to world <{1}>.", player.Username, level.LevelId));

            return true;
        }
开发者ID:WilliamGao1,项目名称:MiNET,代码行数:27,代码来源:CustomStandingSign.cs


示例7: Place

        public override void Place(IEntityBase entity, IStructBlock iBlock, IStructBlock targetIBlock, BlockFace face)
        {
            var block = (StructBlock)iBlock;
            var living = entity as LivingEntity;
            if (living == null)
                return;

            // TODO: Bugged - should depend on the player's Yaw/Pitch
            switch (living.FacingDirection(4))
            {
                case "N":
                    block.MetaData = (byte)MetaData.Stairs.South;
                    break;
                case "E":
                    block.MetaData = (byte)MetaData.Stairs.West;
                    break;
                case "S":
                    block.MetaData = (byte)MetaData.Stairs.North;
                    break;
                case "W":
                    block.MetaData = (byte)MetaData.Stairs.East;
                    break;
                default:
                    return;
            }
            base.Place(entity, block, targetIBlock, face);
        }
开发者ID:TheaP,项目名称:c-raft,代码行数:27,代码来源:BlockWoodenStairs.cs


示例8: PlaceBlock

        public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
        {
            var rawbits = new BitArray(new byte[] { 0x00 });

            byte direction = player.GetDirection();
            if (face == BlockFace.PositiveY)
            {
                switch (direction)
                {
                    case 0:
                        //South
                        rawbits[1] = true;
                        rawbits[2] = true;
                        break;
                    case 1:
                        //West
                        rawbits[0] = true;
                        rawbits[2] = true;
                        break;
                    case 2:
                        //North
                        rawbits[1] = true;
                        rawbits[2] = true;
                        break;
                    case 3:
                        //East
                        rawbits[0] = true;
                        rawbits[2] = true;
                        break;
                }
            }
            else if (face == BlockFace.NegativeY)
            {
                rawbits[0] = true;
                rawbits[1] = true;
                rawbits[2] = true;
            }
            else if (face == BlockFace.PositiveZ)
            {
                rawbits[0] = true;
                rawbits[1] = true;
            }
            else if (face == BlockFace.NegativeZ)
            {
                rawbits[2] = true;
            }
            else if (face == BlockFace.PositiveX)
            {
                rawbits[0] = true;
            }
            else if (face == BlockFace.NegativeX)
            {
                rawbits[1] = true;
            }

            Metadata = ConvertToByte(rawbits);

            world.SetBlock(this);
            return true;
        }
开发者ID:LiveMC,项目名称:SharpMC,代码行数:60,代码来源:BlockLever.cs


示例9: PlaceBlock

        // 000 001 010 011 100
        public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
        {
            byte direction = player.GetDirection();

            byte upper = (byte) ((faceCoords.Y > 0.5 && face != BlockFace.Up) || face == BlockFace.Down ? 0x04 : 0x00);

            switch (direction)
            {
                case 0:
                    Metadata = (byte) (0 | upper);
                    break;
                case 1:
                    Metadata = (byte) (2 | upper);
                    break;
                case 2:
                    Metadata = (byte) (1 | upper);
                    break;
                case 3:
                    Metadata = (byte) (3 | upper);
                    break;
            }

            world.SetBlock(this);
            return true;
        }
开发者ID:CRBairdUSA,项目名称:MiNET,代码行数:26,代码来源:BlockStairs.cs


示例10: Place

 public override void Place(IEntityBase entity, IStructBlock iBlock, IStructBlock targetIBlock, BlockFace face)
 {
     StructBlock block = (StructBlock)iBlock;
     LivingEntity living = entity as LivingEntity;
     if (living == null)
         return;
     switch (living.FacingDirection(4))
     {
         case "N":
             block.MetaData = (byte)MetaData.Door.Northwest;
             break;
         case "W":
             block.MetaData = (byte)MetaData.Door.Southwest;
             break;
         case "S":
             block.MetaData = (byte)MetaData.Door.Southeast;
             break;
         case "E":
             block.MetaData = (byte)MetaData.Door.Northeast;
             break;
         default:
             return;
     }
     base.Place(entity, block, targetIBlock, face);
 }
开发者ID:TheaP,项目名称:c-raft,代码行数:25,代码来源:BlockBaseDoor.cs


示例11: Interact

		public override bool Interact(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face)
		{
			Metadata = (byte) (Metadata | (0x8));
			world.SetBlock(this);
			world.ScheduleBlockTick(this, TickRate);
			return true;
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:7,代码来源:Button.cs


示例12: PlaceBlock

		public override bool PlaceBlock(Level world, Player player, BlockCoordinates blockCoordinates, BlockFace face, Vector3 faceCoords)
		{
			Metadata = (byte) face;

			world.SetBlock(this);
			return true;
		}
开发者ID:TheDiamondYT2,项目名称:MiNET,代码行数:7,代码来源:Button.cs


示例13: Place

        public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
        {
            // Load the blocks surrounding the position (NSEW) not diagonals
            BlockData.Blocks[] nsewBlocks = new BlockData.Blocks[4];
            UniversalCoords[] nsewBlockPositions = new UniversalCoords[4];
            int nsewCount = 0;
            block.Chunk.ForNSEW(block.Coords, (uc) =>
            {
                nsewBlocks[nsewCount] = (BlockData.Blocks)block.World.GetBlockId(uc);
                nsewBlockPositions[nsewCount] = uc;
                nsewCount++;
            });

            // Count chests in list
            if (nsewBlocks.Where((b) => b == BlockData.Blocks.Chest).Count() > 1)
            {
                // Cannot place next to two chests
                return;
            }

            for (int i = 0; i < 4; i++)
            {
                UniversalCoords p = nsewBlockPositions[i];
                if (nsewBlocks[i] == BlockData.Blocks.Chest && block.Chunk.IsNSEWTo(p, (byte)BlockData.Blocks.Chest))
                {
                    // Cannot place next to a double chest
                    return;
                }
            }
            base.Place(entity, block, targetBlock, face);
        }
开发者ID:Smjert,项目名称:c-raft,代码行数:31,代码来源:BlockChest.cs


示例14: PlaceBlock

 public override bool PlaceBlock(Level world, Player player, Vector3 blockCoordinates, BlockFace face, Vector3 mouseLocation)
 {
     var prevblock = world.GetBlock(Coordinates);
     if (prevblock.Id == Id && prevblock.Metadata == Metadata)
     {
         DoubleSlab ds = new DoubleSlab(Metadata) {Coordinates = Coordinates};
         world.SetBlock(ds);
     }
     else if (prevblock.Id == Id && prevblock.Metadata != Metadata)
     {
         if (player.Gamemode != Gamemode.Creative)
         {
             player.Inventory.AddItem((short)Id, Metadata, 1);
         }
         return true;
     }
     else
     {
         bool upper = ((mouseLocation.Y >= 8 && face != BlockFace.PositiveY) || face == BlockFace.NegativeY);
         BitArray b = new BitArray(new byte[] {Metadata});
         b[3] = upper;
         Metadata = ConvertToByte(b);
         world.SetBlock(this);
     }
     return true;
 }
开发者ID:LiveMC,项目名称:SharpMC,代码行数:26,代码来源:Slab.cs


示例15: UseItem

 public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
 {
     blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
     var d = new BlockRedstoneDust {Coordinates = blockCoordinates};
     //d.SetPowerLevel(new Random().Next(0,15));
     world.SetBlock(d, true, true);
 }
开发者ID:LiveMC,项目名称:SharpMC,代码行数:7,代码来源:ItemRedstone.cs


示例16: Place

        public override void Place(EntityBase entity, StructBlock block, StructBlock targetBlock, BlockFace face)
        {
            Player player = (entity as Player);
            if (player == null)
                return;
            if (face == BlockFace.Down)
                return;

            switch (face)
            {
                case BlockFace.Down: return;
                case BlockFace.Up: block.MetaData = (byte)MetaData.Torch.Standing;
                    break;
                case BlockFace.West: block.MetaData = (byte)MetaData.Torch.West;
                    break;
                case BlockFace.East: block.MetaData = (byte)MetaData.Torch.East;
                    break;
                case BlockFace.North: block.MetaData = (byte)MetaData.Torch.North;
                    break;
                case BlockFace.South: block.MetaData = (byte)MetaData.Torch.South;
                    break;
            }

            base.Place(entity, block, targetBlock, face);
        }
开发者ID:AVATAR-Phoenix,项目名称:c-raft,代码行数:25,代码来源:BlockRedstoneTorch.cs


示例17: GetUvsForFace

    /// <summary>
    /// Gets the uvs for face given face.
    /// </summary>
    /// <returns>The uvs for face.</returns>
    /// <param name="face">Face.</param>
    public Vector2[] GetUvsForFace(BlockFace face)
    {
        switch (face)
        {
            case BlockFace.FRONT:
                return this.frontUv;

            case BlockFace.BACK:
                return this.backUv;

            case BlockFace.LEFT:
                return this.leftUv;

            case BlockFace.RIGHT:
                return this.rightUv;

            case BlockFace.TOP:
                return this.topUv;

            case BlockFace.BOTTOM:
                return this.bottomUv;
        }

        return null;
    }
开发者ID:kennux,项目名称:cubicworld,代码行数:30,代码来源:Block.cs


示例18: ItemUsedOnBlock

 public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
 {
     var bottom = coordinates + MathHelper.BlockFaceToCoordinates(face);
     var top = bottom + Coordinates3D.Up;
     if (world.GetBlockID(top) != 0 || world.GetBlockID(bottom) != 0)
         return;
     DoorFlags direction;
     switch (MathHelper.DirectionByRotationFlat(user.Entity.Yaw))
     {
         case Direction.North:
             direction = DoorFlags.Northwest;
             break;
         case Direction.South:
             direction = DoorFlags.Southeast;
             break;
         case Direction.East:
             direction = DoorFlags.Northeast;
             break;
         default: // Direction.West:
             direction = DoorFlags.Southwest;
             break;
     }
     user.Server.BlockUpdatesEnabled = false;
     world.SetBlockID(bottom, BlockID);
     world.SetMetadata(bottom, (byte)direction);
     world.SetBlockID(top, BlockID);
     world.SetMetadata(top, (byte)(direction | DoorFlags.Upper));
     user.Server.BlockUpdatesEnabled = true;
     item.Count--;
     user.Inventory[user.SelectedSlot] = item;
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:31,代码来源:DoorItem.cs


示例19: BlockPlaced

 public override void BlockPlaced(BlockDescriptor descriptor, BlockFace face, IWorld world, IRemoteClient user)
 {
     var chunk = world.FindChunk(descriptor.Coordinates);
     user.Server.Scheduler.ScheduleEvent(chunk,
         DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
         s => TrySpread(descriptor.Coordinates, world, user.Server));
 }
开发者ID:zevipa,项目名称:TrueCraft,代码行数:7,代码来源:GrassBlock.cs


示例20: UseItem

        public override void UseItem(Level world, Player player, Vector3 blockCoordinates, BlockFace face)
        {
            blockCoordinates = GetNewCoordinatesFromFace(blockCoordinates, face);
            var bl = world.GetBlock(blockCoordinates);

            var slot = 0;
            var hand0 = player.Inventory.GetItemInHand(0);
            var hand1 = player.Inventory.GetItemInHand(1);
            if (hand0.Id == Id)
            {
                slot = player.Inventory.CurrentSlot + 36;
            }
            else if (hand1.Id == Id)
            {
                slot = 45;
            }

            //player.SendChat("Block: " + bl.Id, ChatColor.Bold);
            if (bl.Id == 65535) return;

            if (bl.Id == 8)
            {
                //Water
                player.Inventory.SetSlot(slot, 326, 0, 1);
                world.SetBlock(new BlockAir() {Coordinates = blockCoordinates}, true, true);
            }

            if (bl.Id == 10)
            {
                //lava
                player.Inventory.SetSlot(slot, 327, 0, 1);
                world.SetBlock(new BlockAir() { Coordinates = blockCoordinates }, true, true);
            }
        }
开发者ID:LiveMC,项目名称:SharpMC,代码行数:34,代码来源:ItemBucket.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BlockList类代码示例发布时间:2022-05-24
下一篇:
C# BlockExpression类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap