Unit 3 Activity 2 - Writing our first script
using UnityEngine;
using System.Collections;
public class NumberWizard : MonoBehaviour {
int max;
int min;
int guess;
// Use this for initialization
void Start () {
max = 1001;
min = 1;
guess = Random.Range (1, 1001);
print ("Welcome To Number Wizard!!!");
print ("Choose any whole number, but don't tell me!");
print ("The highest number you can choose is " + max);
print ("The lowest number you can choose is " + min);
print (" Is your number higher or lower than " + guess);
print ("Press up_arrow if higher, down_arrow if lower, and enter for equal");
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown (KeyCode.UpArrow)) {
print ("Up arrow pressed");
min = guess;
guess = Random.Range(min,max);
print ("Is it higher or lower than " + guess);
print ("Press up_arrow if higher, down_arrow if lower, and enter for equal");
}if (Input.GetKeyDown (KeyCode.DownArrow)) {
print ("Down arrow pressed");
max = guess;
guess = Random.Range(min,max);
print ("Is it higher or lower than " + guess);
print ("Press up_arrow if higher, down_arrow if lower, and enter for equal");
}if (Input.GetKeyDown (KeyCode.Return)) {
print ("I win!");
Start ();
}
}
}
Unit 3: Activity 3
https://onedrive.live.com/redir?resid=D9D6C310A52C8A66!160&authkey=!AGf6f_niwTLo3vo&ithint=folder%2c
Rich Activity: Ship Shooter
https://onedrive.live.com/redir?resid=D9D6C310A52C8A66!281&authkey=!ACd6C6qptBhkRZ4&ithint=folder%2chtml