Example #1
0
    public void JogarNovamente()
    {
        Destroy(placarObj);
        tempoDeJogo = TEMPO_JOGO;
        InterfaceSalaMuzzley.Instance.tempo.text = /*"ID: " + */activityId + "\n" + /*"Tempo: " + */((int)tempoDeJogo).ToString();
        contagemRegressivaObj = (GameObject)Instantiate(contagemRegressivaPrefab);
        fluxo = FLUXO.JOGO;
        jogarNovamente = false;

        CriarCarrosIA();
        RecriarCarrosDestruidos ();
    }
Example #2
0
    void Start()
    {
        myMuzzleyApp = new MuzzleyApp();
        myMuzzleyApp.ConnectApp(OnActivityReady, "ddb0a998759d3469", null);
        state = STATE.NENHUM_JOGADOR_ENTROU;
        fluxo = FLUXO.ESPERANDO_JOGADORES;
        idNovoCarro = null;
        participantes = new Dictionary<string, BumperCarMuzzley>();
        showQr = false;
        actionView = new Bounds(gameObject.transform.position, new Vector3(1,1,1));
        esperandoJogadorObj = (GameObject)Instantiate(esperandoJogadorPrefab);
        qrcodeGuiTexture2.enabled = true;
        moedasObj = (GameObject)Instantiate(moedasPrefab);
        jogadoresMax = 6;
        CriarPosicoesNaArena();

        //		motion.Add("c", "deviceMotion");
        //
        //		motionParams.Add("step", 5);
        //		motionParams.Add("pitch", true);
        //
        //		motion.Add("p", motionParams);
    }
Example #3
0
    public void EstadosDeJogo()
    {
        switch (fluxo) {
            case FLUXO.ESPERANDO_JOGADORES:
                if (participantes.Count > 0)
                {
                    tempoDeEspera -= Time.deltaTime;
                    GameObject.Find("Titulo2").guiText.text = "Esperando mais jogadores...  " + ((int)tempoDeEspera).ToString();
                }
                else
                {
                    tempoDeEspera = TEMPO_ESPERA;
                    GameObject.Find("Titulo2").guiText.text = "Venha jogar!";
                    LimparMoedas();
                }

                if (tempoDeEspera <= 0)
                {
                    Destroy(esperandoJogadorObj);
                    Destroy(moedasObj);
                    contagemRegressivaObj = (GameObject)Instantiate(contagemRegressivaPrefab);
                    fluxo = FLUXO.JOGO;

                    qrcodeGuiTexture2.enabled = false;

                    if (participantes.Count > 0)
                    {
                        DestruirCarrosParticipantes ();
                        RecriarCarrosDestruidos();
                    }

                    CriarCarrosIA ();
                    LimparMoedas();
                    tempoDeEspera = TEMPO_ESPERA;
                }

                break;
            case FLUXO.JOGO:
                if (participantes.Count == 0) {
                    fluxo = FLUXO.ESPERANDO_JOGADORES;
                    esperandoJogadorObj = (GameObject)Instantiate(esperandoJogadorPrefab);
                    qrcodeGuiTexture2.enabled = true;
                    moedasObj = (GameObject)Instantiate(moedasPrefab);
                    Destroy(contagemRegressivaObj);
                    tempoDeJogo = TEMPO_JOGO;
                    jogoIniciado = false;
                    DestruirCarrosIA ();
                    LimparMoedas();
                }

                if (!jogoIniciado)
                {
                    if (((int)contagemRegressiva) <= 0)
                    {
                        contagemRegressivaObj.guiText.text = "Vai!";
                        if (((int)contagemRegressiva) <= -1)
                        {
                            jogoIniciado = true;
                            tempoDeJogo = TEMPO_JOGO;
                            Destroy(contagemRegressivaObj);
                            contagemRegressiva = 4;
                        }
                    }
                    else if (contagemRegressivaObj != null)
                    {
                        contagemRegressivaObj.guiText.text = ((int)contagemRegressiva).ToString();
                    }

                    contagemRegressiva -= Time.deltaTime;
                }

                if (jogoIniciado)
                {
                    tempoDeJogo -= Time.deltaTime;
                    InterfaceSalaMuzzley.Instance.tempo.text = /*"ID: " + */activityId + "\n" + /*"Tempo: " + */((int)tempoDeJogo).ToString();

                    if (tempoDeJogo <= 0)
                    {
                        fluxo = FLUXO.PLACAR;
                        placarObj = (GameObject)Instantiate(placarPrefab);
                        jogoIniciado = false;

                        LimparMoedas();

                        // atualizamos os jogadores no placar
                        int oioi = 0;
                        foreach (KeyValuePair<string, BumperCarMuzzley> item in participantes)
                        {
                            oioi++;
                            GameObject.Find("Resultado").guiText.text = GameObject.Find("Resultado").guiText.text + "\n" + oioi + " - " + InterfaceSalaMuzzley.Instance.huds[oioi-1].GetComponent<UsuarioHudMuzzley>().nome.guiText.text + " - " + InterfaceSalaMuzzley.Instance.huds[oioi-1].GetComponent<UsuarioHudMuzzley>().coins + " Moedas";
                        }

                        //aqui limpamos a lista de jogadores com ia, excluimos eles e atualizams eles no placar
                        foreach (GameObject item in iaBumperCars)
                        {
                            oioi++;
                            GameObject.Find("Resultado").guiText.text = GameObject.Find("Resultado").guiText.text + "\n" + oioi + " - " + "IA" + " - " + item.GetComponent<BumperCarIA>().coins + " Moedas";
                            Destroy(item.gameObject);
                        }
                        iaBumperCars.Clear();

                        DestruirCarrosParticipantes();

                        //Limpamos a lista de carros seguidos pela ia
                        BumperCarsManager.Instance.bumperCars.Clear();

                        carrosCriados = false;
                    }
                }
                break;
            case FLUXO.PLACAR:
                if (participantes.Count == 0) {
                    fluxo = FLUXO.ESPERANDO_JOGADORES;
                    esperandoJogadorObj = (GameObject)Instantiate(esperandoJogadorPrefab);
                    qrcodeGuiTexture2.enabled = true;
                    moedasObj = (GameObject)Instantiate(moedasPrefab);
                    Destroy(placarObj);
                    tempoDeJogo = TEMPO_JOGO;
                    InterfaceSalaMuzzley.Instance.tempo.text = /*"ID: " + */activityId + "\n" + /*"Tempo: " + */((int)tempoDeJogo).ToString();
                    jogoIniciado = false;
                }

                if (jogarNovamente){
                    JogarNovamente();
                }
                break;
        }
    }