Esempio n. 1
0
    IEnumerator CreateCar(int carNum)
    {
        CarParametres carParametres = CarsInfo.GetCarInfo(carNum);

        this.carParametres = carParametres;

        StaticValues.NumCar = carNum;


        libraryMenu.filling.UpdateAllPower(
            carParametres.GetParam(1),
            carParametres.GetParam(2),
            carParametres.GetParam(3),
            PreferencesSaver.GetCarUpgrade(carNum, 1),
            PreferencesSaver.GetCarUpgrade(carNum, 2),
            PreferencesSaver.GetCarUpgrade(carNum, 3));


        bool isOpen = PreferencesSaver.CarIsOpen(carNum);

        if (!isOpen)
        {
            if (!carParametres.IsBonus())
            {
                libraryMenu.garage.ShowBuyButton(carParametres.GetCost());
            }
            else
            {
                libraryMenu.garage.ShowEnterVkButton();
            }

            libraryMenu.garage.HidePlayButton();
            libraryMenu.garage.HideSecondPower();
        }
        else
        {
            libraryMenu.garage.HideBuyAndVkButton();
            libraryMenu.garage.ShowPlayButton();
            libraryMenu.garage.ShowSecondPower();
        }

        ResourceRequest rr = Resources.LoadAsync("Prefabs/UI/Cars/" + carParametres.GetName());


        yield return(rr);

        GameObject carObject = Instantiate(rr.asset as GameObject);

        carObject.transform.SetParent(car.transform, false);

        carObject.transform.localPosition = new Vector3(0, 0, 0);
        carObject.transform.localRotation = Quaternion.Euler(0, 0, 0);
        carObject.transform.localScale    = new Vector3(1, 1, 1);
    }
Esempio n. 2
0
    // Use this for initialization
    void Awake()
    {
        CarParametres carParametres = CarsInfo.GetCarInfo(StaticValues.NumCar);

        if (carParametres != null && StaticValues.NumLevel != 999)
        {
            speed           = carParametres.GetParam(1) + PreferencesSaver.GetCarUpgrade(StaticValues.NumCar, 1);
            nitro           = carParametres.GetParam(2) + PreferencesSaver.GetCarUpgrade(StaticValues.NumCar, 2);
            controllability = carParametres.GetParam(3) + PreferencesSaver.GetCarUpgrade(StaticValues.NumCar, 3);

            carLevel = carParametres.GetLevelCar();
            minSpeed = carParametres.GetMinSpeed();
        }
        controllability = Mathf.Clamp(controllability, 1, maxVal);
        nitro           = Mathf.Clamp(nitro, 1, maxVal);
        speed           = Mathf.Clamp(speed, 1, maxVal);
    }