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

C# Coordinates3D类代码示例

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

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



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

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


示例2: FurnaceWindow

        public FurnaceWindow(IEventScheduler scheduler, Coordinates3D coordinates,
            IItemRepository itemRepository, InventoryWindow inventory)
        {
            ItemRepository = itemRepository;
            EventScheduler = scheduler;
            Coordinates = coordinates;

            WindowAreas = new[]
                {
                    new WindowArea(IngredientIndex, 1, 1, 1),
                    new WindowArea(FuelIndex, 1, 1, 1),
                    new WindowArea(OutputIndex, 1, 1, 1),
                    new WindowArea(MainIndex, 27, 9, 3),
                    new WindowArea(HotbarIndex, 9, 9, 1)
                };
            inventory.MainInventory.CopyTo(MainInventory);
            inventory.Hotbar.CopyTo(Hotbar);
            foreach (var area in WindowAreas)
                area.WindowChange += (s, e) => OnWindowChange(new WindowChangeEventArgs(
                    (s as WindowArea).StartIndex + e.SlotIndex, e.Value));
            Copying = false;
            inventory.WindowChange += (sender, e) =>
            {
                if (Copying) return;
                if ((e.SlotIndex >= InventoryWindow.MainIndex && e.SlotIndex < InventoryWindow.MainIndex + inventory.MainInventory.Length)
                    || (e.SlotIndex >= InventoryWindow.HotbarIndex && e.SlotIndex < InventoryWindow.HotbarIndex + inventory.Hotbar.Length))
                {
                    inventory.MainInventory.CopyTo(MainInventory);
                    inventory.Hotbar.CopyTo(Hotbar);
                }
            };
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:32,代码来源:FurnaceWindow.cs


示例3: HydrationCheckEvent

 void HydrationCheckEvent(IMultiplayerServer server, Coordinates3D coords, IWorld world)
 {
     if (world.GetBlockID(coords) != BlockID)
         return;
     if (MathHelper.Random.Next(3) == 0)
     {
         var meta = world.GetMetadata(coords);
         if (IsHydrated(coords, world) && meta != 15)
             meta++;
         else
         {
             meta--;
             if (meta == 0)
             {
                 world.SetBlockID(coords, BlockID);
                 return;
             }
         }
         world.SetMetadata(coords, meta);
     }
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("farmland", chunk,
         TimeSpan.FromSeconds(UpdateIntervalSeconds),
         _server => HydrationCheckEvent(_server, coords, world));
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:25,代码来源:FarmlandBlock.cs


示例4: ItemUsedOnBlock

        public override void ItemUsedOnBlock(Coordinates3D coordinates, ItemStack item, BlockFace face, IWorld world, IRemoteClient user)
        {
            if (face == BlockFace.PositiveY || face == BlockFace.NegativeY)
            {
                // Trapdoors are not placed when the user clicks on the top or bottom of a block
                return;
            }

            // NOTE: These directions are rotated by 90 degrees so that the hinge of the trapdoor is placed
            // where the user had their cursor.
            switch (face)
            {
                case BlockFace.NegativeZ:
                    item.Metadata = (byte)TrapdoorDirection.West;
                    break;
                case BlockFace.PositiveZ:
                    item.Metadata = (byte)TrapdoorDirection.East;
                    break;
                case BlockFace.NegativeX:
                    item.Metadata = (byte)TrapdoorDirection.South;
                    break;
                case BlockFace.PositiveX:
                    item.Metadata = (byte)TrapdoorDirection.North;
                    break;
                default:
                    return;
            }

            base.ItemUsedOnBlock(coordinates, item, face, world, user);
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:30,代码来源:TrapdoorBlock.cs


示例5: BlockLoadedFromChunk

 public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
 {
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("crops", chunk,
         TimeSpan.FromSeconds(MathHelper.Random.Next(30, 60)),
         (s) => GrowBlock(s, world, coords));
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:7,代码来源:CropsBlock.cs


示例6: Update

 public void Update(IMobEntity entity, IEntityManager manager)
 {
     var cast = entity as IEntity;
     if (entity.CurrentPath != null)
         entity.AdvancePath(manager.TimeSinceLastUpdate);
     else
     {
         if (MathHelper.Random.Next(IdleChance) == 0)
         {
             var target = new Coordinates3D(
                 (int)(cast.Position.X + (MathHelper.Random.Next(Distance) - Distance / 2)),
                 0,
                 (int)(cast.Position.Z + (MathHelper.Random.Next(Distance) - Distance / 2))
             );
             IChunk chunk;
             var adjusted = entity.World.FindBlockPosition(target, out chunk, generate: false);
             target.Y = chunk.GetHeight((byte)adjusted.X, (byte)adjusted.Z) + 1;
             Task.Factory.StartNew(() =>
             {
                     entity.CurrentPath = PathFinder.FindPath(entity.World, entity.BoundingBox,
                         (Coordinates3D)cast.Position, target);
             });
         }
     }
 }
开发者ID:Gbear605,项目名称:TrueCraft,代码行数:25,代码来源:WanderState.cs


示例7: ItemUsedOnBlock

        private void ItemUsedOnBlock(World world, Coordinates3D coordinates, BlockFace face, Coordinates3D cursor, ItemInfo item)
        {
            var info = world.GetBlockInfo(coordinates);
            if (Block.GetIsSolidOnFace(info, face) == false)
                return;
            
            coordinates += MathHelper.BlockFaceToCoordinates(face);

            switch (face)
            {
                case BlockFace.NegativeZ:
                    world.SetBlockId(coordinates, item.ItemId);
                    world.SetMetadata(coordinates, (byte)Orientation.FacingNorth);
                    break;
                case BlockFace.PositiveZ:
                    world.SetBlockId(coordinates, item.ItemId);
                    world.SetMetadata(coordinates, (byte)Orientation.FacingSouth);
                    break;
                case BlockFace.NegativeX:
                    world.SetBlockId(coordinates, item.ItemId);
                    world.SetMetadata(coordinates, (byte)Orientation.FacingWest);
                    break;
                case BlockFace.PositiveX:
                    world.SetBlockId(coordinates, item.ItemId);
                    world.SetMetadata(coordinates, (byte)Orientation.FacingEast);
                    break;
                default:
                    // Ladders can't be placed lying flat.
                    break;
            }
        }
开发者ID:Bitterholz,项目名称:Craft.Net,代码行数:31,代码来源:LadderBlock.cs


示例8: Decorate

 public void Decorate(IWorld world, IChunk chunk, IBiomeRepository biomes)
 {
     var noise = new Perlin();
     noise.Seed = world.Seed;
     var chanceNoise = new ClampNoise(noise);
     chanceNoise.MaxValue = 2;
     for (int x = 0; x < 16; x++)
     {
         for (int z = 0; z < 16; z++)
         {
             var biome = biomes.GetBiome(chunk.Biomes[x * Chunk.Width + z]);
             var blockX = MathHelper.ChunkToBlockX(x, chunk.Coordinates.X);
             var blockZ = MathHelper.ChunkToBlockZ(z, chunk.Coordinates.Z);
             var height = chunk.HeightMap[x * Chunk.Width + z];
             if (biome.Plants.Contains(PlantSpecies.Cactus) && chanceNoise.Value2D(blockX, blockZ) > 1.7)
             {
                 var blockLocation = new Coordinates3D(x, height, z);
                 var cactiPosition = blockLocation + Coordinates3D.Up;
                 if (chunk.GetBlockID(blockLocation).Equals(SandBlock.BlockID))
                 {
                     var HeightChance = chanceNoise.Value2D(blockX, blockZ);
                     var CactusHeight = (HeightChance < 1.4) ? 2 : 3;
                     Decoration.GenerateColumn(chunk, cactiPosition, CactusHeight, CactusBlock.BlockID);
                 }
             }
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:28,代码来源:CactusDecorator.cs


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


示例10: BlockLoadedFromChunk

 public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
 {
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("cactus", chunk,
         TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
         s => TryGrowth(s, coords, world));
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:7,代码来源:CactusBlock.cs


示例11: BlockLoadedFromChunk

 public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
 {
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent(chunk,
         DateTime.UtcNow.AddSeconds(MathHelper.Random.Next(MinGrowthTime, MaxGrowthTime)),
         s => TrySpread(coords, world, server));
 }
开发者ID:zevipa,项目名称:TrueCraft,代码行数:7,代码来源:GrassBlock.cs


示例12: IsCuboidCorner

 public static bool IsCuboidCorner(Coordinates2D location, Coordinates3D start, Vector3 size)
 {
     return location.X.Equals(start.X) && location.Z.Equals(start.Z)
         || location.X.Equals(start.X) && location.Z.Equals(start.Z + (int)size.Z - 1)
         || location.X.Equals(start.X + (int)size.X - 1) && location.Z.Equals(start.Z)
         || location.X.Equals(start.X + (int)size.X - 1) && location.Z.Equals(start.Z + (int)size.Z - 1);
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:7,代码来源:Decoration.cs


示例13: GenerateCuboid

        /*
         * Cuboid Modes
         * 0x0 - Solid cuboid of the specified block
         * 0x1 - Hollow cuboid of the specified block
         * 0x2 - Outlines the area of the cuboid using the specified block
         */
        public static void GenerateCuboid(IChunk chunk, Coordinates3D location, Vector3 size, byte block, byte meta = 0x0, byte mode = 0x0)
        {
            //If mode is 0x2 offset the size by 2 and change mode to 0x1
            if (mode.Equals(0x2))
            {
                size += new Vector3(2, 2, 2);
                mode = 0x1;
            }

            for (int w = location.X; w < location.X + size.X; w++)
            {
                for (int l = location.Z; l < location.Z + size.Z; l++)
                {
                    for (int h = location.Y; h < location.Y + size.Y; h++)
                    {

                        if (w < 0 || w >= Chunk.Width || l < 0 || l >= Chunk.Depth || h < 0 || h >= Chunk.Height)
                            continue;
                        Coordinates3D BlockLocation = new Coordinates3D(w, h, l);
                        if (!h.Equals(location.Y) && !h.Equals(location.Y + (int)size.Y - 1)
                            && !IsCuboidWall(new Coordinates2D(w, l), location, size)
                            && !IsCuboidCorner(new Coordinates2D(w, l), location, size))
                            continue;

                        chunk.SetBlockID(BlockLocation, block);
                        if (meta != 0x0)
                            chunk.SetMetadata(BlockLocation, meta);
                    }
                }
            }
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:37,代码来源:Decoration.cs


示例14: TryGrowth

 private void TryGrowth(IMultiplayerServer server, Coordinates3D coords, IWorld world)
 {
     if (world.GetBlockID(coords) != BlockID)
         return;
     // Find current height of stalk
     int height = 0;
     for (int y = -MaxGrowHeight; y <= MaxGrowHeight; y++)
     {
         if (world.GetBlockID(coords + (Coordinates3D.Down * y)) == BlockID)
             height++;
     }
     if (height < MaxGrowHeight)
     {
         var meta = world.GetMetadata(coords);
         meta++;
         world.SetMetadata(coords, meta);
         var chunk = world.FindChunk(coords);
         if (meta == 15)
         {
             if (world.GetBlockID(coords + Coordinates3D.Up) == 0)
             {
                 world.SetBlockID(coords + Coordinates3D.Up, BlockID);
                 server.Scheduler.ScheduleEvent("cactus", chunk,
                     TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
                     (_server) => TryGrowth(_server, coords + Coordinates3D.Up, world));
             }
         }
         else
         {
             server.Scheduler.ScheduleEvent("cactus", chunk,
                 TimeSpan.FromSeconds(MathHelper.Random.Next(MinGrowthSeconds, MaxGrowthSeconds)),
                 (_server) => TryGrowth(_server, coords, world));
         }
     }
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:35,代码来源:CactusBlock.cs


示例15: ValidCactusPosition

        public bool ValidCactusPosition(BlockDescriptor descriptor, IBlockRepository repository, IWorld world, bool checkNeighbor = true, bool checkSupport = true)
        {
            if (checkNeighbor)
            {
                var adjacent = new Coordinates3D[]
                {
                    descriptor.Coordinates + Coordinates3D.North,
                    descriptor.Coordinates + Coordinates3D.East,
                    descriptor.Coordinates + Coordinates3D.South,
                    descriptor.Coordinates + Coordinates3D.West,
                };

                foreach (var coords in adjacent)
                    if (world.GetBlockID(coords) != AirBlock.BlockID)
                        return false;
            }

            if (checkSupport)
            {
                var supportingBlock = repository.GetBlockProvider(world.GetBlockID(descriptor.Coordinates + Coordinates3D.Down));
                if ((supportingBlock.ID != CactusBlock.BlockID) && (supportingBlock.ID != SandBlock.BlockID))
                    return false;
            }

            return true;
        }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:26,代码来源:CactusBlock.cs


示例16: BlockChange

 public static void BlockChange(MinecraftClient client, IPacket _packet)
 {
   var packet = (BlockChangePacket)_packet;
   var position = new Coordinates3D(packet.X, packet.Y, packet.Z);
   client.World.SetBlockId(position, (short)packet.BlockType);
   client.World.SetMetadata(position, packet.BlockMetadata);
 }
开发者ID:Booser,项目名称:Craft.Net,代码行数:7,代码来源:WorldHandlers.cs


示例17: BlockLoadedFromChunk

 public override void BlockLoadedFromChunk(Coordinates3D coords, IMultiplayerServer server, IWorld world)
 {
     var chunk = world.FindChunk(coords);
     server.Scheduler.ScheduleEvent("farmland", chunk,
         TimeSpan.FromSeconds(UpdateIntervalSeconds),
         s => HydrationCheckEvent(s, coords, world));
 }
开发者ID:ComputeLinux,项目名称:TrueCraft,代码行数:7,代码来源:FarmlandBlock.cs


示例18: UpdateHeightMap

 private void UpdateHeightMap(Coordinates3D coords)
 {
     IChunk chunk;
     var adjusted = World.FindBlockPosition(coords, out chunk, generate: false);
     if (!HeightMaps.ContainsKey(chunk.Coordinates))
         return;
     var map = HeightMaps[chunk.Coordinates];
     byte x = (byte)adjusted.X; byte z = (byte)adjusted.Z;
     Coordinates3D _;
     for (byte y = (byte)(chunk.GetHeight(x, z) + 2); y > 0; y--)
     {
         if (y >= Chunk.Height)
             continue;
         _.X = x; _.Y = y - 1; _.Z = z;
         var id = chunk.GetBlockID(_);
         if (id == 0)
             continue;
         var provider = BlockRepository.GetBlockProvider(id);
         if (provider.LightOpacity != 0)
         {
             map[x, z] = y;
             break;
         }
     }
 }
开发者ID:ricucremop,项目名称:TrueCraft,代码行数:25,代码来源:WorldLighting.cs


示例19: SetBlockInfo

 public static void SetBlockInfo(this World world, Coordinates3D coordinates, BlockInfo info)
 {
     world.SetBlockId(coordinates, info.BlockId);
     world.SetMetadata(coordinates, info.Metadata);
     world.SetSkyLight(coordinates, info.SkyLight);
     world.SetBlockLight(coordinates, info.BlockLight);
 }
开发者ID:Bitterholz,项目名称:Craft.Net,代码行数:7,代码来源:WorldExtensions.cs


示例20: DefaultBlockMinedHandler

 public static void DefaultBlockMinedHandler(BlockDescriptor block, World world, Coordinates3D destroyedBlock, ItemDescriptor? tool)
 {
     var drops = Block.GetBlockDrop(block, world, destroyedBlock);
     world.SetBlockId(destroyedBlock, 0);
     world.SetMetadata(destroyedBlock, 0);
     foreach (var drop in drops)
         world.OnSpawnEntityRequested(new ItemEntity((Vector3)destroyedBlock + new Vector3(0.5), drop));
 }
开发者ID:nevercast,项目名称:Craft.Net,代码行数:8,代码来源:LogicHelpers.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Coords类代码示例发布时间:2022-05-24
下一篇:
C# Coordinates2D类代码示例发布时间: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