Greeting from CANADA

Hello folks,
Here is my first code in Unity!
I did some little changes based on my taste. I hope you like it!

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

public class NumberWizard : MonoBehaviour
{
    int max=1000;
    int min = 1;
    static System.Random Rnd = new System.Random();
    int guess;
    int counter=0;
    // Start is called before the first frame update
    void Start()
    {
        guess = Rnd.Next(min, max);
        print("Hello,  Welcome to my Numbers Wizard Game from CANADA!");
        Debug.Log("Now Pick a number between " + min + " and " + max );
        Debug.Log("I gonna guess the number you picked with a little help from you!");
        Debug.Log("I Guess the number you picked is: " + guess);
        Debug.Log("Now Push Up Arrow on your keyboard if the number is bigger than my guess, Push Down Arrow_" +
            " if it is Smaller than my guess and finally Push Enter if my guess is Correct");
        
    }


    // Update is called once per frame
    void Update()
    {
        if(Input.GetKeyDown(KeyCode.DownArrow))
        {
            //Debug.Log("Down arrow Pressed");
            max = guess;
            guess = Rnd.Next(min, max);
            counter += 1;
            //Debug.Log("The Lowest number is: " + min);
            //Debug.Log("The Highest number is: " + max);
            Debug.Log("I Guess you picked: " + guess + " Correct?!");
        }
        else if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            //Debug.Log("Up arrow Pressed");
            min = guess;
            guess = Rnd.Next(min, max);
            counter += 1;
            //Debug.Log("The Lowest number is: " + min);
            //Debug.Log("The Highest number is: " + max);
            Debug.Log("I Guess you picked: " + guess + " Correct?!");
        }
        else if(Input.GetKeyDown(KeyCode.Return))
        {
            Debug.Log("Horray! I Guessed it in " +counter+" attempt!");
        }
        
    }
}

Hi Arash, welcome to the community :slight_smile:

Extra kudos for applying the code fencing to your code - thank you :slight_smile:

Privacy & Terms