-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class Hazard_zone : MonoBehaviour { | ||
|
||
|
||
void OnTriggerEnter(Collider other){ | ||
//Destroy ball | ||
Destroy (other.gameObject); | ||
//Generate new ball on collission | ||
if (! (GameObject.FindWithTag("GameController").GetComponent<Main>().winConditionMet)) { | ||
FindObjectOfType<Instantiator> ().generate (); | ||
} | ||
//announce hazard name to Main script to update score | ||
FindObjectOfType<Main> ().updateScore (gameObject.name); | ||
} | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class Instantiator : MonoBehaviour { | ||
|
||
//Load prefab | ||
public GameObject preFab; | ||
//Temp gameobject for setting new object configuration | ||
private GameObject newObject; | ||
//InstantiateID | ||
public string instantiateName; | ||
public int instantiateID; | ||
//Position, rotation, velocity | ||
public Vector3 positionVec, rotationVec, velocityVec; | ||
//TEST | ||
private float spawnRate, nextSpawn; | ||
|
||
public int gridSizeX, gridSizeY; | ||
|
||
void Start(){ | ||
// nextSpawn = 0.0f; | ||
// spawnRate = 0.7f; | ||
generate (); | ||
} | ||
|
||
void Update(){ | ||
if (Input.GetKeyDown("mouse 0")) { | ||
generate (); | ||
//generateCluster (); | ||
} | ||
|
||
// if (Time.time > nextSpawn) { | ||
// generate (); | ||
// nextSpawn = Time.time + spawnRate; | ||
// } | ||
} | ||
|
||
public void generate () { | ||
//Generate new object | ||
newObject = (GameObject)Instantiate (preFab, positionVec, Quaternion.Euler(rotationVec)); | ||
//Set new object ID | ||
newObject.name = instantiateName + instantiateID.ToString (); | ||
//Set new velocity for rigid body for object | ||
newObject.GetComponent<Rigidbody> ().velocity = velocityVec; | ||
//Increase ID number for next object | ||
instantiateID += 1; | ||
} | ||
|
||
void generateCluster () | ||
{ | ||
for (int i = -gridSizeX / 2; i <= gridSizeX / 2; i++) | ||
{ | ||
for (int j = -gridSizeY / 2; j <= gridSizeY / 2; j++) | ||
{ | ||
GameObject newBall = (GameObject)Instantiate (preFab, new Vector3 (i * 2, j * 2, 0), Quaternion.Euler (rotationVec)); | ||
newBall.name = i.ToString () + "," + j.ToString (); | ||
|
||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
using System.Collections; | ||
|
||
public class Load_Scene : MonoBehaviour { | ||
|
||
public int sceneIndex; | ||
private Color tempColor; | ||
|
||
void Start(){ | ||
changeColor (Color.blue); | ||
} | ||
|
||
void OnMouseEnter(){ | ||
changeColor (Color.yellow); | ||
} | ||
|
||
void OnMouseExit(){ | ||
changeColor (Color.blue); | ||
} | ||
|
||
void changeColor(Color color){ | ||
tempColor = gameObject.GetComponent<Renderer> ().material.color; | ||
tempColor = color; | ||
gameObject.GetComponent<Renderer> ().material.color = tempColor; | ||
} | ||
|
||
void OnMouseOver() { | ||
if (Input.GetKeyDown("mouse 0")){ | ||
if (gameObject.name == ("Quit_button")){ | ||
Application.Quit(); | ||
} | ||
else{ | ||
SceneManager.LoadScene(sceneIndex); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
using System.Collections; | ||
|
||
public class Main : MonoBehaviour { | ||
|
||
//Bind text gameobjects for manipulation | ||
public GameObject playerScoreText, aiScoreText, announceText; | ||
|
||
//Score variables | ||
public int playerScore, aiScore; | ||
private float winScore = 2; | ||
|
||
//Timer | ||
private float tempTime, showWinTextTime = 5; | ||
public bool winConditionMet; | ||
|
||
void Start (){ | ||
|
||
//Reset scores | ||
winConditionMet = false; | ||
playerScore = 0; | ||
aiScore = 0; | ||
|
||
//Update score text | ||
announceText.GetComponent<TextMesh> ().text = ""; | ||
playerScoreText.GetComponent<TextMesh> ().text = "Player Score: " + playerScore.ToString (); | ||
aiScoreText.GetComponent<TextMesh> ().text = "A.I Score: " + aiScore.ToString (); | ||
} | ||
|
||
void Update () { | ||
|
||
//Back to lobby if escape is pressed | ||
if(Input.GetKey("escape")){SceneManager.LoadScene(0);} | ||
|
||
//Winning condition | ||
|
||
if (playerScore >= winScore && !winConditionMet) { | ||
winCondition ("Player Wins"); | ||
} | ||
|
||
if (aiScore >= winScore && !winConditionMet) { | ||
winCondition ("A.I Wins"); | ||
} | ||
|
||
if (Time.time > tempTime && winConditionMet) { | ||
SceneManager.LoadScene("Credits"); | ||
} | ||
|
||
} | ||
|
||
public void winCondition (string winnerName) | ||
{ | ||
winConditionMet = true; | ||
tempTime = Time.time + showWinTextTime; | ||
announceText.GetComponent<TextMesh> ().text = winnerName; | ||
} | ||
|
||
//Modify score based on announcement from hazards | ||
public void updateScore(string hazardName){ | ||
if (hazardName == "West_wall") { | ||
aiScore +=1; | ||
} | ||
if (hazardName == "East_wall") { | ||
playerScore +=1; | ||
} | ||
//Update text | ||
playerScoreText.GetComponent<TextMesh> ().text = "Player Score: " + playerScore.ToString (); | ||
aiScoreText.GetComponent<TextMesh> ().text = "A.I Score: " + aiScore.ToString (); | ||
|
||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class Main_Cyclic : MonoBehaviour { | ||
|
||
public GameObject ball; | ||
GameObject test; | ||
Vector3 zeroVec = new Vector3(0,5,0); | ||
public float x=1.0f, y=1.0f, z=1.0f; | ||
public string ballName; | ||
public int gridSizeX, gridSizeY; | ||
//Quaternion zeroRot = new Quaternion(0.0f,0.0f,0.0f); | ||
|
||
//Use this for initialization | ||
void Start () { | ||
|
||
gridSizeX += 1; | ||
gridSizeY += 1; | ||
|
||
for (int i=-gridSizeX/2; i<gridSizeX/2; i++) { | ||
for (int j=-gridSizeY/2; j<gridSizeY/2; j++) { | ||
GameObject newBall = (GameObject)Instantiate (ball, new Vector3 (i * 2, j * 2, 0), Quaternion.Euler (zeroVec)); | ||
newBall.name = i.ToString()+","+j.ToString(); | ||
//namelist. | ||
//ball.AddComponent<Rigidbody>(); | ||
//ball.GetComponent<Rigidbody>() = 50; | ||
//test = GameObject.Find("Ball8"); | ||
|
||
} | ||
} | ||
/* | ||
for (int x = 1; x<=5; x++) { | ||
test = GameObject.Find (x.ToString()+"(Clone)"); | ||
test.GetComponent<Transform> ().position = new Vector3 (Random.Range (0, 10), Random.Range (0, 10), Random.Range (0, 10)); | ||
Debug.Log ("DOne "+x.ToString()); | ||
} | ||
*/ | ||
} | ||
/* | ||
// Update is called once per frame | ||
void Update () { | ||
for (int a=; a<=10; a++) { | ||
Debug.Log (a.ToString()); | ||
test = GameObject.Find(a.ToString()); | ||
for (int b = 1; b<5; b++) { | ||
//test.GetComponent<Transform> ().localScale = new Vector3 (Random.Range (0, 10), Random.Range (0, 10), Random.Range (0, 10)); | ||
test.GetComponent<Rigidbody>().velocity = new Vector3(b,0,0); | ||
} | ||
} | ||
} | ||
*/ | ||
|
||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.