Пример #1
0
    void Start()
    {
        calculoEnd = false;
        saved      = false;
        instance   = this;
        GameObject player_go = GameObject.FindGameObjectWithTag("Player");

        if (player_go == null)
        {
            Debug.LogError("No se encuentra objeto con tag 'Player'");
        }
        princesa = player_go.GetComponent <PrincesavueScript>();
        score    = 0;
        PlayerPrefs.GetInt("highScore", 0);


//AQUI INICIO EL COMPARADOR CON EL MAXIMO PUNTAJE GUARDADO O 0 SI NO HAY UN XML (RECIEN INSTALADO)
        try {
            var lPath1 = ScoreList.getPath("scores.xml");

            var scoreCollection = ScoreList.Load(lPath1);
            var lScore          = scoreCollection.getScores(0);
            comparator = lScore.Points;
//PARA TESTEAR DESCOMENTA LA SIGUIENTE LINEA
            //comparator = 10;
        }catch {
            comparator = 0;
        }
    }
Пример #2
0
    // Update is called once per frame
    //void Update () {
    public void test()
    {
        if (!isDead)
        {
            isDead = GameObject.Find("Jugador").GetComponent <PrincesavueScript> ().muerte;
            if (isDead)
            {
                try {
                    scoreCollection = ScoreList.Load(lPath);
                }
                catch {
                    createXML3(lPath);
                    scoreCollection = ScoreList.Load(lPath);
                }


                guiText.text = "";
                //CAMBIAR POR OTRO GUI TEXT
                guiText.text = scoreCollection.getScores(0).Name + ": " + scoreCollection.getScores(0).Points + " ptos\n" +
                               "" + scoreCollection.getScores(1).Name + ": " + scoreCollection.getScores(1).Points + " ptos\n" +
                               "" + scoreCollection.getScores(2).Name + ": " + scoreCollection.getScores(2).Points + " ptos\n" +
                               "" + scoreCollection.getScores(3).Name + ": " + scoreCollection.getScores(3).Points + " ptos\n" +
                               "" + scoreCollection.getScores(4).Name + ": " + scoreCollection.getScores(4).Points + " ptos\n";
            }
        }
    }
Пример #3
0
 public void LoadNow()
 {
     scoreList.Load(System.IO.Path.Combine(Application.persistentDataPath, scoreListFileName));
 }
Пример #4
0
    void Update()
    {
        //CON ESTO AGARRAS JUSTO CUANDO MUERE EL PLAYER
        bool isDead       = GameObject.Find("Jugador").GetComponent <PrincesavueScript>().muerte;
        bool isPowerClock = GameObject.Find("Jugador").GetComponent <PrincesavueScript>().powerClock;

        if (!isDead)
        {
            int distanciaenmil = (int)(dist);
            if (distanciaenmil >= comparator && !compared)
            {
                puntoTiempo += Time.deltaTime;

                compared = true;
                Debug.LogWarning(puntoTiempo);
                GameObject.Find("recorrido").GetComponent <SpriteRenderer>().enabled = true;
            }
            //dist = Vector3.Distance(other.position, transform.position);
            dist = isPowerClock ? dist + (Time.deltaTime * 10 * 2):dist + (Time.deltaTime * 10);

            guiText.text = "Galleta: " + score + "\nDistancia: " + (int)(dist);
        }
        else
        {
            if (!saved)
            {
                saved = true;
                lPath = ScoreList.getPath("scores.xml");

                try {
                    var scoreCollection = ScoreList.Load(lPath);
                    var lScore          = new Score();
                    int auxPints        = (int)(dist);

                    for (int i = 0; i < 5; i++)
                    {
                        lScore = scoreCollection.getScores(i);
                        if (lScore.Points <= auxPints)
                        {
                            int aux2 = lScore.Points;
                            lScore.Points = auxPints;
                            auxPints      = aux2;
                        }
                    }
                    scoreCollection.Save(lPath, 0);
                    guiText.text = "";
                }catch {
                    createXML(lPath);
                    var scoreCollection = ScoreList.Load(lPath);
                    var lScore          = new Score();
                    int auxPints        = (int)(dist);

                    for (int i = 0; i < 5; i++)
                    {
                        lScore = scoreCollection.getScores(i);
                        Debug.LogWarning(lScore.Name);
                        Debug.LogWarning(lScore.Points);
                        if (lScore.Points <= auxPints)
                        {
                            int aux2 = lScore.Points;
                            lScore.Points = auxPints;
                            auxPints      = aux2;
                        }
                    }
                    scoreCollection.Save(lPath, 0);
                    guiText.text = "";
                }


                var lTotales = GameObject.Find("Totales2").GetComponent <totales> ();
                lTotales.test();
            }
        }
    }