money-billMoney

Overview

The WalletService class is used to work with in-game currencies. Class location: Asset/KrolStudio/SwipeGunner/Scripts/Runtime/Services/WalletService/...

An instance of WalletService is created during game initialization in the GameInstaller and bound to the ProjectContext container. This makes the service globally available throughout the project.

Container.BindInterfacesTo<WalletService>().AsSingle();

WalletService is a service responsible for managing the player’s in-game currencies. It handles storing currency balances, modifying them, notifying subscribers about changes, and saving/loading player progress data.

circle-info

The class is used as a single source of truth for all currencies in the game.

Purpose

  • Store the amount of each currency

  • Modify currency balances (set, add, subtract)

  • Check if sufficient funds are available

  • Support purchase operations

  • Notify systems about currency changes

  • Save and load player progress

Implemented Interfaces

  • IWalletService — public API for working with currencies

  • IProgressReader — loading data from saved progress

  • IProgressSaver — saving player progress data

Adding a New Currency

To add a new currency to the game, you need to extend the CurrencyType enum by adding your custom currency type:

Use the walletService to add or retrieve amounts of your custom currency:

Default Value Setup

You can set the starting amount for your new currency in the DefaultPlayerProgress configuration asset. This allows you to define how much of the currency the player starts with.

Last updated