//If the user stays on the number long enough without changing void TimerEnded() { if (amount.isActiveAndEnabled) { Debug.Log("Timer Finished"); int num = int.Parse(amount.text); nRS.SetNumber(num); nRS.ReadNumber(); } }
//Gets the int to be read out to the user public void ReadBalance() { nRS = FindObjectOfType <NumberReaderScript>(); string temp = playerCoins.text; temp = Regex.Replace(temp, "Coins: ", ""); playerCoins.GetComponentInParent <Button>().Select(); int i = int.Parse(temp); nRS.SetNumber(i); nRS.ReadNumber(); }
//Checks if the result is the same public void CheckWinner() { List <string> betNums = sBI.GetSavedNums(); string line; int saveNum; int count = 0; int betNum = 0; int numbers = 0; int winNum = rWS.rouletteValue; //Add file data to betonNum list foreach (string s in betNums) { //Checks if the line length is 2 or less meaning its a number e.g. 0 - 36 if (s.Length <= 2) { saveNum = int.Parse(s); betonNum.Add(saveNum); if (numbers == 0) { typeIndex.Add(betonNum.Count - 1); } numbers++; } //Gets the bet type name from the file else { betType.Add(s); betNum++; numbers = 0; } count++; } count = 0; //Loops through the values in betonNum to check if it contains the winning number foreach (int i in betonNum) { if (i == winNum) { //Saves the index of the winning number inside the betonNum list winIndex.Add(betonNum.IndexOf(i)); int smallest = 0; //Finds the bet type related to the winning number by comparing indexes of the winning number to the //index of the first number for the new bet, the closest index means it must be from that bet type for (int j = 0; j < typeIndex.Count; j++) { int placeHolder = winIndex[winIndex.Count() - 1] - typeIndex[j]; //If its the first loop then save the values if (j == 0) { smallest = placeHolder; //If there is more than 1 bet that covers the winning number then count will have increased meaning the next bettype in the list is saved type.Add(""); type[count] = (betType[count]); saveIndex.Add(0); } //Checks if the smallest bettype index is smaller than the next index else if (placeHolder < smallest && placeHolder >= 0) { smallest = placeHolder; type.Add(betType[j]); saveIndex.Add(j); } } //If the winning number was found winner = true; count++; } } string path = "/balandamount.txt"; StreamReader reader = new StreamReader(Application.persistentDataPath + path); count = 0; //Add the balance and bet amount to betInfo while ((line = reader.ReadLine()) != null) { betInfo.Add(line); count++; } reader.Close(); string bal = betInfo[count - 2]; string lastAmount = betInfo[count - 1]; //Get back only the numbers in bal bal = Regex.Replace(bal, "[^0-9.]", ""); int balance = int.Parse(bal); nRS.SetNumber(winNum); nRS.ReadNumber(); colourRed = nRS.SetColour(winNum); //If the player won if (winner) { //Loops for each time the winning number was found for (int i = 0; i < type.Count(); i++) { int.TryParse(betInfo[saveIndex[i] + 2], out int amount); balance = wP.GetWinnings(type[i], balance, amount); } rWS.Winner(winNum); if (!tutorial) { wP.ResetFile(balance); } else { wP.SetBal(balance); } } //If they lost else { rWS.Loser(winNum); wP.SetBal(balance); } dD.Destroy(); soundCount = 0; }
//Plays the sound for the number or outside bet selected public void CountdownFinished() { //Wait until other audio has finished if (audioSource.isPlaying || nums.isPlaying) { Debug.Log(audioSource.isPlaying); StartCoroutine(StartCountdown(0.1f)); } else { btn = EventSystem.current.currentSelectedGameObject.GetComponent<Button>(); audioSource.pitch = 1f; audioSource.panStereo = 0f; string temp = btn.name; //Plays a number if (inside && audioSource.isActiveAndEnabled) { num = btn.GetComponentInChildren<TMP_Text>().text; int i = int.Parse(num); nRS.SetNumber(i); nRS.ReadNumber(); } //Plays an outside bet name else if (audioSource.isActiveAndEnabled) { int count = 0; switch (temp) { case "1st_Column": count = 7; break; case "2nd_Column": count = 8; break; case "3rd_Column": count = 9; break; case "1st_Third": count = 0; break; case "2nd_Third": count = 1; break; case "3rd_Third": count = 2; break; case "Evens": count = 3; break; case "Odds": count = 4; break; case "Blacks": count = 5; break; case "Reds": count = 6; break; case "1_To_18": count = 10; break; case "19_To_36": count = 11; break; default: Debug.Log("naming error"); break; } audioSource.PlayOneShot(outside[count]); } //Saves the button to be accessed on double tap sB.SaveButton(btn); } }
//Starts a countdown to check if the button is still in focus to determine whether the sound is played or not public IEnumerator StartCountdown(float f) { int count = 0; if (clips.Length == 4) { count++; } yield return(new WaitForSeconds(f)); for (int i = 0; i < clips.Length * 2; i++) { if (!numReader.isPlaying) { if (!read) { read = true; switch (count) { case 0: textName = "RoundsPlayed"; break; case 1: textName = "BetsMade"; break; case 2: textName = "AWon"; break; case 3: textName = "ALost"; break; case 4: textName = "Profit"; break; } statName = GameObject.Find(textName).GetComponent <Text>(); if (statName.text.Contains("Losses")) { source.PlayOneShot(clip); } else { if (clips.Length == 4) { source.PlayOneShot(clips[count - 1]); } else { source.PlayOneShot(clips[count]); } } count++; yield return(new WaitForSeconds(0.8f)); } else { switch (count) { case 1: textName = "RP"; break; case 2: textName = "BM"; break; case 3: textName = "AW"; break; case 4: textName = "AL"; break; case 5: textName = "Pt"; break; } stat = GameObject.Find(textName).GetComponent <Text>(); num = stat.text; num = Regex.Replace(num, "[^0-9]", ""); int n = int.Parse(num); nRS.SetNumber(n); nRS.ReadNumber(); yield return(new WaitForSeconds(0.4f)); read = false; } } else { yield return(new WaitForSeconds(0.1f)); i--; } } }