block-quote On this pagechevron-down
copy Copy chevron-down
Basics chevron-right gears Engine Systemschevron-right gamepad-modern Gameplay Systemsdice-d20 Random Events ManagerPresented by IRandomEventsManager interface, this system works with random events and provides such mechanisms like Bad Luck Protection and Good Luck Protection for them.
To use this system, inject IRandomEventsManager interface into your class, as shown below:
Copy [ Inject ] private IRandomEventsManager randomEventsManager ; Parameters in inspector
possibleEvents – reference to scriptable object which contains a collection of possible random events.
Available methods
Copy bool DoEventAttempt ( string eventType ) This method attempts to fire random event with certain eventType . Returns true if attempt was successful and event has occurred.
Example:
Copy if ( randomEventsManager . DoEventAttempt ( " SuperRareItemDrop " ))
{
Debug . Log ( " Super rare item dropped! " );
}
Copy bool DoEventAttempt ( RandomEventInfo eventInfo ) This method attempts to fire random event described in eventInfo . Returns true if attempt was successful and event has occurred.
Example:
Copy if ( randomEventsManager . DoEventAttempt ( superRareEventInfo ))
{
Debug . Log ( " Super rare item dropped! " );
} This method resets random event chance (cancels all modifiers applied by Bad Luck Protection and Good Luck Protection logics).
Example:
This method returns current chance of eventType event occurance.
Example: