#pragma strict

public var spawnPoints:Transform[];
//var rigidbody: Rigidbody;
//var ballObj: Rigidbody;
public var ballObjects: Rigidbody[];
public var myTimer : float = 15.0;
public var score: int = 0;
public var spawnNum:int;
public var ballNum:int;
public var scoreText:GUIText;
public var scoreText2:GUIText;
scoreText.guiText.text = “You have jack shit”;
scoreText2.guiText.text = “You have jack shit”;
public var proj: Rigidbody;
var goodSound: AudioClip;

function Start() {
//spawnPoint = GameObject.FindGameObjectsWithTag(“Spawn”);
//ballObject = GameObject.FindGameObjectsWithTag(“BallObject”);

}

function Update() {

if(myTimer > 0){
myTimer -= Time.deltaTime;
}

if(myTimer <= 0){
spawnNum =Random.Range(0, spawnPoints.length-1);
ballNum = Random.Range(0, ballObjects.length-1);
print(“spawnpoint:” + spawnNum + ”  ball number:” + ballNum);
var proj: Rigidbody = Instantiate(ballObjects[ballNum], spawnPoints[spawnNum].position, spawnPoints[spawnNum].rotation);
proj.velocity = Vector3(-25,0,0);
proj.AddForce(Vector3(-40,50,0));
myTimer = 15.0;
}

if (score == 100) {
scoreText.guiText.text = “You have won the game!”;
}

if (score == -100) {
scoreText.guiText.text = “You lose! Try again… Harder this time!”;
}
}

function OnCollisionEnter(col:Collision) {

//if(col.gameObject.tag == “Player”) {
print(col.rigidbody);
//scoreText = GameObject.Find(“scoreText”);
//SpawnScript = GameObject.Find(“Main Camera”).GetComponent(Spawn2);
audio.PlayOneShot(goodSound);
Destroy(rigidbody);
score += 10;
}
//}

function LosePoints(){
score -= 10;
scoreText.text = (“Score: ” + score);
scoreText2.text = (“Score: ” + score);
print(“you have lost points”);
}

About the author

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>