Beispiel #1
0
 public void resetUpgrades()
 {
     xml.setNivell("Velocitat", 0);
     xml.setNivell("Vida", 0);
     xml.setNivell("Valor", 0);
     xml.setNivell("ValorFuel", 0);
     xml.setNivell("Arrancada", 0);
     xml.setNivell("Turbo", 0);
     xml.setNivell("Capacitat", 0);
     xml.setNivell("Resistencia", 0);
     xml.setNivell("Botiquin", 0);
 }
Beispiel #2
0
    public void milloraNivell()
    {
        //xml.milloraNivell(EventSystem.current.currentSelectedGameObject.name);
        switch (EventSystem.current.currentSelectedGameObject.name)
        {
        case "velocitat":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellVelocitat + 1), 2) && nivellVelocitat < 4)
            {
                nivellVelocitat++;
                xml.setNivell("Velocitat", nivellVelocitat);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellVelocitat];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellVelocitat];
            }

            break;

        case "vida":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellVida + 1), 2) && nivellVida < 4)
            {
                nivellVida++;
                xml.setNivell("Vida", nivellVida);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellVida];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellVida];
            }
            break;

        case "valor":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellValor + 1), 2) && nivellValor < 4)
            {
                nivellValor++;
                xml.setNivell("Valor", nivellValor);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellValor];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellValor];
            }
            break;

        case "valorFuel":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellValorFuel + 1), 2) && nivellValorFuel < 4)
            {
                nivellValorFuel++;
                xml.setNivell("ValorFuel", nivellValorFuel);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellValorFuel];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellValorFuel];
            }
            break;

        case "arrancada":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellArrancada + 1), 2) && nivellArrancada < 4)
            {
                nivellArrancada++;
                xml.setNivell("Arrancada", nivellArrancada);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellArrancada];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellArrancada];
            }
            break;

        case "turbo":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellTurbo + 1), 2) && nivellTurbo < 4)
            {
                nivellTurbo++;
                xml.setNivell("Turbo", nivellTurbo);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellTurbo];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellTurbo];
            }
            break;

        case "capacitatFuel":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellCapacitatFuel + 1), 2) && nivellCapacitatFuel < 4)
            {
                nivellCapacitatFuel++;
                xml.setNivell("Capacitat", nivellCapacitatFuel);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellCapacitatFuel];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellCapacitatFuel];
            }
            break;

        case "resistencia":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellResistencia + 1), 2) && nivellResistencia < 4)
            {
                nivellResistencia++;
                xml.setNivell("Resistencia", nivellResistencia);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellResistencia];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellResistencia];
            }
            break;

        case "botiquin":
            if (xml.getMoney() >= 800 * Mathf.Pow((nivellBotiquin + 1), 2) && nivellBotiquin < 4)
            {
                nivellBotiquin++;
                xml.setNivell("Botiquin", nivellBotiquin);
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/BarraMillora").GetComponent <Image>().sprite = barresMillora[nivellBotiquin];
                GameObject.Find("/Canvas/ScrollRect/Millores/" + EventSystem.current.currentSelectedGameObject.name + "/Cost").GetComponent <Image>().sprite         = imatgesPreus[nivellBotiquin];
            }
            break;
        }

        monedas      = GameObject.Find("/Canvas/monedas").GetComponent <Text>();
        monedas.text = "" + xml.getMoney();
    }