Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class NumberGuess : MonoBehaviour {
- public int max;
- public int min;
- public int guess;
- void Start () {
- StartGame ();
- }
- // 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 ("Κέρδισες");
- StartGame ();
- }
- }
- void StartGame (){
- print ("My nymber Game");
- print ("Διάλεξε έναν αριθμό αλλα μην πεις ποιος είναι");
- print ("Μέγιστος αριθμός: " + max + ", ελάχιστος αριθμός: " + min);
- NextGuess ();
- }
- void NextGuess(){
- //max = max + 1;
- guess = (max + min) / 2;
- print ("Ο αριθμός είναι μεγαλύτερος του " + guess +";");
- print ("Αν είναι μεγαλύτερος πάτα το πάνω βέλος, εάν είναι μικρότερος πάτα το κάτω βέλος, εάν τον βρήκα πάτα το Enter");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement