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


C# ItemStack类代码示例

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


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


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