1. Trang chủ
  2. » Giáo án - Bài giảng

Lecture 48 number wizard code tủ tài liệu training

1 26 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 1
Dung lượng 44,55 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Trang 1

usingUnityEngine;

usingSystem.Collections;

public classNumberWizards : MonoBehaviour {

// Use this for initialization

intmax;

intmin;

intguess;

voidStart () {

StartGame();

}

voidStartGame () {

max = 1000;

min = 1;

guess = 500;

print ("========================");

print ("Welcome to Number Wizard");

print ("Pick a number in your head, but don't tell me!");

print ("The highest number you can pick is "+ max);

print ("The lowest number you can pick is " + min);

print ("Is the number higher or lower than "+ guess +"?");

print ("Up = higher, down = lower, return = equal");

max = max + 1;

}

// Update is called once per frame

voidUpdate () {

if (Input.GetKeyDown(KeyCode.UpArrow)) {

min = guess;

NextGuess();

}else if(Input.GetKeyDown(KeyCode.DownArrow)) {

max = guess;

NextGuess();

}else if(Input.GetKeyDown(KeyCode.Return)) {

print("I won!");

StartGame();

}

}

voidNextGuess () {

guess = (max + min) / 2;

print ("Higher or lower than "+ guess);

print ("Up = higher, down = lower, return = equal");

}

}

Find more atwww.CompleteUnityDeveloper.com

Ngày đăng: 17/11/2019, 07:35