void CollectOre(OreType type, int amount) { if (amount == 0) { return; } currentOres[(int)type] += amount; backPack += amount; OnPackFillChanged?.Invoke(backPack, backPackCap); // +amount type (total) //Debug.Log($"Gained {type} ({currentOres[(int)type]})"); if (pickupTextQueue.Count < pickupQueueLength) { // create a new one TextFade copy = Instantiate(pickupTextPrefab); pickupTextQueue.Enqueue(copy); } TextFade next = pickupTextQueue.Dequeue(); next.transform.position = transform.position + pickupOffset; // negate when facing left next.UpdateColour(type); next.SetText($"+{amount} {type} ({currentOres[(int)type]})"); next.Reset(); pickupTextQueue.Enqueue(next); // recycle //pickupText.text = $"+{amount} {type} ({currentOres[(int)type]})"; OnOreChanged?.Invoke((int)type, currentOres[(int)type]); if (IsBagFull()) { BagFull(); } }
int CalculateMoney() { int sum = 0; for (int i = 0; i < currentOres.Length; i++) { sum += (int)(currentOres[i] * oreValues[i]); currentOres[i] = 0; OnOreChanged?.Invoke(i, 0); } return(sum); }