My Number Wizard Greeting

Check out my version of the number wizard game

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class NumberWizard : MonoBehaviour
{
    int max; //Declaring variables to be accessible throughout the class
    int min;
    int guess;

    //Game guessing player's input from 1 to 1000
    void Start()
    {
        StartGame();

    }

    void StartGame()
    {
        max = 1000;
        min = 1;
        guess = 500;

        Debug.Log("Greetings, I am The Ancient Number Wizard of the Sea");
        Debug.Log("Choose a number between 1 to 1000 and I will guess what it is");
        Debug.Log("but THERE ARE RULES!");
        Debug.Log("Rule #1 : The highest number you can pick is " + max);
        Debug.Log("Rule #2 : The lowest number you can pick is " + min);
        Debug.Log("Now, CHOOSE");
        Debug.Log("Now traveler, reveal your number if it is higher than, lower than or exactly " + guess);
        Debug.Log("Higher (PRESS UP KEY) ");
        Debug.Log("Lower (PRESS DOWN KEY)");
        Debug.Log("You guess right! (PRESS ENTER KEY)");
        max = max + 1;
    }
    // Update is called once per frame
    void Update()
    {
        //Detect when the up arrow key is pressed down, Your guess is too low, number is higher than 500
        if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            min = guess;
            NextGuess();
        }

        //Detect when the down arrow key is pressed down, Your guess is too high, number lower than 500
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            max = guess;
            NextGuess();
        }

        //Detect when the Return key is pressed down, Your guess is exactly right
        else if (Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("VALIA, your number is " + guess);
            Debug.Log("Go Again?");
            StartGame();
        }
    }

    void NextGuess()
    {
        guess = (max + min) / 2;
        Debug.Log("Is your number higher or lower than " + guess);
    }
}


1 Like

Awesome Number Wizard greeting!

Funny and detailed ))) but from there you know the name of the gamer will be Valia ??

Privacy & Terms