// 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(); }
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; } }
// 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); } } }
// Update car in use and apply the changes to the play page. public void UpdateCarInUse(CarList.Car targetCar) { carInUseName = targetCar.Name; _playerController.UpdateCarInUse(); }
// 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); }
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(); }