Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // NumberWizard.cs
- // ================
- using UnityEngine;
- using System.Collections;
- using UnityEngine.UI;
- public class NumberWizard : MonoBehaviour
- {
- // Use this for initialization
- int max;
- int min = 1;
- int guess;
- public int maxGuessesAllowed;
- public Text text;
- //Start the game
- void Start ()
- {
- StartGame();
- }
- // Start the game
- void StartGame ()
- {
- NextGuess();
- }
- //Guess a higher number
- public void GuessHigher()
- {
- min = guess;
- NextGuess();
- }
- //Guess a lower number
- public void GuessLower()
- {
- max = guess;
- NextGuess();
- }
- public void SetFields(){
- RangeSelection RA = gameObject.AddComponent("RangeSelection") as RangeSelection;
- this.max = RA.maximum;
- this.maxGuessesAllowed = RA.max_GuessesAllowed;
- }
- //Guess a new number
- void NextGuess()
- {
- RangeSelection RA = gameObject.AddComponent("RangeSelection") as RangeSelection;
- print ("RA Max:" + RA.maximum);
- print ("Current Max:" + max);
- print ("Current # of Guesses:" + maxGuessesAllowed);
- guess = Random.Range(min,max+1);
- print ("Guess: " + guess) ;
- text.text = guess.ToString();
- maxGuessesAllowed--;
- // if(maxGuessesAllowed <= 0)
- // {
- // Application.LoadLevel("Win");
- // }
- }
- }
- // RangeSelection.cs
- // ================
- using UnityEngine;
- using System.Collections;
- public class RangeSelection : MonoBehaviour {
- // Use this for initialization
- public static int maximum = 500;
- public static int max_GuessesAllowed = 8;
- //Set the guessing range to 1-1000
- public void Range_1()
- {
- this.maximum = 1000;
- this.max_GuessesAllowed = 7;
- print ("Range1 called");
- }
- //Set the guessing range to 1-10000
- public void Range_2()
- {
- this.maximum = 10000;
- this.max_GuessesAllowed = 10;
- print ("Range1 called2");
- }
- //Set the guessing range to 1-100000
- public void Range_3()
- {
- this.maximum = 100000;
- this.max_GuessesAllowed = 15;
- print ("Range1 called3");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement