Im having an issue with the scripting for a game im designing.
Its a card game with a strong narrative element. Players will start with a card deck with preselected cards and those cards will appear one by one in order (through a list that is created at day start.)
Each card has an option (which players select to create new narrative paths and add new cards at day start.)
All cards are scriptable objects.
The issue that im having (although several as it is my first project in unity, I am a boardgame designer) is that I dont know how to add a serialized field to the scriptable object in order to modify the script attached to the onclick() event for each card.
I have the cards on the table.
I can change through them using another button that changes the scene (NOT ideally what I wanted)
But they all have the same button functions and same amount of buttons which is not what I wanted.
I will be changing some of the cards and creating more than one type of card scriptable object to bypass this problem.
It takes me a long time as Im still learning c# and the unity interface.
Excellent. Now consider cards as a sort of user interface.
Using the cards your player will signal his intent to the game engine.
Some “intentions” might be:
place the card on the table
remove the card from the table
turn the card sideways (like “tapping” in Magic)
press a button on the card (I’ve never seen this but you say yours have buttons?)
etc
Identify what you want to do with the possible user intentions associated with each type of card.
Again I’ll use Magic The Gathering.
Land:
place the card on the table: result: counts as your one land placement, and does nothing
remove the card from the table: result: illegal: you cannot remove land
tap the card: add one mana to your magic pool
Creature:
place the card on the table: result: uses mana, summons the card, places it on the field
attack: illegal except during attack phase (now you need to make phases)
You want to flesh out and hard-wire two or three of these.
Perhaps have a DEATH card, if you play it, you lose the game
Then have a WINNER card, if you play it, you win the game
Then perhaps a GAIN HEALTH card: if you play it, you gain 1 health each turn… now you need a turn-taking system.etc
Then perhaps a DESTROY OTHER CARD ability: drag the card onto another card and both get destroyed.
Only once you have some of these behaviors hard-wired through the cards, then start thinking of ways to abstract it into ScriptableObjects or MonoBehaviours, as appropriate.
But focus on the intent and behavior flow: user does X, game does Y, turn ends, etc.
Im not sure that would suit my game though.
The game works much more as an RPG/Choose your own adventure kind of game. I’ll attach an image so you see what I’m describing.
I know theres a long way to go in the project, but Im doing this by myself and its still very complicated.
Your button has an On Click() interface in the inspector click the + and then add an object and a script method attached to it. Usually the script is attached to your own object, but it’s not required.