Exemplo n.º 1
0
    // Use this for initialization

    public static JogadorInfo[] gerarInfo(GameObject[] jogadores)
    {
        if (jogadores == null)
        {
            return(null);
        }
        JogadorInfo[] ji = new JogadorInfo[jogadores.Length];
        for (int i = 0; i < jogadores.Length; i++)
        {
            ji[i] = jogadores[i].GetComponent <Jogador>().GetInfo();
        }
        return(ji);
    }
Exemplo n.º 2
0
 public void SetInfo(JogadorInfo info)
 {
     this.enabled      = info.enabled;
     this.nick         = info.nick;
     this.nPersonagens = info.nPersonagens;
     this.setPersonagem(info.numeroPersonagem);
     Debug.Log("info.numeroPersonagem: " + info.numeroPersonagem + " " + this.NumeroPersonagem + " " + this.Nick);
     this.Visibilidade(info.visivel);
     this.name           = info.name;
     this.pontuacao      = info.pontuacao;
     this.pos_personagem = info.pos_personagem;
     this.pos_personagem = info.posTabuleiro;
     //	Debug.Log(" set info: "+info.nick+" "+info.numeroPersonagem+" "+info.name+" ");
 }
    public void Confirmar()
    {
        number_show.text = "" + count_jogadores;

        base.persistencia.jogadoresInfo = new JogadorInfo[count_jogadores];
        JogadorInfo info;

        for (int i = 0; i < count_jogadores; i++)
        {
            info      = new JogadorInfo();
            info.nick = "JOGADOR " + (i + 1);
            persistencia.jogadoresInfo[i] = info;
        }
        Destroy(infoReload);
        persistencia.CarregarCena(TelaCarregamento.ESCOLHAPERSONAGEM);
    }
Exemplo n.º 4
0
    public JogadorInfo GetInfo()
    {
        JogadorInfo info = new JogadorInfo();

        info.enabled = this.enabled;
        //jog.gameObject = this.gameObject.;
        info.name = this.name;
        info.nick = this.nick;
        //	Debug.Log(" nick get info: "+info.nick);
        info.numeroPersonagem = this.numeroPersonagem;
        //	jog.peao = this.peao;
        info.pontuacao      = this.pontuacao;
        info.pos_personagem = this.pos_personagem;
        info.sexo           = this.sexo;
        info.visivel        = this.visivel;
        info.posTabuleiro   = this.posTabuleiro;
        //	Debug.Log(" get info: "+info.nick+" "+info.numeroPersonagem+" "+info.name+" ");
        return(info);
    }
Exemplo n.º 5
0
    private IEnumerator Controle()
    {
        int posAtual;
        int rnd = 0;

        while (estadoMaquina > -1)
        {
            Debug.Log("jogador: " + jogadorSelecionado);
            switch (estadoMaquina)
            {
            case INICIO:
                if (!anim)
                {
                    Debug.Log("INICIO");
                    estadoMaquina = PERGUNTANDO;
                }
                break;

            case PERGUNTANDO:
                if (!anim)
                {
                    Debug.Log("PERGUNTANDO");
                    canvasCelularBackground.color = new Color(1f, 1f, 1f);
                    dice.GetComponent <Animator>().SetInteger("numberDice", 0);
                    dice.transform.localPosition = new Vector3(1, 1, 1);

                    Pergunta(nSen);
                    this.nickJogador_tv.text  = "JOGADOR " + (jogadorSelecionado + 1);
                    this.nickJogador_cel.text = "JOGADOR " + (jogadorSelecionado + 1);
                    this.pontosJogador.text   = "" + jogadores[jogadorSelecionado].GetComponent <Jogador>().Pontuacao;
                    this.jogadorAvatar.sprite = jogadores[jogadorSelecionado].GetComponent <Jogador>().Personagem.GetComponent <Image>().sprite;
                    this.EnfocarCameraTV(
                        jogadores[jogadorSelecionado].GetComponent <Jogador>().Peao.transform.position);
                    estadoMaquina = RESPONDENDO;
                }
                break;

            case RESPONDENDO:
                if (!anim)
                {
                    Debug.Log("RESPONDENDO");
                    if (condRespondido)
                    {
                        condRespondido = false;
                        ShowMessage(false, "", false, false);
                        estadoMaquina = MOVENDO;
                        if (TesteResposta())
                        {
                            rnd = Random.Range(1, 6);
                            dice.transform.localPosition = new Vector3(626f, -300f, 45f);
                            dice.GetComponent <Animator>().SetInteger("numberDice", rnd);
                            canvasCelularBackground.color = new Color(0, 1f, 0);
                            this.respostaCertaAudio.Play();
                        }
                        else
                        {
                            canvasCelularBackground.color = new Color(1f, 0, 0);
                            this.respostaErradaAudio.Play();
                        }
                    }
                }
                break;

            case MOVENDO:
                if (!anim)
                {
                    Debug.Log("MOVENDO");
                    if (TesteResposta())
                    {
                        posAtual = jogadores[jogadorSelecionado].GetComponent <Jogador>().PosTabuleiro;
                        jogadores[jogadorSelecionado].GetComponent <Jogador>().Pontuacao += nSen;
                        MoverPeao(jogadorSelecionado, posAtual + rnd);                     // tabuleiro.GetComponent<Tabuleiro>().NCasas);//

                        //refreshScreen();
                    }                    //else{

                    //}
                    posAtual = jogadores[jogadorSelecionado].GetComponent <Jogador>().PosTabuleiro;

                    //testa se chegou ao final
                    if (posAtual >= tabuleiro.GetComponent <Tabuleiro>().NCasas - 1)
                    {
                        estadoMaquina = TERMINO;
                    }
                    else
                    {
                        jogadorSelecionado = (jogadorSelecionado + 1) % jogadores.Length;

                        estadoMaquina = INICIO;
                    }
                    Resources.UnloadUnusedAssets();
                    System.GC.Collect();
                }
                break;

            case TERMINO:
                if (!anim)
                {
                    Debug.Log("TERMINO GG");
                    ShowMessage(true, " PARABÉNS\n" + jogadores[jogadorSelecionado].GetComponent <Jogador>().Nick, true, false);
                    estadoMaquina = -1;
                    vitoriaAudio.Play();
                    yield return(new WaitForSeconds(5));

                    this.persistencia.jogadoresInfo = JogadorInfo.gerarInfo(this.jogadores);
                    this.persistencia.CarregarCena(TelaCarregamento.CLASSIFICACAO);
                }
                break;

            default:

                break;
            }


            yield return(new WaitForSeconds(1));
        }
    }
Exemplo n.º 6
0
    public void iniciarJogadores(int nJogadores)
    {
        //	if(info.first)
        jogadores = JogadorInfo.gerarJogadores(base.persistencia.jogadoresInfo);          // GameObject.FindGameObjectsWithTag("Player");
        //	else{
        //	jogadores =JogadorInfo.gerarJogadores(info.jogadores);
        //	}

        bool jogadoresAtivos = jogadores != null;

        if (jogadoresAtivos)
        {
            nJog = jogadores.Length;

            Debug.Log(" ENCONTRADOS PLAYERS " + jogadores.Length + " " + nJogadores);
        }
        else
        {
            nJog      = nJogadores;
            jogadores = new GameObject[nJog];

            //	Debug.Log(" NÃO ENCONTRADOS JOGADORES ");
        }


        Jogador jog = null;

        for (int i = 0; i < nJog; i++)
        {
            //		Debug.Log("iniciarJogadores && info.first: "+info.first+" ");
            jog = jogadores[i].GetComponent <Jogador>();
            if ((!jogadoresAtivos || (jogadores[i] == null)))
            {
                jogadores[i] = Instantiate(Resources.Load("prefabs/jogador")) as GameObject;
                //	jogadores[i].AddComponent<RectTransform>();
                //	jogadores[i].AddComponent<Jogador>();
                jogadores[i].name = "JOGADOR" + i;
                jog.setPersonagem(0);
                //	jogadores[i].GetComponent<RectTransform>().localPosition;
                jog.nick = "JOGADOR " + i;
                Debug.Log("inside true iniciarJogadores");
                jog.SetScalePersonagem(new Vector3(0.007f, 0.0047f, 0));
            }
            else
            {
                jogadores[i].GetComponent <Jogador>().SetScalePersonagem(new Vector3(1f, 1f, 1f));
            }

            jogadores[i].GetComponent <RectTransform>().SetParent(placeholderPersonagem.transform);            //(this.GetComponent<RectTransform>());
            jogadores[i].transform.localPosition = new Vector3(10, 0, 0);
            jogadores[i].transform.localScale    = new Vector3(11, 11, 0);
            //jog.SetPositionPeao( new Vector3(4.11f,-0.42f,0) );
            //jog.SetScalePeao( new Vector3(0.01f,0.01f,0) );
            //jog.peao.transform.localPosition = new Vector3(4.11f,-0.42f,0);

            jog.personagem.transform.localPosition = new Vector3(0, 0, 0);
            //Debug.Log(jogadores[i].GetComponent.<RectTransform>().localPosition );
            //Debug.Log(jogadores[i].GetComponent<RectTransform>().position );
            jogadores[i].GetComponent <Jogador>().Visibilidade(false);
            //jogadores[i].GetComponent<RectTransform>().rect.width=1;
            //jogadores[i].GetComponent<RectTransform>().rect.height =1;
        }
    }