- Home /
 
Need help with generating random Multiplier,Need help with generating random multipliers
Hello!
So I'm making a slot machine type of game, and I am trying to make it so that when the player hits the button to play, the game picks a random multiplier from a list of numbers based on what the multiplier randomizer rolled.
So for instance: Play hits button, the game rolls a 66 out of 100, that means it picks a multiplier from a certain set of numbers and then uses that number to multiply their bet by. So if the player bet $1 and the multiplier that was rolled was a 4. The player wins $4 dollars.
The problem I'm having is getting the game to find that multiplier to do the math with the bet amount, here's the code I have so far.
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class GameController : MonoBehaviour
 {
     public Button playButton;
     public Button increaseButton;
     public Button decreaseButton;
 
     //public int[] thirtyPercent = new int[1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
     //public int[] fifteenPercent = new int[12, 16, 24, 32, 48, 64];
     //public int[] fivePercent = new int[100, 200, 300, 400, 500];
 
     //public float thirtyRandom = Random.Range(0, (thirtyPercent.length));
     //public float fifteenRandom = Random.Range(0, (fifteenPercent.length));
     //public float fiveRandom = Random.Range(0, (fivePercent.length));
 
     //public float randomThirty = thirtyPercent[thirtyRandom];
     //public float randomFifteen = fifteenPercent[fifteenRandom];
     //public float randomFive = fivePercent[fiveRandom];
 
     private static float bAmount;
     private static float cAmount;
     private static bool playGame;
 
     public float gameMultiplier;
     public float multiplyAmount;
 
     // Start is called before the first frame update
     void Start()
     {
 
     }
 
     // Update is called once per frame
     void Update()
     {
         bAmount = BetController.betAmount;
         cAmount = PlayButton.creditAmount;
         playGame = PlayButton.playingGame;
 
         if(playGame == true)
         {
             StartGame();
         }
     }
 
     public void StartGame()
     {
         playButton.interactable = false;
         increaseButton.interactable = false;
         decreaseButton.interactable = false;
         TimeToPlay();
     }
 
     public void StartOver()
     {
         playGame = false;
         playButton.interactable = true;
         increaseButton.interactable = true;
         decreaseButton.interactable = true;
     }
 
     public void TimeToPlay()
     {
         gameMultiplier = Random.Range(0, 100);
         //Debug.Log("Your Multiplier is " + gameMultiplier);
 
         if (gameMultiplier <= 49)
         {
             Debug.Log("You Won " + bAmount);
             StartOver();
         }
         else if (gameMultiplier <= 79)
         {
             Debug.Log("You Won " + bAmount);
             StartOver();
         }
         else if (gameMultiplier <= 94)
         {
             Debug.Log("You Won " + bAmount);
             StartOver();
         }
         else if (gameMultiplier <= 100)
         {
             Debug.Log("You Won " + bAmount);
             StartOver();
         }
     }
 }
 
               I've been trying to find help on this for a bit, but can't seem to find anything. If I could find some help from anyone that'd be fantastic!
Your answer
 
             Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Generate a big digit with only 1 2 3 and 4,How to generate a big number that only countains 0 to 3 2 Answers
How Precise is Random.Range? 1 Answer
Non-repeating random number generator crashing unity 1 Answer
How to make enemy prefab spawn at random times between 1.0f to 10.0f. 1 Answer