Introduction
00:00:00:05 - 00:00:24:26
Peter
To be able to continue implementing different farming mechanics, like placing seeds on top of their preferred field towers. We need to be able to start multiple tools as well as to be able to swap between them. And later we'll need to have some sort of an inventory where we are going to be storing. They picked up items and later some way to be able to swap between them and to move them and to sell them.
00:00:25:01 - 00:00:47:11
Peter
And that's what we are going to start implementing in this section to implement this swapping tool mechanic. We need to first delete this connection between the player and the tool. We had the direct connection between this, but right now we want to extract the logic for storing the tools into a separate class called Tools bag, which will be responsible for storing.
00:00:47:11 - 00:01:10:14
Peter
What tools do we currently have and for swapping those tools. And the player will get access to the tool from the tools bag, which will be then connected to something called item database, which will be comfortable objects. So this will make our code more data driven, which is always beneficial for us in terms of making the code more maintainable.
00:01:11:12 - 00:01:30:10
Peter
The result will be that we have some sort of a database of game items where we define, for example, a stole and it has this specific ID so we can recreate it in our game, in our inventory or on our map. But it also presents an image name and all the other parameters that we want to know. So just can we start it?
00:01:30:11 - 00:01:49:00
Peter
Can it be thrown away or can it be consumed or the price of it if we want to sell it and we can easily simply use this plus icon to add a new item and define ID and for example, for things like code or other tools, we can define what are the tools, what is the tool type, which is the tool animator.
00:01:49:04 - 00:02:17:11
Peter
So we do not need to parse this directly in our script, but we have this defined in our game item's description, and this will make it easy for us to add new items and new tools to our game without touching the code. Now the item database will be split into item description, so this will be what our item database uses to define an item, but we will also have the crop database says items usually are the same day.
00:02:17:11 - 00:02:37:19
Peter
We can define the tools and we can define items that can be consumed and sold. So do those could be split into separate objects, but it is much easier to define them in one item description. But crops are entirely different because crops are defined. Where are they growing? What is the harvest time? What are the stages before we can harvest them?
00:02:37:25 - 00:03:15:25
Peter
This additional data requires us to create a specific definition of a crop data, but we can of course expand this and create different types for different data or different items. But the idea here is that the item database will have the reference to the items such as seeds and the crop which this seed can reference so that we know what is this crop when it grows and a player can access through the the tools bag, what is the crop based on the item that we are carrying, based on the tool or the seed bag that we are carrying And this is how we are going to extract this data from this item Item description object.
00:03:16:15 - 00:03:40:09
Peter
And again, by using this descriptive object as a data container, it is very easy for us to define all the parameters and even add new crop and define its parameters without touching the code. So everything is data driven, which should make our record more maintainable. Says it needs to process this data. And this data can vary, so it needs to handle all.
00:03:40:09 - 00:03:58:16
Peter
There are cases for different data and if we make our code in such a way, we are going to be able to define and expand our game with new items without worrying about the code. So this is the idea behind using this could be a little object, but of course you can get this data from Excel spreadsheet or from wherever you want.
00:03:58:24 - 00:04:02:01
Peter
The point is to make our code more data driven.