add games
This commit is contained in:
31
assignment8final/Assets/Resources/Scripts/Airplane.cs
Normal file
31
assignment8final/Assets/Resources/Scripts/Airplane.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Airplane : MonoBehaviour {
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
// if airplane goes past the left edge, destroy it
|
||||
if (transform.position.x < -25) {
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else {
|
||||
|
||||
// make it go twice as fast as the skyscraper spawner speed toward the left
|
||||
transform.Translate(-SkyscraperSpawner.speed * 2 * Time.deltaTime, 0, 0, Space.World);
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
|
||||
// trigger helicopter's explode function via HeliController component
|
||||
// and then destroy this airplane as well
|
||||
other.transform.parent.gameObject.GetComponent<HeliController>().Explode();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
12
assignment8final/Assets/Resources/Scripts/Airplane.cs.meta
Normal file
12
assignment8final/Assets/Resources/Scripts/Airplane.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bcb45777e9edadd408cc84124f1a86b5
|
||||
timeCreated: 1475978678
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
assignment8final/Assets/Resources/Scripts/AirplaneSpawner.cs
Normal file
30
assignment8final/Assets/Resources/Scripts/AirplaneSpawner.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class AirplaneSpawner : MonoBehaviour {
|
||||
public GameObject[] prefabs;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
// trigger asynchronous randomized infinite spawning of airplanes
|
||||
StartCoroutine(SpawnAirplanes());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
IEnumerator SpawnAirplanes() {
|
||||
while (true) {
|
||||
|
||||
// instantiate a random airplane past the right egde of the screen, facing left
|
||||
Instantiate(prefabs[Random.Range(0, prefabs.Length)], new Vector3(26, Random.Range(7, 10), 11),
|
||||
Quaternion.Euler(-90f, -90f, 0f));
|
||||
|
||||
// pause this coroutine for 3-10 seconds and then repeat loop
|
||||
yield return new WaitForSeconds(Random.Range(3, 10));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7d118b2fbd562e3488817cdd2ecebdd7
|
||||
timeCreated: 1475978684
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
22
assignment8final/Assets/Resources/Scripts/Bounds.cs
Normal file
22
assignment8final/Assets/Resources/Scripts/Bounds.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Bounds : MonoBehaviour {
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
float speed = other.transform.parent.gameObject.GetComponent<HeliController>().speed;
|
||||
|
||||
other.transform.parent.gameObject.transform.Translate(-other.transform.parent.gameObject.GetComponent<Rigidbody>().velocity / speed);
|
||||
other.transform.parent.gameObject.GetComponent<Rigidbody>().velocity = new Vector3(0, 0, 0);
|
||||
}
|
||||
}
|
12
assignment8final/Assets/Resources/Scripts/Bounds.cs.meta
Normal file
12
assignment8final/Assets/Resources/Scripts/Bounds.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2604e242834ab40619fefa56fa3ca79a
|
||||
timeCreated: 1475904608
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
34
assignment8final/Assets/Resources/Scripts/Coin.cs
Normal file
34
assignment8final/Assets/Resources/Scripts/Coin.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Coin : MonoBehaviour {
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
// despawn coin if it goes past the left edge of the screen
|
||||
if (transform.position.x < -25) {
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else {
|
||||
|
||||
// ensure coin moves at the same rate as the skyscrapers do
|
||||
transform.Translate(-SkyscraperSpawner.speed * Time.deltaTime, 0, 0, Space.World);
|
||||
}
|
||||
|
||||
// infinitely rotate this coin about the Y axis in world space
|
||||
transform.Rotate(0, 5f, 0, Space.World);
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
|
||||
// trigger coin pickup function if a helicopter collides with this
|
||||
other.transform.parent.GetComponent<HeliController>().PickupCoin();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
12
assignment8final/Assets/Resources/Scripts/Coin.cs.meta
Normal file
12
assignment8final/Assets/Resources/Scripts/Coin.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4b9467434aa2b724fad2631704e851b0
|
||||
timeCreated: 1475972856
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
35
assignment8final/Assets/Resources/Scripts/CoinSpawner.cs
Normal file
35
assignment8final/Assets/Resources/Scripts/CoinSpawner.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class CoinSpawner : MonoBehaviour {
|
||||
|
||||
public GameObject[] prefabs;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
// infinite coin spawning function, asynchronous
|
||||
StartCoroutine(SpawnCoins());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
IEnumerator SpawnCoins() {
|
||||
while (true) {
|
||||
|
||||
// number of coins we could spawn vertically
|
||||
int coinsThisRow = Random.Range(1, 4);
|
||||
|
||||
// instantiate all coins in this row separated by some random amount of space
|
||||
for (int i = 0; i < coinsThisRow; i++) {
|
||||
Instantiate(prefabs[Random.Range(0, prefabs.Length)], new Vector3(26, Random.Range(-10, 10), 10), Quaternion.identity);
|
||||
}
|
||||
|
||||
// pause 1-5 seconds until the next coin spawns
|
||||
yield return new WaitForSeconds(Random.Range(1, 5));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 05fd3c03acabdb9499cbfb87f9de8f42
|
||||
timeCreated: 1475972837
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
24
assignment8final/Assets/Resources/Scripts/CoinText.cs
Normal file
24
assignment8final/Assets/Resources/Scripts/CoinText.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
|
||||
[RequireComponent(typeof(Text))]
|
||||
public class CoinText : MonoBehaviour {
|
||||
|
||||
public GameObject helicopter;
|
||||
private Text text;
|
||||
private int coins;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
text = GetComponent<Text>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
if (helicopter != null) {
|
||||
coins = helicopter.GetComponent<HeliController>().coinTotal;
|
||||
}
|
||||
text.text = "Coins: " + coins;
|
||||
}
|
||||
}
|
12
assignment8final/Assets/Resources/Scripts/CoinText.cs.meta
Normal file
12
assignment8final/Assets/Resources/Scripts/CoinText.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee85b83558eee7b4886fb4fa2e8f74f6
|
||||
timeCreated: 1475974352
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
40
assignment8final/Assets/Resources/Scripts/GameOverText.cs
Normal file
40
assignment8final/Assets/Resources/Scripts/GameOverText.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using System.Collections;
|
||||
|
||||
public class GameOverText : MonoBehaviour {
|
||||
|
||||
public GameObject helicopter;
|
||||
private Text text;
|
||||
private int coins;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
text = GetComponent<Text>();
|
||||
|
||||
// start text off as completely transparent black
|
||||
text.color = new Color(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
if (helicopter != null) {
|
||||
coins = helicopter.GetComponent<HeliController>().coinTotal;
|
||||
}
|
||||
else {
|
||||
|
||||
// reveal text only when helicopter is null (destroyed)
|
||||
text.color = new Color(0, 0, 0, 1);
|
||||
text.text = "Game Over\nYour Score:\n" + coins + " Coins\nPress Space to Restart!";
|
||||
|
||||
// jump is space bar by default
|
||||
if (Input.GetButtonDown("Jump")) {
|
||||
SkyscraperSpawner.speed = 10f;
|
||||
|
||||
// reload entire scene, starting music over again, refreshing score, etc.
|
||||
SceneManager.LoadScene("Main");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a882b90e547eb94419c63f8a2dcddf65
|
||||
timeCreated: 1475980811
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
assignment8final/Assets/Resources/Scripts/Gem.cs
Normal file
30
assignment8final/Assets/Resources/Scripts/Gem.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class Gem : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (transform.position.x < -25) {
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else {
|
||||
transform.Translate(-SkyscraperSpawner.speed * Time.deltaTime, 0, 0, Space.World);
|
||||
}
|
||||
|
||||
transform.Rotate(0, 1f, 0, Space.World);
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
other.transform.parent.GetComponent<HeliController>().PickupGem();
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
11
assignment8final/Assets/Resources/Scripts/Gem.cs.meta
Normal file
11
assignment8final/Assets/Resources/Scripts/Gem.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c3b7c3fb4a0c2414aad7a7b94f98ccf7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
29
assignment8final/Assets/Resources/Scripts/GemSpawner.cs
Normal file
29
assignment8final/Assets/Resources/Scripts/GemSpawner.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class GemSpawner : MonoBehaviour
|
||||
{
|
||||
public GameObject[] prefabs;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
StartCoroutine(SpawnGem());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
IEnumerator SpawnGem() {
|
||||
while (true) {
|
||||
GameObject gem = Instantiate(prefabs[Random.Range(0, prefabs.Length)], new Vector3(26, Random.Range(-10, 10), 10), Quaternion.identity);
|
||||
gem.GetComponent<Renderer>().material.color = Color.red;
|
||||
|
||||
yield return new WaitForSeconds(Random.Range(7, 15));
|
||||
}
|
||||
}
|
||||
}
|
11
assignment8final/Assets/Resources/Scripts/GemSpawner.cs.meta
Normal file
11
assignment8final/Assets/Resources/Scripts/GemSpawner.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbd55934d661b39a7a8e256d8392ea60
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
79
assignment8final/Assets/Resources/Scripts/HeliController.cs
Normal file
79
assignment8final/Assets/Resources/Scripts/HeliController.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class HeliController : MonoBehaviour {
|
||||
|
||||
public float speed = 10.0f;
|
||||
public int coinTotal = 0;
|
||||
private Rigidbody rb;
|
||||
private float vertical, horizontal;
|
||||
public ParticleSystem explosion;
|
||||
public AudioSource explosionSound;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
// vertical axis is either up or down or w and s on the keyboard, among others
|
||||
if (Input.GetAxisRaw("Vertical") != 0) {
|
||||
vertical = Input.GetAxis("Vertical") * speed;
|
||||
|
||||
// constrain movement within the bounds of the camera
|
||||
if (transform.position.y < -9.5f) {
|
||||
transform.position = new Vector3(transform.position.x, -9.5f, transform.position.z);
|
||||
}
|
||||
if (transform.position.y > 9) {
|
||||
transform.position = new Vector3(transform.position.x, 9, transform.position.z);
|
||||
}
|
||||
} else {
|
||||
vertical = 0f;
|
||||
}
|
||||
|
||||
// horizontal axis is either left or right or a and d on the keyboard, among others
|
||||
if (Input.GetAxisRaw("Horizontal") != 0) {
|
||||
horizontal = Input.GetAxis("Horizontal") * speed;
|
||||
|
||||
// constrain movement within the bounds of the camera
|
||||
if (transform.position.x < -12.5f) {
|
||||
transform.position = new Vector3(-12.5f, transform.position.y, transform.position.z);
|
||||
}
|
||||
if (transform.position.x > 15.5f) {
|
||||
transform.position = new Vector3(15.5f, transform.position.y, transform.position.z);
|
||||
}
|
||||
}
|
||||
else {
|
||||
horizontal = 0f;
|
||||
}
|
||||
|
||||
// set rigidbody's velocity to our input
|
||||
rb.velocity = new Vector3(horizontal, vertical, 0);
|
||||
}
|
||||
|
||||
public void PickupCoin() {
|
||||
coinTotal += 1;
|
||||
|
||||
// trigger audio playback and emit particles from particle system
|
||||
GetComponents<AudioSource>()[0].Play();
|
||||
GetComponent<ParticleSystem>().Play();
|
||||
}
|
||||
|
||||
public void PickupGem() {
|
||||
coinTotal += 5;
|
||||
GetComponents<AudioSource>()[0].Play();
|
||||
GetComponent<ParticleSystem>().Play();
|
||||
}
|
||||
|
||||
public void Explode() {
|
||||
explosionSound.Play();
|
||||
|
||||
// set explosion position to helicopter's and emit
|
||||
explosion.transform.position = transform.position;
|
||||
explosion.Play();
|
||||
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 529082fd803994597be3009b40f0873b
|
||||
timeCreated: 1475899068
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,26 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class ScrollingBackground : MonoBehaviour {
|
||||
|
||||
public float scrollSpeed = .1f;
|
||||
public Renderer rend;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
rend = GetComponent<Renderer>();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
// Time.time is time since the game began, vs. deltaTime, which is time since last frame
|
||||
float offset = Time.time * scrollSpeed;
|
||||
|
||||
// texture offsets shift how the texture is drawn onto the 3D object, skewing its
|
||||
// UV coordinates; this results in a scrolling effect when applied on one axis
|
||||
rend.material.SetTextureOffset("_MainTex", new Vector2(offset, 0));
|
||||
|
||||
// shown out of curiosity, in case this texture had an associated bump map
|
||||
rend.material.SetTextureOffset("_BumpMap", new Vector2(offset, 0));
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4723d850564263c4c829dc91c7ec4f9b
|
||||
timeCreated: 1475950759
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
30
assignment8final/Assets/Resources/Scripts/Skyscraper.cs
Normal file
30
assignment8final/Assets/Resources/Scripts/Skyscraper.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class Skyscraper : MonoBehaviour {
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
// despawn when past left edge of the screen (camera)
|
||||
if (transform.position.x < -25) {
|
||||
Destroy(gameObject);
|
||||
}
|
||||
else {
|
||||
|
||||
// scroll based on SkyscraperSpawner static variable, speed
|
||||
transform.Translate(-SkyscraperSpawner.speed * Time.deltaTime, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter(Collider other) {
|
||||
|
||||
// trigger helicopter to explode when it collides with this
|
||||
other.transform.parent.gameObject.GetComponent<HeliController>().Explode();
|
||||
}
|
||||
}
|
12
assignment8final/Assets/Resources/Scripts/Skyscraper.cs.meta
Normal file
12
assignment8final/Assets/Resources/Scripts/Skyscraper.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b04e699576a932f4880c99bf34d59d32
|
||||
timeCreated: 1475954681
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,37 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
public class SkyscraperSpawner : MonoBehaviour {
|
||||
|
||||
public GameObject[] prefabs;
|
||||
public static float speed = 10f;
|
||||
|
||||
// Use this for initialization
|
||||
void Start () {
|
||||
|
||||
// aysnchronous infinite skyscraper spawning
|
||||
StartCoroutine(SpawnSkyscrapers());
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update () {
|
||||
|
||||
}
|
||||
|
||||
IEnumerator SpawnSkyscrapers() {
|
||||
while (true) {
|
||||
|
||||
// create a new skyscraper from prefab selection at right edge of screen
|
||||
Instantiate(prefabs[Random.Range(0, prefabs.Length)], new Vector3(26, Random.Range(-20, -12), 11),
|
||||
Quaternion.Euler(-90f, 0f, 0f));
|
||||
|
||||
// randomly increase the speed by 1
|
||||
if (Random.Range(1, 4) == 1) {
|
||||
speed += 1f;
|
||||
}
|
||||
|
||||
// wait between 1-5 seconds for a new skyscraper to spawn
|
||||
yield return new WaitForSeconds(Random.Range(1, 5));
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 747d152cc27c6d14fa9a796f93d8feaf
|
||||
timeCreated: 1475954648
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user