Check it out. Here is my take on the Number Wizard.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NumberWizard : MonoBehaviour
{
int stack;
int buck;
int guess;
// Start is called before the first frame update
void Start()
{
StartGame();
}
/*Calls the Default Values for a New Game.
* Also Provides a New player with Instructions on How the game is played.
*
* Ignore This Line--> Testing out out different skills that I learned in C# basics course. <--Ignore this Line.*/
void StartGame()
{
//Starting Values
stack = 1000;
buck = 1;
guess = 500;
//Introduction and Instructions for Player
Debug.Log("Wad up Scrap, You ready for some Number Wizadry?");
Debug.Log("Imma need you to think of a digit, I don't tell me what it is.");
Debug.Log("Listen, You can't Pick nothin' higher than: " + stack);
Debug.Log("And While you at it can't be no lower than: " + buck);
Debug.Log("Press 'H' for Higer, Press 'L' for Lower and Press Enter if I'm Right. Simple, right?");
Debug.Log("........");
Debug.Log("You Ready?");
Debug.Log("........");
Debug.Log("One,Two..");
Debug.Log("One,Two..");
Debug.Log("One, Two, Five, Hop in the hot mess for the one time");
Debug.Log("Hey, real quick. Your number, higher or lower than: " + guess + "?");
stack = stack + 1;
}
// Update is called once per frame
void Update()
{
//Control Inputs for the player and it's result when activated.
if (Input.GetKeyDown(KeyCode.H))
{
Debug.Log("So Higher than: " + guess);
buck = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.L))
{
Debug.Log("So Lower than: " + guess);
stack = guess;
NextGuess();
}
else if (Input.GetKeyDown(KeyCode.Return))
{
Debug.Log("Bet, Your Number is: " + guess + " See, Told you I'm a Wizard!");
StartGame();
}
}
void NextGuess()
{
//A repetitive statement that is Printed after each selection by the player.
guess = (buck + stack) / 2;
Debug.Log("Is it: " + guess);
}
}