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

C# ItemStack类代码示例

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

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



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

示例1: ItemFrameEntity

 public ItemFrameEntity(ItemStack item, ItemFrameDirection direction, Vector3 position)
 {
     Item = item;
     Position = position;
     Direction = direction;
     Pitch = GetRotation(Direction); // This should be Pitch, but it doesn't work. Not sure why.
 }
开发者ID:seaboy1234,项目名称:Craft.Net,代码行数:7,代码来源:ItemFrameEntity.cs


示例2: GetDrop

 protected override ItemStack[] GetDrop(BlockDescriptor descriptor, ItemStack item)
 {
     if (descriptor.Metadata >= 7)
         return new[] { new ItemStack(WheatItem.ItemID), new ItemStack(SeedsItem.ItemID, (sbyte)MathHelper.Random.Next(3)) };
     else
         return new[] { new ItemStack(SeedsItem.ItemID) };
 }
开发者ID:Zoxive,项目名称:TrueCraft,代码行数:7,代码来源:CropsBlock.cs


示例3: addToInventory

    public static void addToInventory(int itemID, string pathToIcon)
    {
        itemHUD_Controls hud = GameObject.Find ("ItemHUD").GetComponent<itemHUD_Controls>();

        for(int i = 0; i < maxInventorySize; i++) {
            if(inv[i] == null) {
                inv[i] = new ItemStack(itemID, pathToIcon);

                //Update Icon in Inventory HUD
                hud.items[i].GetComponent<Image> ().sprite = Resources.Load<Sprite> (pathToIcon);
                hud.items[i].GetComponent<Image> ().color = new Color32(255, 255, 255, 255);
                inv[i].incrementStack();
                //Update stack counter
                hud.items[i].GetComponentInChildren<Text>().text = getSlotStackSize(i).ToString();
                Resources.UnloadUnusedAssets();

                break;
            } else {
                if(inv[i].getItemID() == itemID && !inv[i].checkStackFull()) {
                    inv[i].incrementStack();
                    hud.items[i].GetComponentInChildren<Text>().text = getSlotStackSize(i).ToString();
                    break;
                }
            }
        }
    }
开发者ID:Aden-Herold,项目名称:AzamRealms,代码行数:26,代码来源:Inventory.cs


示例4: Click

 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is PlayerEntity))
     {
         // TODO: non-player support
         return;
     }
     PlayerEntity player = (PlayerEntity)entity;
     Location eye = player.GetEyePosition();
     Location forw = player.ForwardVector();
     RayCastResult rcr;
     bool h = player.TheRegion.SpecialCaseRayTrace(eye, forw, 5, MaterialSolidity.ANY, player.IgnoreThis, out rcr);
     if (h)
     {
         if (rcr.HitObject != null && rcr.HitObject is EntityCollidable && ((EntityCollidable)rcr.HitObject).Entity != null)
         {
             // TODO: ???
         }
         else if (player.Mode.GetDetails().CanPlace)
         {
             Location block = (new Location(rcr.HitData.Location) - new Location(rcr.HitData.Normal).Normalize() * 0.01).GetBlockLocation();
             block = block.GetBlockLocation();
             BlockInternal blockdat = player.TheRegion.GetBlockInternal(block);
             Material mat = (Material)blockdat.BlockMaterial;
             if (mat != Material.AIR)
             {
                 int paint = item.Datum;
                 player.TheRegion.SetBlockMaterial(block, mat, blockdat.BlockData, (byte)paint, (byte)(blockdat.BlockLocalData | (byte)BlockFlags.EDITED), blockdat.Damage);
             }
         }
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:32,代码来源:PaintbrushItem.cs


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


示例6: AddPart

 public void AddPart(ItemStack IS)
 {
     if (!Parts.Contains(IS))
     {
         Parts.Add(IS);
     }
 }
开发者ID:vinterdo,项目名称:SteamAge,代码行数:7,代码来源:CraftingRecipePart.cs


示例7: Split

 public void Split(ItemStack stack) {
     var nStack = stack.Split();
     if (nStack != null) {
         if (!AddNewStack(nStack))
             DropStack(nStack);
     }
 }
开发者ID:NaNLagger,项目名称:ZombieStarve,代码行数:7,代码来源:CanStore.cs


示例8: BinderItem

        public BinderItem(ItemValue itemValue)
        {
            bindItemData(DataItem.getItemDataByItemValue(itemValue));

            itemStack = createItemStack(DataItem.getItemDataByItemValue(itemValue), itemValue);
            bindItemValue(itemValue);
        }
开发者ID:Redeye123,项目名称:7DaysProfileEditor,代码行数:7,代码来源:BinderItem.cs


示例9: Awake

 private void Awake() {
     baseScript = GetComponent<SimpleObject>();
     if(drop == null) {
         ItemEntities.Init();
         drop = new ItemStack(ItemEntities.items.Values.First());
     }
 }
开发者ID:NaNLagger,项目名称:ZombieStarve,代码行数:7,代码来源:CanBeCollected.cs


示例10: Click

 public override void Click(Entity entity, ItemStack item)
 {
     // TODO: Should non-players be allowed here?
     if (!(entity is PlayerEntity))
     {
         return;
     }
     PlayerEntity player = (PlayerEntity)entity;
     // TODO: Generic 'player.gettargetblock'?
     Location eye = player.GetEyePosition();
     Location forw = player.ForwardVector();
     RayCastResult rcr;
     bool h = player.TheRegion.SpecialCaseRayTrace(eye, forw, 5, MaterialSolidity.ANY, player.IgnoreThis, out rcr);
     if (h)
     {
         if (rcr.HitObject != null && rcr.HitObject is EntityCollidable && ((EntityCollidable)rcr.HitObject).Entity != null)
         {
             // TODO: ???
         }
         else
         {
             Location block = (new Location(rcr.HitData.Location) - new Location(rcr.HitData.Normal).Normalize() * 0.01).GetBlockLocation();
             Material mat = player.TheRegion.GetBlockMaterial(block);
             if (mat != Material.AIR)
             {
                 player.Selection = new AABB() { Min = block, Max = block + Location.One };
                 player.NetworkSelection();
             }
         }
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:31,代码来源:StructureSelectorItem.cs


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


示例12: GetDrop

 public override bool GetDrop(ToolItem tool, out ItemStack[] drop)
 {
     drop = new ItemStack[0];
     if (tool is ShovelItem)
         drop = new[] { new ItemStack(new SnowballItem(), 1) };
     return tool is ShovelItem;
 }
开发者ID:cpancake,项目名称:Craft.Net,代码行数:7,代码来源:SnowfallBlock.cs


示例13: Click

 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is PlayerEntity))
     {
         return; // TODO: non-player support?
     }
     PlayerEntity player = (PlayerEntity)entity;
     if (player.Manipulator_Grabbed != null)
     {
         return;
     }
     Location eye = player.GetEyePosition();
     CollisionResult cr = player.TheRegion.Collision.RayTrace(eye, eye + player.ForwardVector() * 50, player.IgnoreThis);
     if (!cr.Hit || cr.HitEnt == null || cr.HitEnt.Mass <= 0)
     {
         return;
     }
     PhysicsEntity target = (PhysicsEntity)cr.HitEnt.Tag;
     player.Manipulator_Grabbed = target;
     player.Manipulator_Distance = (double)(eye - target.GetPosition()).Length();
     player.Manipulator_Beam = new ConnectorBeam() { type = BeamType.MULTICURVE };
     player.Manipulator_Beam.One = player;
     player.Manipulator_Beam.Two = target;
     player.Manipulator_Beam.color = Colors.BLUE;
     player.TheRegion.AddJoint(player.Manipulator_Beam);
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:26,代码来源:ManipulatorItem.cs


示例14: GenerateDropEntity

        public void GenerateDropEntity(BlockDescriptor descriptor, IWorld world, IMultiplayerServer server, ItemStack item)
        {
            var entityManager = server.GetEntityManagerForWorld(world);
            var items = new ItemStack[0];
            var type = ToolType.None;
            var material = ToolMaterial.None;
            var held = ItemRepository.GetItemProvider(item.ID);

            if (held is ToolItem)
            {
                var tool = held as ToolItem;
                material = tool.Material;
                type = tool.ToolType;
            }

            if ((EffectiveTools & type) > 0)
            {
                if ((EffectiveToolMaterials & material) > 0)
                    items = GetDrop(descriptor, item);
            }

            foreach (var i in items)
            {
                if (i.Empty) continue;
                var entity = new ItemEntity(new Vector3(descriptor.Coordinates) + new Vector3(0.5), i);
                entityManager.SpawnEntity(entity);
            }
        }
开发者ID:ricucremop,项目名称:TrueCraft,代码行数:28,代码来源:BlockProvider.cs


示例15: Click

 public override void Click(Entity entity, ItemStack item)
 {
     if (!(entity is CharacterEntity))
     {
         // TODO: Non-character support?
         return;
     }
     CharacterEntity character = (CharacterEntity)entity;
     double range = RangeBase * item.GetAttributeF("range_mod", 1f);
     double strength = StrengthBase * item.GetAttributeF("strength_mod", 1f) * GetStrength();
     Location start = character.GetEyePosition(); // TODO: ItemPosition?
     Location forw = character.ForwardVector();
     Location mid = start + forw * range;
     // TODO: base the pull on extent of the entity rather than its center. IE, if the side of a big ent is targeted, it should be rotated by the force.
     List<Entity> ents = character.TheRegion.GetEntitiesInRadius(mid, range);
     foreach (Entity ent in ents)
     {
         if (ent is PhysicsEntity) // TODO: Support for primitive ents?
         {
             PhysicsEntity pent = (PhysicsEntity)ent;
             Location rel = (start - ent.GetPosition());
             double distsq = rel.LengthSquared();
             if (distsq < 1)
             {
                 distsq = 1;
             }
             pent.ApplyForce((rel / distsq) * strength);
         }
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:30,代码来源:BaseForceRayItem.cs


示例16: InitItem

 public void InitItem(ItemStack itemStack) {
     GetComponent<Image>().sprite = itemStack.TypeItem.Icon;
     Count.text = itemStack.Count.ToString();
     currentItemStack = itemStack;
     itemStack.OnChangeCount += ChangeCount;
     itemStack.OnNullCount += Delete;
 }
开发者ID:NaNLagger,项目名称:ZombieStarve,代码行数:7,代码来源:DragItem.cs


示例17: Start

    // Use this for initialization
    void Start()
    {
        _descriptors = new ItemDescriptors();
        _descriptors.Initialize();

        // TODO: Hook Descriptors

        StorageContainer sc = new StorageContainer();
        Storage s = (Storage)_descriptors.Find("Backpack").Create();

        // Add the Storage to our StorageContainer
        sc.Storages.Add(s);

        ItemStack stack = new ItemStack(_descriptors.Find("Whiskey Bottle"), s);
        stack.AddQuantity(80);
        // Automatically add the Stack to the first available storage of the Container.
        sc.AddStack(stack);

        stack = new ItemStack(_descriptors.Find("Botan"));
        stack.AddQuantity(1);
        // Automatically add the Stack to the first available storage of the Container.
        sc.AddStack(stack);

        foreach (IStorage storage in sc.Storages)
        {
            string msg = "";
            msg += "Total Storage weight: " + storage.Weight / 1000.0f + "kg, Content Weight: " + System.Math.Round(storage.ContentWeight / 1000.0f, 2) + "/" + storage.Capacity / 1000.0f + "kg\n";
            foreach (IItemStack itemStack in storage.Stacks)
            {
                msg += itemStack.Quantity + "x " + itemStack.Descriptor.Name + " (" + itemStack.Weight / 1000.0f + "kg)\n";
            }
            Debug.Log(msg);
        }
    }
开发者ID:Rukenshia,项目名称:Unity-Inventory-System,代码行数:35,代码来源:ItemManager.cs


示例18: ReleaseAltClick

 public override void ReleaseAltClick(Entity entity, ItemStack item)
 {
     // TODO: Handle non-players
     if (!(entity is PlayerEntity))
     {
         return;
     }
     PlayerEntity player = (PlayerEntity)entity;
     if (player.TheRegion.GlobalTickTime - player.LastGunShot < fireRate)
     {
         return;
     }
     player.LastGunShot = player.TheRegion.GlobalTickTime;
     for (int i = 1; i < player.Breadcrumbs.Count; i++)
     {
         if ((player.GetPosition() - player.Breadcrumbs[i]).LengthSquared() < 4)
         {
             player.Breadcrumbs.RemoveRange(i, player.Breadcrumbs.Count - i);
         }
     }
     List<Location> locs = new List<Location>();
     Location cpos = player.GetPosition();
     for (int i = player.Breadcrumbs.Count - 1; i >= 0; i--)
     {
         if ((player.Breadcrumbs[i] - cpos).LengthSquared() > MaxRadius * MaxRadius)
         {
             break;
         }
         locs.Add(player.Breadcrumbs[i]);
     }
     if (locs.Count > 0)
     {
         player.Network.SendPacket(new PathPacketOut(locs));
     }
 }
开发者ID:Morphan1,项目名称:Voxalia,代码行数:35,代码来源:BreadcrumbItem.cs


示例19: onItemUse

 public override bool onItemUse(ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k,
     int l)
 {
     if (l == 0)
     {
         return false;
     }
     if (l == 1)
     {
         return false;
     }
     byte byte0 = 0;
     if (l == 4)
     {
         byte0 = 1;
     }
     if (l == 3)
     {
         byte0 = 2;
     }
     if (l == 5)
     {
         byte0 = 3;
     }
     var entitypainting = new EntityPainting(world, i, j, k, byte0);
     if (entitypainting.onValidSurface())
     {
         if (!world.singleplayerWorld)
         {
             world.entityJoinedWorld(entitypainting);
         }
         itemstack.stackSize--;
     }
     return true;
 }
开发者ID:riverar,项目名称:Crafty,代码行数:35,代码来源:ItemPainting.cs


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



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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