#Farming System

1 messages · Page 1 of 1 (latest)

fast fulcrum
#

this is a game UI/UX problem tho, but my question is pure coding one

im trying to build a farm+idle game, players will not plant their crops one by one in a .... lets say 16X16 farmland, that gonna make them piss

so each section of farmland will have a terminal like stuff , let u plan/do a batch farming , ofc u can plant it by urself if u wanna gets ur hand dirty

lets say ur farmland is 12 X 8

  1. batch planting can starts everywhere but in a selection like this , rectangular/square area , all the section will plant the same crop

  2. smart avoid : if the area included has any plants not yet harvested, it will bypass(ignore)

  3. ofc the farmland will be a grid like structure

  4. each major section will have a parent script to take care of the overview, contain the map of all small section

  5. farmland will be made in a 3 level prefabbing layer

    • individual farmland
    • row
    • the whole map (grid)
native pendant
#

whats the question

fast fulcrum
#

or this is already good enough

native pendant
#

Row seems unnecessary tbh

fast fulcrum
#

yeah

#

i was planning to do with 2D array

#

put all farmland section into that single array

#

so the hierachy would be

farmland
subsection 1
subsection 2
subsection 3
....
subsection 96

native pendant
#

From grid stuff i've done (which might not be standard in anyway who knows) I usually have all of my tiles be assigned their matrix index and handle as much of the access via that as possible, in order to somewhat avoid how they are as gameobjects even mattering

native pendant
#

I say this just for general reference and not what you should do immediately but worth keeping in mind that in a bigger budget, more developed project these tiles might not even be individual gameobjects at all

#

For something smaller it's def worth it just for how easy it is to have your data split up and all nice but just regarding your concerns for hierarchy i don't think any of your code should neccasarily even aknowledge how it's setup yknow

fast fulcrum
#

so at the end the same scene might end up with 1600 farmland, but im planning this game as a smartphone game......

#

the project was decided as a "idle + farming" game two days ago, i want to think of how to design every system before i can get my hands on it

native pendant
#

I don't have firsthand experience optimizing for mobile but that's a big reason why you might actually want to consider how you would go about this with these tiles not being a gameobject per instance this early. not necessarily do it yet but think about it

fast fulcrum
#

yeah

native pendant
#

Like """ideally"""" most of your tiles would probably be some combined instanced mesh and stuff

fast fulcrum
#

no one wants their phone to be a stove lol

native pendant
#

dunno if any of what im saying helps but i guess tldr is i wouldn't worry about prefab/go hierarchy too much because ideally it wouldn't matter at all due to it ideally it would probably be a very, very small amount of gameobjects actually involved. Think about how your going to compose this kind of system with the mindset of how would you do this in raw c# without any gameobjects and then for prototyping/early iteration just make use of gameobjects for convince

#

and its abit of a pain to serialize them but multi dimensional arrays are your friend

fast fulcrum
#

because ive been warned for many times it might not

native pendant
#

I would have to see what people are warning you about because that does not make sense to me

#

you guarantee the sequence of storing data in arrays by doing it

fast fulcrum
#

nice

#

then i have one less worries 👍

#

and if i expand the farmland, without the concept of rows , how would i place the new sections in runtime?

native pendant
#

Usually I tend to spawn all my tiles at runtime so if you have some stuff pre-existing in scene there might be challenges im not as aware of but still should be fine. I tend to use a kinda pattern like

TileBehaviour : MonoBehaviour

public Vector3Int CurrentIndex


TileManager : MonoBehaviour

TileBehaviour[,,] tileMatrix
TileBehaviour tilePrefab

for x++, y++, z++ yada-yada etc.
    TileBehaviour newTile = Instansiate(tilePrefab)
    tileMatrix[x,y,z] = newTile;
    newTile.CurrentIndex = new(x,y,z)
#

which then everything is in a nice matrix and also all the tiles know where they are which is really helpful

fast fulcrum
#

thats not something beginner

native pendant
#

as long as your foundational stuff isn't reliant on gameobjects you can kinda kick that can down the road

#

and you'll want to for early iteration anyway

fast fulcrum
#

wait

#

yeah

native pendant
#

accessing all your data via matrixes and index etc. means your reliant on that monobehaviour, which can eventually be swapped out for maybe a base class or whatever

fast fulcrum
#

a collection of model class