/// <summary> /// Delivers an Item from the StoreManager to the Player's inventory as well as the change of that /// transaction, this also updates the Currency and Item UIs. /// </summary> /// <param name="item">Item bought by the player</param> /// <param name="currency">The type of currency used in the transaction</param> /// <param name="change">The change from the transaction</param> private void OnDeliverItem(Item item, CurrencyType currency, int change) { _myItems.Add(item); currencies[(int)currency] = change; GameObserverManager.OnUpdateCurrencies(currency, change); GameObserverManager.OnAddItem(item); }
/// <summary> /// This collects all the currencies that are in the _collectablesInRange list, also calling the /// CurrencySpawnManager singleton to handle their deactivation in the pool, finally it uses the /// GameObserverManager to update the Currencies UI. /// </summary> private void CollectCurrenciesInRange() { if (Input.GetButtonDown("Jump")) { foreach (GameObject collectable in _collectablesInRange) { Currency current = collectable.GetComponent <Currency>(); currencies[(int)current.MyCurrencyType]++; CurrencySpawnerManager.Instance.DeactivateCurrency(collectable); } for (int i = 0; i < currencies.Length; i++) { GameObserverManager.OnUpdateCurrencies((CurrencyType)i, currencies[i]); } } }
/// <summary> /// Update is called once per frame, this checks the current state of the Player Interact to handle /// movement and other interactions /// </summary> void Update() { // The Browsing state refers to when the player has the Store open if (_currentInteractState != PlayerInteractState.Browsing) { MovePlayer(); CheckTalkableInRange(); // The Collecting state refers to when the player isn't near a talking NPC if (_currentInteractState == PlayerInteractState.Collecting) { CheckCollectableInRange(); CollectCurrenciesInRange(); } // The Talking state refers to when the player is near a talking NPC if (_currentInteractState == PlayerInteractState.Talking) { TalkWithNPC(); } } else { StoreBrowsing(); } // Cheat Code - Press X for CASH if (Input.GetKeyDown(KeyCode.X)) { currencies = new[] { 10, 10, 10, 10, 10 }; for (var i = 0; i < currencies.Length; i++) { int currency = currencies[i]; GameObserverManager.OnUpdateCurrencies((CurrencyType)i, currency); } } }