Beispiel #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;
        }
    }
Beispiel #2
0
    // Use this for initialization
    void Start()
    {
        bool isDead = false;

        lPath      = ScoreList.getPath("scores.xml");
        evaluation = false;
    }
Beispiel #3
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();
            }
        }
    }