IsVirtualGoodEquipped() публичный статический Метод

Checks if the virtual good with the given goodItemId is currently equipped.
Thrown if the item is not found.
public static IsVirtualGoodEquipped ( string goodItemId ) : bool
goodItemId string Id of the virtual good who we want to know if is equipped.
Результат bool
Пример #1
0
 void SpawnCars()
 {
     Debug.Log("spawner car count " + cars.Count);
     try
     {
         Debug.Log("try " + "cars.Count"
                   + cars.Count);
         for (int i = 0; i < cars.Count; i++)
         {
             Debug.Log("cars[i]" + cars[i]);
             Debug.Log("showCaseTransform" + showCaseTransform);
             //instantiate cars from assets into scene
             cars[i] = Instantiate(cars[i]);
             cars[i].transform.parent =
                 platform.transform;
             cars[i].transform.position
                 = showCaseTransform.position;
             cars[i].SetActive(false);
         }
         //put currently selected car on platform
         foreach (GameObject car in cars)
         {
             Debug.Log(car.GetComponentInChildren <Car>());
             if ((car) && (car.GetComponentInChildren <Car>()) &&
                 (StoreInventory.IsVirtualGoodEquipped(car
                                                       .GetComponentInChildren <Car>().virtualGood.ItemId)))
             {
                 selectedCar = car;
                 break;
             }
         }
         if (!selectedCar) // if there's no selected car
         {
             Debug.Log("no selected car");
             //mark a bought car as selected
             foreach (GameObject car in cars)
             {
                 // at the beginning there's at least one bought car
                 if ((car) && (car.GetComponentInChildren <Car>()) &&
                     (car.GetComponentInChildren <Car>().virtualGood
                      .GetBalance() > 0))
                 {
                     selectedCar = car;
                     StoreInventory.EquipVirtualGood(car
                                                     .GetComponentInChildren <Car>().virtualGood.ItemId);
                     break;
                 }
             }
         }
         //sort by price
         cars = cars.OrderBy(o => o.GetComponentInChildren
                             <Car>().carData
                             .price).ToList <GameObject>();
         areCarsSpawned = true;
     }
     catch (Exception e)
     {
         Debug.Log("i caught this err " + e);
     }
 }
Пример #2
0
        void UpdateUI()
        {
            Debug.Log("currentShowCasedCar" + currentShowCasedCar);

            if (!(currentShowCasedCar.GetComponentInChildren <Car>()) ||
                !(currentShowCasedCar.GetComponentInChildren <Car>()).carData)
            {
                return;
            }
            Car currentCar = currentShowCasedCar
                             .GetComponentInChildren <Car>();
            int currentShowCasedCarIndex = cars.FindIndex
                                               (x => x == currentShowCasedCar);

            if ((currentCar) && (currentCar.carData))
            {
                carPriceText.text = currentCar.carData.price.ToString();
                carNameText.text  = currentCar.carData.name.ToString();
                carSpeedText.text = currentCar.carData.speedRate.ToString();
            }
            if (currentShowCasedCarIndex == 0)
            //if there's no previous car
            {
                rightArrowButton.SetActive(true);
                leftArrowButton.SetActive(false);
            }
            else if (currentShowCasedCarIndex == cars.Count - 1)
            //if there's no next car
            {
                leftArrowButton.SetActive(true);
                rightArrowButton.SetActive(false);
            }
            else // if there's a next car and a previous car
            {
                leftArrowButton.SetActive(true);
                rightArrowButton.SetActive(true);
            }
            //if current car wasn't bought
            if ((currentCar) && (currentCar.carData) &&
                (currentCar.virtualGood.GetBalance() == 0))
            {
                carStatus.text = unBoughtString;
                carPriceUI.SetActive(true);
                carPriceText.text = currentCar.carData.price
                                    .ToString();
                buyCarButton.SetActive(true);
                selectCarButton.SetActive(false);
            }
            else if ((currentCar) && (currentCar.carData) &&
                     (currentCar.virtualGood.GetBalance() > 0))
            //if current showcased car was bought
            {
                carStatus.text = boughtString;
                buyCarButton.SetActive(false);
                carPriceUI.SetActive(false);
                if (!StoreInventory.IsVirtualGoodEquipped(
                        currentCar.virtualGood.ItemId))
                {
                    selectCarButton.SetActive(true);
                }
                else // if current show cased car is selected
                {
                    selectCarButton.SetActive(false);
                }
            }
            //if either there is no car or it doesn't have a car data attached.
            else if (!(currentCar) || !(currentCar.carData))

            {
                Debug.Log("couldn't update UI because either there's no car , " +
                          "or it doesn't have a car data attached");
            }
        }