public void TryToFillContainer(bool immediately) { if (mDestroyed) { Debug.Log("Stack container is destroyed, not filling"); return; } Purse purse = null; if (worlditem.Is <Purse> (out purse)) { //purses are simple FillPurse(purse); return; } if (!worlditem.IsStackContainer) { return; } if (mIsFilling) { return; } if (State.HasBeenFilled && !TimeToFill) { return; } mIsFilling = true; StartCoroutine(FillContainerOverTime(immediately)); }
protected void FillPurse(Purse purse) { if (State.FillMethod == ContainerFillMethod.SpecificItems) { purse.State.Bronze += State.PurseBronze; purse.State.Silver += State.PurseSilver; purse.State.Gold += State.PurseGold; purse.State.Lumen += State.PurseLumen; purse.State.Warlock += State.PurseWarlock; } else { //cumulative //TODO this is very temp - use game seed for random values and global settings for spawn values if (Flags.Check(State.Flags.Wealth, 0, Flags.CheckType.MatchAny)) { purse.State.Bronze += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseBronzeCurrency); purse.State.Silver += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseSilverCurrency); } if (Flags.Check(State.Flags.Wealth, 1, Flags.CheckType.MatchAny)) { purse.State.Bronze += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseBronzeCurrency); purse.State.Silver += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseSilverCurrency); purse.State.Gold += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseGoldCurrency); } if (Flags.Check(State.Flags.Wealth, 2, Flags.CheckType.MatchAny)) { purse.State.Silver += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseSilverCurrency); purse.State.Gold += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseGoldCurrency); purse.State.Lumen += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseLumenCurrency); } if (Flags.Check(State.Flags.Wealth, 4, Flags.CheckType.MatchAny)) { purse.State.Silver += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseSilverCurrency); purse.State.Gold += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseGoldCurrency); purse.State.Lumen += Mathf.FloorToInt(UnityEngine.Random.value * Globals.AveragePurseLumenCurrency); } } //update our local base currency value so the purse is worth what's really in it worlditem.Props.Local.BaseCurrencyValue = purse.State.TotalValue; Finish(); }