Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class Tigelas : MonoBehaviour {
- public GameObject bowl = null;
- public float _NextSpawn = 2f;
- public float Interval = 1f;
- public int contador = 0;
- GameObject tigela;
- public enum Estado
- {
- NONE = 0,
- RANDOM = 1,
- LINHA = 2,
- DIAGONAL_LEFT = 3,
- DIAGONAL_RIGHT = 4,
- }
- public Estado estadoAtual = Estado.RANDOM;
- // Use this for initialization
- void Start ()
- {
- estadoAtual = SorteiaEstado();
- }
- Estado SorteiaEstado()
- {
- int Rand = Random.Range (0,4);
- if (Rand == 0) { return Estado.NONE; }
- if (Rand == 1) { return Estado.RANDOM; }
- if (Rand == 2) { return Estado.LINHA; }
- if (Rand == 3) { return Estado.DIAGONAL_LEFT; }
- if (Rand == 4) { return Estado.DIAGONAL_RIGHT; }
- else return Estado.NONE;
- }
- void InstanciaTigela(float X)
- {
- tigela = (GameObject)Instantiate(bowl, new Vector3(X, 0, Camera.main.transform.position.z + 20), Quaternion.identity);
- tigela.transform.Rotate(-90f, 0f, 0f);
- _NextSpawn += Interval;
- }
- void Update()
- {
- if (Time.time >= _NextSpawn)
- {
- if (estadoAtual == Estado.RANDOM)
- {
- float pos = Random.Range(40,48);
- InstanciaTigela(pos);
- contador += 1;
- if (contador >= 5)
- {
- estadoAtual = SorteiaEstado();
- contador = 0;
- }
- }
- if (estadoAtual == Estado.LINHA)
- {
- float pos = 44;
- if (contador == 0)
- {
- pos = Random.Range(40,48);
- }
- InstanciaTigela(pos);
- contador += 1;
- if (contador >= 10)
- {
- estadoAtual = SorteiaEstado();
- contador = 0;
- }
- }
- if (estadoAtual == Estado.DIAGONAL_LEFT)
- {
- float pos = 48;
- InstanciaTigela(pos-1 - contador * 1);
- contador += 1;
- if (contador >= 6)
- {
- estadoAtual = SorteiaEstado();
- contador = 0;
- }
- }
- if (estadoAtual == Estado.DIAGONAL_RIGHT)
- {
- float pos = 40;
- InstanciaTigela(pos+1 + contador * 1);
- contador += 1;
- if (contador >= 6)
- {
- estadoAtual = SorteiaEstado();
- contador = 0;
- }
- }
- if (estadoAtual == Estado.NONE)
- {
- contador += 1;
- if (contador >= 3)
- {
- estadoAtual = SorteiaEstado();
- if (estadoAtual == Estado.NONE)
- {
- while(estadoAtual == Estado.NONE)
- {
- estadoAtual = SorteiaEstado();
- }
- }
- contador = 0;
- }
- _NextSpawn += Interval;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment