示例#1
0
        public static IItemBase GetItem(int id)
        {
            IItemBase item = null;

            item = CSTable.StaticDataManager.ItemTpl[id];
            if (item == null)
            {
                item = CSTable.StaticDataManager.ItemEquip[id];
            }
            if (item == null)
            {
                item = CSTable.StaticDataManager.ItemFashion[id];
            }
            if (item == null)
            {
                item = CSTable.StaticDataManager.ItemPackage[id];
            }
            if (item == null)
            {
                item = CSTable.StaticDataManager.ItemGift[id];
            }
            if (item == null)
            {
                item = CSTable.StaticDataManager.ItemGem[id];
            }
            return(item);
        }
        private static nfloat GetCellHeight(IItemBase item)
        {
            nfloat finalHeight = 0;

            if (item is AllEventsItem)
            {
                return(72);
            }

            if (item is EventCategoryDouble)
            {
                var imageWidth = (UIScreen.MainScreen.Bounds.Width - 42) / 2;

                finalHeight += imageWidth * 0.65f;
                finalHeight += 28;
            }

            if (item is EventCategory)
            {
                finalHeight += 50;
            }

            if (item is Event)
            {
                finalHeight += UIScreen.MainScreen.Bounds.Width * 0.5f + 2;
            }

            return(finalHeight);
        }
示例#3
0
 private void Start()
 {
     if (this.item != null)
     {
         IItemBase itemObj = ItemManager.create <IItemBase>(this.item, this.transform.position, this.transform.rotation);
     }
 }
示例#4
0
 public void ChangeLinkedItems(IItemBase newSourceItem, IItemBase newTargetItem)
 {
     var relationship = Context.Relationships.GetRelation(Id);
     _relationship.SourceEntityId = relationship.SourceEntityId = newSourceItem.ItemId;
     _relationship.TargetEntityId = relationship.TargetEntityId = newTargetItem.ItemId;
     Context.Relationships.UpdateRelation(relationship);
 }
示例#5
0
    /// <summary>
    /// Called when the craft button is clicked.
    /// </summary>
    public void callback_craftButtonClick()
    {
        Recipe r = this.selectedRecipe.getRecipe();
        ContainerContents <IItemBase> inventory = this.getPlayer().inventory;

        // Remove the items from the players inventory.
        foreach (ItemData item in r.getIngredients())
        {
            int i;
            inventory.containsItem(item, out i);
            if (i != -1)
            {
                ItemManager.destroyItem(this.getPlayer(), i);
            }
        }

        // Add the new item to the players inventory.
        if (r.getResult() != null)
        {
            IItemBase item = ItemManager.create <IItemBase>(r.getResult());
            item.setInWorld(false, Vector3.zero, Quaternion.identity);
            inventory.addItem(item);
        }

        // Set the selected recipe to be null.
        this.selectedRecipe.setOutlined(false);
        this.setSelectedRecipe(null);
    }
示例#6
0
    /// <summary>
    /// Called by a slot game object when it is clicked on.
    /// </summary>
    public virtual void onSlotClick(int i, bool leftBtn, bool rightBtn, bool middleBtn)
    {
        ContainerHeldItem cm           = this.player.playerUI.heldItem;
        IItemBase         heldStack    = cm.getHeldItem();
        IItemBase         slotContents = this.contents.getItem(i);

        if (leftBtn)
        {
            if (heldStack == null && slotContents != null)
            {
                // Slot is empty, hand is occupied.  Pick up the stack.
                cm.setHeldStack(slotContents);
                this.contents.setItem(i, null);
            }
            else if (heldStack != null && slotContents == null)
            {
                // Slot is occupied, hand is not.  Drop off the stack.
                this.contents.setItem(i, heldStack);
                cm.setHeldStack(null);
            }
            else if (heldStack != null && slotContents != null)
            {
                // Both hand and slot have stuff.

                // Swap.
                IItemBase temp = slotContents;
                this.contents.setItem(i, heldStack);
                cm.setHeldStack(temp);
            }
        }
    }
示例#7
0
        /// <summary>
        /// 根据列表项信息创建节点
        /// </summary>
        /// <param name="item"></param>
        /// <param name="imgIndex">图片索引</param>
        /// <returns></returns>
        public static TreeNode CreateNode(this IItemBase item, int imgIndex)
        {
            var text = item is IPluginItem pluginItem && pluginItem.AppendSplit ? item.Text + "(|)" : item.Text;

            return(new TreeNode {
                Name = item.Name, Text = text, Tag = item, ImageIndex = imgIndex
            });
        }
示例#8
0
    /// <summary>
    /// Renders the slot contents on the screen.
    /// </summary>
    public virtual void renderSlotContents()
    {
        IItemBase item = this.container.getContents().getItem(this.index);

        if (item != null)
        {
            RenderHelper.renderItemMesh(item, this.transform.position, this.transform.rotation, this.transform.localScale);
        }
    }
示例#9
0
 public static IFolderDataBase NewFolderDataBase(IItemBase itemBase)
 {
     switch (itemBase.ItemKind)
     {
         case ItemKind.Folder:
             return new FolderDataBaseDefault() { DisplayName = itemBase.DisplayName, FolderType = GetFolderType(itemBase) };
         default:
             return new FolderDataBaseDefault() { DisplayName = itemBase.DisplayName, FolderType = DefaultFolderType };
     }
 }
示例#10
0
 public Item(IItemBase itemBase)
 {
     BaseType  = itemBase;
     ItemClass = itemBase.ItemClass;
     Tags      = itemBase.Tags;
     Width     = itemBase.InventoryWidth;
     Height    = itemBase.InventoryHeight;
     RequirementsFromBase();
     Image      = itemBase.Image;
     Properties = new ObservableCollection <ItemMod>(itemBase.GetRawProperties());
 }
示例#11
0
 public void generateItem()
 {
     if (this.areaEnabled == true && this.lootTable != null)
     {
         ItemData itemData = this.lootTable.getRndItem();
         if (itemData != null)
         {
             Quaternion rndRot = Quaternion.identity; // TODO
             IItemBase  item   = ItemManager.create <IItemBase>(itemData, this.getRndPoint(), rndRot);
         }
     }
 }
示例#12
0
 public void drawHotbarItems(ContainerContents <IItemBase> container)
 {
     for (int i = 0; i < 4; i++)
     {
         IItemBase item = container.getItem(i);
         if (item != null)
         {
             Transform t = this.hotbarSquares[i].transform;
             RenderHelper.renderItemMesh(item, t.position, t.rotation, t.localScale, this.orthoCamera);
         }
     }
 }
示例#13
0
 /// <summary>
 /// Sets the stack held by the mouse.  You can pass null.
 /// </summary>
 public void setHeldStack(IItemBase item)
 {
     if (item == null)
     {
         this.heldItem = null;
         this.textHeldItemName.text = string.Empty;
     }
     else
     {
         this.heldItem = item;
         this.textHeldItemName.text = ((IItem)item).getItemName();
     }
 }
示例#14
0
        public void AddItem(IItemBase item)
        {
            int index = this.IndexOfItem(item.ProductId);

            if (index == -1)
            {
                this.Items.Add(item);
            }
            else
            {
                this.Items[index] = item;
            }
            this.CalculateCartTotals();
        }
示例#15
0
    public override void onRightClick(Player player)
    {
        base.onRightClick(player);

        player.health.heal(this.data.healthRestored);
        this.onConsume();

        ItemManager.destroyHeldItem(player);

        IItemBase item = ItemManager.create <IItemBase>(this.data.leftoverItem);

        item.setInWorld(false, Vector3.zero, Quaternion.identity);
        player.inventory.addItem(item);
    }
示例#16
0
    protected void dropItem(int index, Vector3 pos)
    {
        IItemBase item = this.inventory.getItem(index);

        if (item != null)
        {
            item.setInWorld(true, pos, Quaternion.identity);
            this.inventory.setItem(index, null);


            if (this is Player)
            {
                ((Player)this).heldItemDisplayer.heldItemLastFrame = null;
            }
        }
    }
示例#17
0
 public static string GetFolderType(IItemBase itemBase)
 {
     if (itemBase.ItemKind != ItemKind.Folder)
         throw new ArgumentException("Type is wrong.", "itemBase");
     if (itemBase is LoadedTreeItem)
     {
         var str = ((LoadedTreeItem)itemBase).ItemData;
         var des = new JavaScriptSerializer();
         FolderModel item = des.Deserialize<FolderModel>(str);
         return item.FolderType;
     }
     else if (itemBase is IFolderData)
     {
         return ((IFolderData)itemBase).FolderType;
     }
     else
         throw new NotSupportedException("Type is wrong.");
 }
示例#18
0
 public OrderItem(IItemBase value)
 {
     if (value == null)
     {
         throw new System.ArgumentNullException(nameof(value));
     }
     this.Description = value.Description;
     this.ExPrice     = value.ExPrice;
     this.ExTotal     = value.ExTotal;
     this.Gst         = value.Gst;
     this.GstTotal    = value.GstTotal;
     this.ImageUrl    = value.ImageUrl;
     this.IncPrice    = value.IncPrice;
     this.IncTotal    = value.IncTotal;
     this.ProductId   = value.ProductId;
     this.ProductName = value.ProductName;
     this.Quantity    = value.Quantity;
 }
示例#19
0
        private void ModifyEventDetailCell(UITableViewCell cell, IItemBase item)
        {
            var eventDetailCell = cell as EventDetailCell;

            if (eventDetailCell != null)
            {
                var @event = item as IEvent;

                if (@event != null)
                {
                    SetEventCellAboutText(@event, eventDetailCell);

                    eventDetailCell.SetImagesVisible(@event.Images.Any());

                    eventDetailCell.SetAttendeesVisible(@event.Attendees.Any());
                }
            }
        }
示例#20
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="cell"></param>
        /// <param name="item"></param>
        /// <param name="path"></param>
        private void ModifyCommentCell(UITableViewCell cell, IItemBase item, NSIndexPath path)
        {
            var commentCell = cell as CommentCell;

            if (commentCell != null)
            {
                SetCommentCellText(item as IComment, commentCell);

                // Last cell has different ruler
                if (path.Section == TableView.IndexPathForLastRow.Section && path.Row == TableView.IndexPathForLastRow.Row)
                {
                    commentCell.SetRulerFullWidth(true);
                }
                else
                {
                    commentCell.SetRulerFullWidth(false);
                }
            }
        }
示例#21
0
        /// <summary>
        /// Modify the cell when it is a post
        /// </summary>
        /// <param name="item"></param>
        /// <param name="cell"></param>
        private void ModifyPostCell(IItemBase item, UITableViewCell cell)
        {
            var post = item as IFeedPost;

            if (post != null)
            {
                SetFeedPostCellText(post, cell);

                var postCell = cell as FeedPostCell;

                if (postCell != null)
                {
                    postCell.SetBottomSpacing(false);
                    postCell.SetCommentingEnabled(false);

                    if (post.NumberOfImages == 1)
                    {
                        postCell.SetMainImageVisible();
                    }
                    else if (post.NumberOfImages == 2)
                    {
                        postCell.SetSubImagesVisible();
                    }
                    else if (post.NumberOfImages > 2)
                    {
                        postCell.SetAllImagesVisible();
                    }
                    else
                    {
                        postCell.SetNoImagesVisible();
                    }

                    postCell.SetInformationVisible(post.Title != null);
                }
            }
        }
示例#22
0
 public static IMailboxData GetMailboxData(IItemBase itemBase)
 {
     if (itemBase.ItemKind != ItemKind.Mailbox)
         throw new ArgumentException("Type is wrong.", "itemBase");
     if (itemBase is LoadedTreeItem)
     {
         var str = ((LoadedTreeItem)itemBase).ItemData;
         var des = new JavaScriptSerializer();
         MailClass item = des.Deserialize<MailClass>(str);
         return item;
     }
     else if (itemBase is IMailboxData)
     {
         return itemBase as IMailboxData;
     }
     else
         throw new NotSupportedException("Type is wrong.");
 }
示例#23
0
 public static string GetItemSuffix(IItemBase itemBase, ExportType exportType)
 {
     if (exportType == ExportType.Msg)
         return ".msg";
     return GetItemSuffix(GetItemClass(itemBase));
 }
示例#24
0
 public static ItemClass GetItemClass(IItemBase itemBase)
 {
     return GetItemClass(GetItemClassStr(itemBase));
 }
示例#25
0
 public void ChangeTargetItem(IItemBase newTargetItem)
 {
     var relationship = Context.Relationships.GetRelation(Id);
     _relationship.TargetEntityId = relationship.TargetEntityId = newTargetItem.ItemId;
     Context.Relationships.UpdateRelation(relationship);
 }
示例#26
0
 /// <summary>
 /// Renders an ItemStack on the screen.  Used by containers.
 /// </summary>
 public static void renderItemMesh(IItemBase item, Vector3 position, Quaternion rotation, Vector3 scale, Camera camera = null)
 {
     RenderHelper.renderItemMesh(item.getData(), position, rotation, scale, camera);
 }
示例#27
0
 public bool IsAncestorOf(IItemBase item)
 {
     return(Context.PathBuilder.IsAncestorPath(_info.Path, item.Path));
 }
示例#28
0
 public bool IsDescendantOf(IItemBase item)
 {
     return(_context.PathBuilder.IsDescendantPath(_info.Path, item.Path));
 }
示例#29
0
 /// <summary>
 /// Destroys the passed Item.
 /// </summary>
 public static void destroy(IItemBase item)
 {
     GameObject.Destroy(item.getTransform().gameObject);
 }
示例#30
0
 public void ChangeSourceItem(IItemBase newSourceItem)
 {
     var relationship = Context.Relationships.GetRelation(Id);
     _relationship.SourceEntityId = relationship.SourceEntityId = newSourceItem.ItemId;
     Context.Relationships.UpdateRelation(relationship);
 }