public class MiniGame : MonoBehaviour
Base class all of Mini Games, it implements the Rounds flow if there is a Controller assigned and provide callbacks for each state
_Controller |
|
_Rewards |
Every child of this object should have the MiniGames_Reward component assigned |
_SetupGameOnEnable |
(default:false) If true, in Enable it will start the Game Initialization. NOTE: If a controller is used, it's recommended to use the controller._StartGameOnEnable instead of this one |
_OnStart |
Event to allow calling functions when the game is initialized (can be used to enable/disable objects and effects) |
mRewards |
These rewards are filled from the _Reward children |
.
void SetupGame() |
Apply the Layout and Initialize the game |
void ApplyLayout() |
Arrange the rewards and other game elements in the initial state |
void FilterRewards() |
From the mRewards, it removes the rewards that shouldn't be used according to the gameplay (some powerups, need to be unlocked, some gifts are not available yet, etc) |
bool CanPlayAnotherRound() |
False, if the game is over, otherwise, the game is able to be played again (PrizeWheel: can spin, TreasureHunt: there are closed slots that can be opened, etc) |
void TryPlayingRound() |
Execute the next round if possible (e.g. there are free retries or enough currency to purchasable another chance) |
void StartRound () |
Starts a Retry (PrizeWheel: Spin, TreasureHunt: open a closed slot) |
void CancelRound () |
A round was requested, but the controller didn't allow it (not enough currency or not available options) |
MiniGame_Reward GetRandomReward() |
Selects a random reward from the mRewards array by using their probabilities. Can also return null if there are no more rewards or there are more choices than rewards (i.e. elements that don't contain a reward) |
int NumChoices() |
All the possible options (TreasureHunt: Num of remaining closed chests) |
void SetRewardPriority(RewardName, Probability) |
Assigns a Probability to the reward. The reward can be in the mRewards list if the game has been initialized or as a child of _Reward in the Hierarchy |
void EnableGameObject(GameObject go) |
This functions are used in the NGUI prefabs to enable objects from the Button's OnClick |
void DeactivateGameObject(GameObject go) |
This functions are used in the NGUI prefabs to disable objects from the Button's OnClick |
Created with the Personal Edition of HelpNDoc: Single source CHM, PDF, DOC and HTML Help creation