Skip to content

Scripts for Shop

Show Offer Popup

A script that displays a random Available Offer as a Popup under these conditions:

  1. Level-based Trigger: The popup appears every 5 levels.
  2. Shop Exit Trigger: Activated when a player exits the shop without making any purchases.

This setup is just an example, and you are encouraged to modify the logic to suit your game's needs. Consider implementing a cooldown between popups to avoid overwhelming players with frequent offers.

Show Offer Script Screenshot

The RUN METHOD node in the script triggers a C# method using reflection. Specify the full path to the static method you wish to execute in the input port, such as: BalancyShop.DemoUI.ShowRandomOffer.

C# Method Implementation:

Here's the complete code for the ShowRandomOffer method:

using Balancy.Data.SmartObjects;
using Balancy.Models.GameShop;
using UnityEngine;

namespace BalancyShop
{
    public class DemoUI : MonoBehaviour
    {
        ...

        public static void ShowRandomOffer()
        {
            var allOffers = Balancy.LiveOps.GameOffers.GetActiveOffers();
            if (allOffers.Length <= 0)
                return;

            int rndIndex = Random.Range(0, allOffers.Length);
            var rndOffer = allOffers[rndIndex];

            _instance?.ShowOffer(rndOffer);
        }
    }
}

Weekend Sale Event

For special events like a weekend sale, we've crafted a script that offers thrice the usual amount of Gold for the same Gem price.

Weekend Sale Script Screenshot:

Sale Script Screenshot

To implement the sale effectively, ensure to set up all the necessary components thoroughly. For more details on setting up sales, refer to our guide here