示例#1
0
    // Purchase a car.
    public void PurchaseCar(CarList.Car car)
    {
        if (!car.IsRealMoneyPurchase)
        {
            ReduceCoinsOwned((int)(car.Price * Discount));
        }

        carIndexToOwnership[(int)car.Name] = Ownership.Owned;
        Object.FindObjectOfType <CarStorePageController>()?.RefreshPage();
    }
示例#2
0
    public static void SetDeferredPurchaseReminderActiveness(CarList.Car car, bool isActive)
    {
        var storeItemCarGameObj = car.StoreItemCarGameObj;

        storeItemCarGameObj.transform.Find("deferredPurchaseReminder")?.gameObject.SetActive(isActive);
        // Set the Item not interactive if deferred purchase reminder is set up.
        if (isActive)
        {
            storeItemCarGameObj.GetComponent <Button>().interactable = false;
        }
    }
示例#3
0
    // Listener for car item purchase.
    public void OnCarStoreItemClicked(int carIndex)
    {
        _carToPurchaseObj = CarList.GetCarByCarIndex(carIndex);

        if (_carToPurchaseObj.IsRealMoneyPurchase)
        {
            BuyCar();
        }
        else // if the item sells in coins.
        {
            var gameData = GameDataController.GetGameData();
            // Players can purchase the coin item only it they have enough coin.
            if (gameData.coinsOwned >= _carToPurchaseObj.Price * gameData.Discount)
            {
                BuyCar();
            }
            else
            {
                coinsNotEnoughReminder.SetActive(true);
                Invoke(nameof(HideCoinsNotEnoughReminder), HideCoinsNotEnoughReminderTimeOutSec);
            }
        }
    }
示例#4
0
 // Update car in use and apply the changes to the play page.
 public void UpdateCarInUse(CarList.Car targetCar)
 {
     carInUseName = targetCar.Name;
     _playerController.UpdateCarInUse();
 }
示例#5
0
 // Check if the user owns a specific car.
 // Return true if the user owns it; Otherwise return false.
 public bool CheckCarOwnership(CarList.Car car)
 {
     return(carIndexToOwnership[(int)car.Name] == Ownership.Owned);
 }
示例#6
0
 private void Start()
 {
     _gameManger = FindObjectOfType <GameManager>();
     // Get the carObj corresponding to the car game object the script attached to.
     _carObj = CarList.GetCarByName(carName);
 }
 private void SwitchCarInUse(CarList.Car targetCar)
 {
     GameDataController.GetGameData().UpdateCarInUse(targetCar);
     SetCarUsageStatus();
 }