Candy Smith
HomeGeneral Info
Bubble Shooter Toolkit
Bubble Shooter Toolkit
  • Getting started
    • Specification
  • TUTORIALS
    • Video Tutorials
    • Level EDITOR
    • How to set or create in-game tutorials
    • How to expand map and add new points
    • Adding new ball
    • Coins SHOP
    • Ads setup
      • Ads mediation (Levelplay/IronSource) setup
      • Admob setup
      • Unit ads legacy setup
      • Ads settings
      • Add rewarded ads button
    • Settings
      • Game settings
      • Gameplay settings
      • Boost settings
      • Shop settings (IAP)
      • Daily bonus settings
      • Lucky spin settings
      • Powerup settings
      • Target settings
      • Debug Settings
  • Scripts
    • Scripts Overview
      • Ball spawner
      • EventManager
      • GetNeighbours
      • Resource system
      • Playable item types
Powered by GitBook
On this page
  1. Scripts
  2. Scripts Overview

Resource system

ResourceObject.cs is an abstract class that represents a game resource. It includes properties and methods for managing the resource's value and for notifying other parts of the game when the resource's value changes. The resource data stores in player prefs.

LoadPrefs(): A method that loads the resource's value from PlayerPrefs.

Add(int amount): A method that increases the resource's value by a specified amount and saves the new value to PlayerPrefs. It also triggers the OnResourceUpdate event.

Set(int amount): A method that sets the resource's value to a specified amount and saves the new value to PlayerPrefs. It also triggers the OnResourceUpdate event.

Consume(int amount): A method that decreases the resource's value by a specified amount, if there is enough of the resource. It saves the new value to PlayerPrefs and triggers the OnResourceUpdate event.

OnResourceChanged(): A private method that triggers the OnResourceUpdate event.

GetResource(): A method that returns the current value of the resource.

IsEnough(int targetAmount): A method that checks if the resource's value is greater than or equal to a specified amount.

In example you could get coins value like this

ResourceObject coins;  // scriptable object which represents coins in this example

coins.LoadPrefs();  // init value from player prefs
int currentCoins = coins.GetResource();  // getting current coins amount

Last updated 1 year ago