i need to spawn chests with random positions but each chest must have different fucntions like if i click first chest it will open in 1hr for the second chest it will open in 30mins like this for all chest the timer will vary and some functionalities too… someone help me out
What is it you’re asking about? Just different delays when clicked to open for each chest?
Spawn the item first, then set it’s properties. Sounds like your opening is purely based on one floating point value (time until opening) that you can set in a factory.
ya exactly… spawning different objects with different delays and coins,gems inside the chest to collect
So you want a chest class and an item class.
The chest class could have something like an initialisation method that will take the opening delay and a list of contents - void Init( float fOpenDelay, List< ChestItems > lItems )
.
Then just instantiate and initialise a load of those bad boys.
Ok, so here you want to use polymorphism. So your chest class can have virtual methods in it, for example virtual public void DoMagicAction( )
. Now you can create any number of specialist chests that implement their own DoMagicAction()
.