Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class CenarioControl : MonoBehaviour {
- public GameObject casa = null;
- public GameObject plano = null;
- private int CurrentPlane = 0;
- private int lastInstance = 62;
- private float nextCasaInstantiate = 9.4f;
- GameObject casaPequena;
- GameObject terreno;
- List<GameObject> terrenos;
- // Use this for initialization
- void Start ()
- {
- int i = 1;
- int x = 0;
- while (i <= 7)
- {
- InstanciaCasa(new Vector3(36, 0, i*9));
- InstanciaCasa(new Vector3(52, 0, i*9));
- i++;
- }
- terrenos = new List<GameObject>();
- while (x < 7)
- {
- terrenos.Add((GameObject)Instantiate(plano, new Vector3(44, 0, (x * 10 + 2)), Quaternion.identity));
- x++;
- }
- terrenos.Add((GameObject)Instantiate(plano, new Vector3(44, 0, -30), Quaternion.identity));
- }
- void InstanciaCasa(Vector3 pos)
- {
- casaPequena = (GameObject)Instantiate(casa, pos, Quaternion.identity);
- if (casaPequena.transform.position.x > 50)
- {
- casaPequena.transform.Rotate(0,270,0);
- }
- else
- {
- casaPequena.transform.Rotate(0,90,0);
- }
- }
- // Update is called once per frame
- void Update ()
- {
- if (gameObject.transform.position.z >= nextCasaInstantiate)
- {
- InstanciaCasa(new Vector3(52,0,gameObject.transform.position.z + 60));
- InstanciaCasa(new Vector3(36,0,gameObject.transform.position.z + 60));
- nextCasaInstantiate += 9;
- }
- if (CurrentPlane > 6) { CurrentPlane = 0; }
- if (gameObject.transform.position.z >= terrenos[CurrentPlane+1].transform.position.z)
- {
- terrenos[CurrentPlane].transform.Translate(0, 0, 60);
- Debug.Log("Current Plane: " + CurrentPlane);
- CurrentPlane++;
- lastInstance += 10;
- if (CurrentPlane > 8)
- {
- Debug.Log("Current Plane: " + CurrentPlane);
- CurrentPlane = 0;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment