Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Stedd committed Aug 5, 2016
1 parent 468d65a commit 1fa4f91
Show file tree
Hide file tree
Showing 54 changed files with 808 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Assets/_Prefabs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/_Prefabs/Sphere.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/_Prefabs/Sphere.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/_Scenes.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/_Scenes/Credits.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/_Scenes/Credits.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/_Scenes/Game.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/_Scenes/Game.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/_Scenes/Main Menu.unity
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/_Scenes/Main Menu.unity.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/_Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions Assets/_Scripts/Hazard_zone.cs
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);
}

}
12 changes: 12 additions & 0 deletions Assets/_Scripts/Hazard_zone.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

61 changes: 61 additions & 0 deletions Assets/_Scripts/Instantiator.cs
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 ();

}
}
}
}
12 changes: 12 additions & 0 deletions Assets/_Scripts/Instantiator.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Assets/_Scripts/Load_Scene.cs
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);
}
}
}
}
12 changes: 12 additions & 0 deletions Assets/_Scripts/Load_Scene.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

72 changes: 72 additions & 0 deletions Assets/_Scripts/Main.cs
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 ();

}
}
12 changes: 12 additions & 0 deletions Assets/_Scripts/Main.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

55 changes: 55 additions & 0 deletions Assets/_Scripts/Main_Cyclic.cs
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);
}
}
}
*/

}
12 changes: 12 additions & 0 deletions Assets/_Scripts/Main_Cyclic.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1fa4f91

Please sign in to comment.