Unity3d system realizes the various functions of the items in the backpack

Source: Internet
Author: User
Tags json

Some of the effects are shown first:

The backpack is used to store the characters acquired in the game, the box is used to temporarily save the items (only save function), the role panel is used to simulate to the character equipment, weapons, costumes, etc., the rightmost red font panel is used to display the current equipment under the character of the sum of the various attributes.


The Trader panel function is mainly used to give players to buy items and sell their own items, in addition to see the left side of the black piece (the font is colorful), to display the properties of each item. There is also a coin pattern in the upper right corner to show the player's current coins, the player to buy equipment when the coin is reduced, the backpack equipment sold to vendors when the coins increased, but the price of the sale is different.


Forged panels are used to provide a forging function for the player, and players can forge more powerful items using the items in the backpack that match the forged requirements. Specific forging requirements are not introduced, follow-up introduction.

There is also the most important UML class diagram, to understand this basic will probably take care of this so-called equipment system:

First of all, let us understand a general idea, starting from the overall grasp: First look at the UML diagram on the left, the left side does not involve the U3d UI of the various transformation logic, just for the simple processing of data storage and acquisition and so on. Each item has its own property (Id,name), and then the item class on the left is a two enumeration to supplement the type and quality of the item. Then, the item class is derived from the item type enumeration of four sub-categories with special functions: consumables (such as blood bottles, blue bottles, etc.), equipment (mainly for players to dress up), weapons do not say, material class (used to forge better items). Add: The equipment class also has different types, like the top can only wear on the upper body, trousers only in the lower body, so also use an enumeration to distinguish. The weapon is also divided into the main hand weapon (usually the right hand) and the second arm (left hand).


Next, look at the right part of the UNL graph: The right side is used to handle the various transformation logic involved in the U3d UI. First, each item's various attribute information is placed in a JSON (if you do not understand the JSON itself Google or Baidu Kazakhstan, here no longer repeat. ), the item manager is responsible for parsing, and of course the item manager is also responsible for the display and hiding of some cue boxes (the black block of the colorful fonts described above) panel. Inventory (Inventory) class, is the base class of each equipment panel, why this design, because each of the following function panel (subclass), there are a lot of the same method, so in the base class Inventory write first, so that even if the subclass of the function to rewrite the parent class method is also completely possible. Inventory each of the following sub-categories has been described above, not to repeat. Slot item slots, which correspond to the place where each item is stored in the diagram, is used primarily for storing the item function, note that it is also a base class, because the function of each panel's item slot will be different (follow-up introduction). Itemui class, the meaning of the name, is the actual embodiment of the object in the UI, only two attributes, the number of items and items, such as the above image of the item display UI.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.