Combining Lego like bricks with Minecraft mechanics

Post news RSS Devblog 8 - Crafting system

Another important part of this type of game is being able to combine multiple items to create new ones and Brickcraft will not be less. Unfortunately this update is more of a hassle, since there is little calculation and a lot of code, although I have tried to show the minimum.

Posted by on


Another important part of this type of game is being able to combine multiple items to create new ones and Brickcraft will not be less. Unfortunately this update is more of a hassle, since there is little calculation and a lot of code, although I have tried to show the minimum.
Starting with the UI I'll do something super creative again and never seen before:


With the easy part done, it's time to go to the code.
We have to create the data structure of the recipes, which should contain the id of the item to be created, the amount of and the necessary ingredients. For the ingredients we will have another structure, since we cannot recycle any existing one, as at first we would think that it is only the item and the quantity, but we are forgetting the slot, since to craft objects we will force to put them in a certain order/position.

No sooner said than done.
We will also have to write down the recipes somewhere of course.


The first recipe of the game will be to combine 2 bricks of 2x2 to generate one of 2x4.
Now we need to get back to the UI. The 4 crafting slots will be different from the inventory ones. Player must be able to put items there but not get them back into inventory. To discard them, you can drag them out of inventory.
Every time you drag an item into a crafting slot, we will have to iterate over all the recipes to see if you can craft any of them.
Here we can do some tricks to go faster, such as looking to see if the total of items that have been put, fits with the total of ingredients in the recipe.

When we find a recipe that you can craft, we will present it to you visually and in case you drag the item into your inventory, we will proceed to remove all the ingredients and add the new object.

We will also update the UI, to reflect if it has run out of some material or at least show how much they have gone down.
Outcome:


I should also block the camera because it is a bit wtf to see it moving while you are looking at the inventory xD

Comments
Guest
Guest

This comment is currently awaiting admin approval, join now to view.

Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.

Follow Profile
Icon
Brickcraft
Platforms
Windows
Creator
FairlyUseless
Engine
Unity
Contact
Send Message
Homepage
Github.com
Release date
Game watch
Follow
News
Browse
News
New
Post news
Share
Related Games
Brickcraft
Brickcraft Adventure
Related Engines
Unity
Unity Commercial
Related Groups
Unity Games
Unity Games Hobbies & Interests with 1,826 members
Unity3d Discussion
Unity3d Discussion Educational with 28 members