Advertisement
gntalakas

Untitled

Oct 25th, 2016
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.14 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class NumberGuess : MonoBehaviour {
  5.     public int max;
  6.     public int min;
  7.     public int guess;
  8.  
  9.     void Start () {
  10.         StartGame ();
  11.     }
  12.  
  13.     // Update is called once per frame
  14.     void Update () {
  15.         if(Input.GetKeyDown(KeyCode.UpArrow) ) {
  16.             min = guess;
  17.             NextGuess ();
  18.         } else if(Input.GetKeyDown(KeyCode.DownArrow) ) {
  19.             max = guess;
  20.             NextGuess ();
  21.         } else if(Input.GetKeyDown(KeyCode.Return) ) {
  22.             print ("Κέρδισες");
  23.             StartGame ();
  24.         }
  25.  
  26.     }
  27.  
  28.     void StartGame (){
  29.  
  30.         print ("My nymber Game");
  31.         print ("Διάλεξε έναν αριθμό αλλα μην πεις ποιος είναι");
  32.         print ("Μέγιστος αριθμός: " + max + ", ελάχιστος αριθμός: " + min);
  33.         NextGuess ();  
  34.     }
  35.  
  36.     void NextGuess(){
  37.         //max = max + 1;
  38.         guess = (max + min) / 2;
  39.         print ("Ο αριθμός είναι μεγαλύτερος του " + guess +";");
  40.         print ("Αν είναι μεγαλύτερος πάτα το πάνω βέλος, εάν είναι μικρότερος πάτα το κάτω βέλος, εάν τον βρήκα πάτα το Enter");
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement