Slot Machine

Prerequisites

  1. The Slot Machine component is developed on top of MAS SDK. Make sure MAS SDK is imported and configured in your project before starting the integration. Download MAS SDK from here.
  2. The Slot Machine component supports Unity LTS versions from 2019 and above.
  3. The Slot Machine component is developed with Unity UI, and games developed using other UI system might require some adaptations.
  4. For proper rendering of the Slot Machine component UI, the canvas in which the component renders should have Screen Match mode set to “Match Width Or Height” and the match value should be 0.5. If the canvas has different settings, the UI system might require some changes based on the orientation of the game.
  5. The Slot Machine components will only be available to your project after it is enabled by CSM team. Please send your request with AppKey of MAS to this email: cs@yodo1.com

1. Download the Unity Plugin.

2. Integrate the SDK into your project

  • Open Unity project and import the Unity package. Double click on the compressed package icon. The files will populate automatically as illustrated below.

  • The following file structure in the project view can be seen after successfully importing the plugin.

3. Initialize the Slot Machine

Initialize the Slot Machine components only after successful initialization of MAS SDK and make sure you place it under the Canvas element for displaying the UI properly.

Place the prefab of component under your game’s main Canvas, drag and drop the prefab of component into the scene. Prefab path is: Assets/Yodo1/Components/Resources/Yodo1Components.

Ad placement for the slot machine rewarded video can be added. This is optional.

Sample codes is as follows:

				
					using UnityEngine;
using Yodo1.Components;
using Yodo1.MAS;

public class Sample : MonoBehaviour
{
	public GameObject yodo1Components;
	
	private void Start()
	{
	
	    Yodo1U3dMasCallback.OnSdkInitializedEvent += (success, error) =>
	    {
	        if (success)
	        {
	            //TODO - Initialize slot machine
	            if (yodo1Components != null)
	            {
	                yodo1Components.SetActive(true);
	            }
	        }
	    };
	    Yodo1U3dMas.InitializeSdk();
	}
}
				
			

4. Set reward event of the Slot Machine

Set the event Yodo1Components.Instance.SlotMachine.onSlotReward to receive the reward event. Sample code is as follows:

				
					using UnityEngine;
using Yodo1.Components;
using Yodo1.MAS;
    
public class Sample : MonoBehaviour
{
	public GameObject yodo1Components;
	
	private void Start()
	{
	
	    Yodo1U3dMasCallback.OnSdkInitializedEvent += (success, error) =>
	    {
	        if (success)
	        {
	            //TODO - Initialize the slot machine
	            if (yodo1Components != null)
	            {
	                yodo1Components.SetActive(true);
	            }
	        }
	    };
	    Yodo1U3dMas.InitializeSdk();
	}
	
	private void OnEnable()
	{
	    SlotMachine.onSlotReward += this.OnSlotRewardReceive;
	}
	
	private void OnDisable()
	{
	    SlotMachine.onSlotReward -= this.OnSlotRewardReceive;
	}
	    
	/// <summary>
	/// When the slot machine get a bonus
	/// </summary>
	/// <param name="count"></param>
	private void OnSlotRewardReceive(int count)
	{
	    //TODO
	    //You can add your coin or crystal here
	}
}
				
			

5.Customize the Component

5.1 Custom Configuration

The slot machines provide multiple customizable configurations, the path: Assets/Yodo1/Components/Resources/SlotConfig

Key Description
freeSlotChange Players can have one free change (without ads) to play with the slot machine each day
currency Name of the currency by which user will be rewarded
slotAccessCount Number of times user can access the slot machine per day
slotTextures Textures displayed in Slot, the default 5, sorted in the order of rarity(From low to high)
slotAnyTexture A picture shown as a question mark in Slot to show random or unknown items
slotClickSound Click on the play button sound
iconSetSound The sound of pictures turning
winSound Sound effects when receiving rewards
loseSound Sound effects for no reward or failure
goldAddedSound Get the sound for gold display pop-ups
rewardQuantity The number of reward levels in Slot. The current number of rewards is 7 (Can not be chenged). In order of reward level from highest to lowest. Currently, the game component only supports one type of reward
rewardProbability The probability of the occurrence of the corresponding reward level, the number and the reward level are 7 (can not be changed). The sum of the reward probabilities is less than or equal to 1.0, and the difference between the sum and 1.0 is the probability of not getting the reward

If the user gets high rarity image(crocodile in the default design) in all the three slots, user will receive highest reward(5000 in the default design). If user gets high rarity image in two slots then user receives second highest reward. If user gets high rarity image in one slot then user receives third highest reward. The reward amount reduces based on the rarity of image the user gets in the slots as shown below.

5.2 Customize the Background Frame

The entire background of the slot machine can be modified in accordance of the game UI design in the prefab SlotMachinePopUp.

5.3 Customize the currency

The currency of the slot machine can also be customized. The default slot machine has the currency as gold. This has to be changed in the design and the texts as well.

5.4 Customize the pop ups

The pop ups like reward pop up, Currency added pop up, Ad failed pop up can be customized. There are separate prefabs for each one and this can be modified in accordance to the UI of the game.

5.5 Customize the localization language

The localization language manager path is Assets/Yodo1/Components/Common/Script/TextManager.cs.

				
					texts.Add("slot_machine",  "slot machine");
texts.Add("no_reward","You didn't win anything! Try again for better luck!");
texts.Add("congratulation_coins", "Congratulations on getting {0} gold");
texts.Add("left_times",  "Current remaining {0} times");
texts.Add("watch_video",  "WATCH VIDEO \n TO PLAY");
texts.Add("press_to_play",  "PRESS TO PLAY");
texts.Add("ad_failed",  "Advertisement failed to play.");
texts.Add("ok",  "OK");
texts.Add("try_again",  "Try Again");
texts.Add("cancel",  "Cancel");
texts.Add("slot_title",  "win up to 5000 gold!");
texts.Add("done",  "Done");
				
			

5.6 The Slot Machine component structure

The directory path of the Slot Machine component is Assets/Yodo1/Components/SlotMachine

  • Animation
  • Animator
  • Font
  • Music
  • Plugins Third-party plug-ins (Using LitJson)
  • Prefab
  • Sample
  • Script
  • Texcure
CONTENTS