Пример #1
0
    public void queryscore()
    {
        FB.API("/1617825028466938/scores", HttpMethod.GET, delegate(IGraphResult result)
        {
            scorelist = Util.DeserializeScores(result.RawResult);

            Constantes.listaPuntajesfb = new ArrayList();
            foreach (object score in scorelist)
            {
                var entry  = (Dictionary <string, object>)score;
                var user   = (Dictionary <string, object>)entry["user"];
                var puntos = entry["score"].ToString();
                var nombre = entry["user"].ToString();


                if (int.Parse(puntos) > 0)
                {
                    PuntajeVO puntajefb = new PuntajeVO();

                    puntajefb.setTiempo(puntos);
                    puntajefb.setNombreJugador(user["name"].ToString());

                    Constantes.listaPuntajesfb.Add(puntajefb);
                }
            }
        }



               );
    }
Пример #2
0
    public static ArrayList ordenarPuntajesfb(ArrayList puntajesfb)
    {
        bool ordenado = true;

        Debug.Log("CANT PUNTAJES: " + puntajesfb.Count);
        PuntajeVO puntajefb_pivote = null;

        PuntajeVO puntajefb_aux = null;

        for (int i = 0; i < puntajesfb.Count; i++)
        {
            Debug.Log("QuickSort Ejecutandose");

            if (i == 0)
            {
                puntajefb_pivote = (PuntajeVO)puntajesfb[i];
            }
            else
            {
                PuntajeVO puntajefb = (PuntajeVO)puntajesfb[i];

                if (int.Parse(puntajefb.getTiempo()) > int.Parse(puntajefb_pivote.getTiempo()))
                {
                    puntajefb_pivote = (PuntajeVO)puntajesfb[i];
                }
                else
                {
                    ordenado      = false;
                    puntajefb_aux = puntajefb;

                    puntajesfb[i]     = puntajefb_pivote;
                    puntajesfb[i - 1] = puntajefb_aux;
                }
            }
        }

        Debug.Log("DESPUES DE ORDENAR: ");
        string lista = "";

        for (int i = 0; i < puntajesfb.Count; i++)
        {
            PuntajeVO puntaje_ = (PuntajeVO)puntajesfb[i];
            lista += " (" + puntaje_.getPosicion() + ") " + int.Parse(puntaje_.getTiempo().Replace(":", ""));
        }

        Debug.Log("L:" + lista);

        if (ordenado == true)
        {
            return(puntajesfb);
        }
        else
        {
            return(ordenarPuntajesfb(puntajesfb));
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (Constantes.raceFinished && !FinishedAndTested)
        {
            //salto a la nueva escena
            InvokeRepeating("LaunchProjectile", 5, 0);
            Debug.Log("CARRERA FINALIZADA ");
            Debug.Log("TOTAL RACERS " + RankManager.instance.totalRacers);
            string mipuntaje = "";

            Constantes.listaPuntajes = new ArrayList();

            for (int i = 0; i < RankManager.instance.totalRacers - 1; i++)
            {
                Debug.Log("RANKING: " + RankManager.instance.racerRanks[i].racer.GetComponent <Statistics>().rank);
                Debug.Log("RACE TIME: " + RankManager.instance.racerRanks[i].racer.GetComponent <Statistics>().totalRaceTime);
                Debug.Log("NOMBRE JUGADOR: " + RankManager.instance.racerRanks[i].racer.name);

                PuntajeVO puntaje = new PuntajeVO();
                puntaje.setPosicion(RankManager.instance.racerRanks[i].racer.GetComponent <Statistics>().rank);
                puntaje.setTiempo(RankManager.instance.racerRanks[i].racer.GetComponent <Statistics>().totalRaceTime);
                puntaje.setNombreJugador(RankManager.instance.racerRanks[i].racer.name);

                if (RankManager.instance.racerRanks[i].racer.name == "Jugador")
                {
                    mipuntaje = RankManager.instance.racerRanks[i].racer.GetComponent <Statistics>().totalRaceTime;
                    mipuntaje = mipuntaje.Replace(":", "");
                    int numVal = int.Parse(mipuntaje);

                    Debug.Log("mi puntaje:" + numVal.ToString());
                    if (FB.IsLoggedIn)
                    {
                        FBPuntajes.setscore(numVal.ToString());
                    }
                    else
                    {
                    }
                }

                Constantes.listaPuntajes.Add(puntaje);
            }

            FinishedAndTested = true;
        }
    }