playMaker

Author Topic: detective game logic  (Read 1312 times)

TerraImagina

  • Playmaker Newbie
  • *
  • Posts: 33
detective game logic
« on: January 15, 2020, 07:30:47 AM »
Hi everyone

I would like to ask some more experimented user how to implement the barebone logic for a game I would like to make.

The game is a detective game for Kids where you have to find the guilty guy based on clue (like "Who am I ?")
On game start the clues and the culprit would be randomly choosen. like -long hat -blue eyes -red jaquet ...
On each scene the choosen clues would have to appear and to be found by the player through games.
On the last scene the culprit would be placed with the right items on him (for exemple -long hat -blue eyes -red jaquet) at a random place where other suspect are placed with random items...

I watched a lot of tutorials on array maker and I think I could use array or hashtable (which one would be best ?). I have a little understanding of how to work with it but still miss some understanding.
 I am still confuse how to implement it on such a mechanic.
Especialy the last scene, how to randomly place the culprit, how to place the items on the right spot (hat on the head, eyes, jaquet...).
Or  how to save the random choice of the clues on startup to work on all scenes....

Any help would be greatly appreciated!
Don't hesitate to tell me if I wasn't clear with the description
Thank you

TerraImagina

  • Playmaker Newbie
  • *
  • Posts: 33
Re: detective game logic
« Reply #1 on: February 17, 2020, 04:27:52 AM »
Just a friendly bump  ;D

I start to understand how to make the game mechanic, but as I never worked with array so far I don't know which method is the more suited for such a game.
I don't know how to handle the "clues". The clues are generated on the first scene, and then based on those clues, each scene will show different images.
Is it better with hastable or array ? Should I save them as global variable, or in the player prefs ?
I think I am a bit loss about how to handle variables in a game...

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: detective game logic
« Reply #2 on: February 17, 2020, 07:45:19 AM »
Hi,

 thanks for the bump, we need them :)

use Hashtables for clues, as you can better organise a clue using a reference and as the value, you either have a bool which tells you if this clue is available to the player or not, or the value of the clue what ever that is.

then, yes, indeed, you have then two problems, saving it and using it.

Saving it between sessions means using playerprefs indeed. no other way around, other than saving on a server online.

Using it can be done in different fashion, I would avoid global variables or keep it to the bare minimum, for example, only have as a global variable the gameobject responsible for the clues and have the hashtable on that gameobject.

you can also, tag the clue gameobject and have each fsm find it when they start, then you don't need the global variable at all.

each of your level features that need to act in different ways depending on clues will refer to that clue gameobject and query its hashtable for a specific clue value and act accordingly, that's all.

Let me know if that is not clarifying your vision on how to progress with this. we'll go more in details.

Bye,

 Jean

TerraImagina

  • Playmaker Newbie
  • *
  • Posts: 33
Re: detective game logic
« Reply #3 on: February 18, 2020, 05:43:21 AM »
Thank you Jean Fabre, really appreciate the support you are providing !

I implemented the hashtables and player prefs logic as you recommended and it work fine so far. It is done on a game object called _clueMechanic
The only thing I didn't understand is why I should tag this gameobject or have it as a  global variable? Is it not possible to have it on each scene I need and have a direct link to it, when I want to fetch variable to other FSM ? What is the benefice of your method ? I also read about dontdestroyonload on object to use them on all scene as well, but I am not sure it is relevant in this case...

Regards
« Last Edit: February 18, 2020, 07:54:14 AM by TerraImagina »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: detective game logic
« Reply #4 on: February 19, 2020, 07:08:49 AM »
Hi,

 whatever works for you, indeed if your object is set to not destroy on load it will remaing, but many fsm may be in a scene you load after, and so they start in an environment where they don't know the reference of the gameobject where the data is, so then you can use FindGameObject ( using tag for performance) when the fsm starts and then you keep that reference to access the data on it.

 or, you can save the reference in a global variable available directly for any fsm.

Bye,

 Jean