Changes and Extras:
-Guesses random number now
-17 ‘Magic Numbers’ resulting in phrases including an ‘Easter Egg’ from holding down a certain key
-Opted out of letting the user pick the range so there’s a better chance of them picking a ‘Magic Number’
using UnityEngine;
using System.Collections;
public class NumberWizards : MonoBehaviour {
// Use this for initialization
int max;
int min;
int guess;
void Start () {
StartGame ();
}
void StartGame () {
max = 1000;
min = 1;
guess = 500;
print ("========================");
print ("Welcome to Number Wizard");
print ("Pick a number in you head, but don't tell me!");
print ("The highest number you can pick is " + max);
print ("The lowest number you can pick is " + min);
print ("Is the number higher or lower than " + guess + "?");
print ("Up arrow = higher, down = lower, return = equal");
max = max + 1;
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.UpArrow)) {
min = guess;
NextGuess();
} else if (Input.GetKeyDown (KeyCode.DownArrow)) {
max = guess;
NextGuess();
} else if (Input.GetKeyDown (KeyCode.Return)) {
print("I Won! Your number was " + guess + "!");
EasterEgg ();
MagicNumbers();
StartGame();
}
}
void NextGuess () {
guess = Random.Range (min, max);
// guess = (max + min) / 2;
print("Higher or lower than " + guess + "?");
print ("Up arrow = higher, down = lower, return = equal");
}
void MagicNumbers () {
if (guess == 0) {
print ("Zero to Hero, you broke the game!");
} else if (guess == 1) {
print ("One is the loneliest number...");
} else if (guess == 2) {
print ("Two can be as bad as one but the lonelist number is the number one...");
} else if (guess == 3) {
print ("So, which one of you is the third wheel? Must be the one who brought the pie.");
} else if (guess == 4) {
print ("Death");
} else if (guess == 7) {
print ("So many things associated with this number. A little unoriginal, no?");
} else if (guess == 17) {
print ("The number of 'Magic Numbers' including this message and the 'Easter Egg' for breaking the game");
} else if (guess == 21) {
print ("Blackjack!");
} else if (guess == 42) {
print ("42, The Answer to Everything. Or perhaps you just like baseball.");
} else if (guess == 69) {
print ("Naughty or just a Cancer ♋ ?");
} else if (guess == 500) {
print ("Right down the middle.");
} else if (guess == 666) {
print ("The number of the Beast or 'everything goes smoothly'");
} else if (guess == 777) {
print ("Lucky Sevens! Unfortunately the slot machines don't have to guess your number.");
} else if (guess == 1000) {
print ("You've reached the roof, now Raise it. Caution: Possibility of the Roof being on fiya.");
} else if (guess <= 100) {
print ("How low can you go?");
} else if (guess >= 900) {
print ("Can you bring it to the top?");
} else {
print ("Thanks for playing");
}
}
void EasterEgg () {
if (Input.GetKey (KeyCode.Z)) {
guess = 0;
}
}
}