public void Update() { if (RemoveFromFromOnClick == null || TransferToOnClick == null) { return; } else if (UICamera.hoveredObject == gameObject) { if (InterfaceActionManager.RawScrollWheelAxis > 0.01f || InterfaceActionManager.RawScrollWheelAxis < -0.01f) { bool playSound = false; if (RemoveFromFromOnClick.TryToRemove(NumToRemoveOnClick * 5, CurrencyType, false)) { TransferToOnClick.Add(NumToRemoveOnClick * 5, CurrencyType); playSound = true; } if (playSound) { MasterAudio.PlaySound(SoundType, SoundNameSuccess); } else { MasterAudio.PlaySound(SoundType, SoundNameFailure); } } } }
public static bool Add(BankInfo bankInfo) { bankInfo.BankId = GetMaxId() + 1; return(dal.Add(bankInfo)); }
public void MakeChange(int baseCurrencyValue, IBank bankToTransferTo) { if (baseCurrencyValue <= 0 || bankToTransferTo == this) { return; } int lumensTransferred = 0; int goldTransferred = 0; int warlockTransferred = 0; int silverTransferred = 0; int bronzeTransferred = 0; //probably a better way to do this but whatever while (mLumen > 0 && baseCurrencyValue >= (mLumen * Globals.BaseValueLumen)) { mLumen--; lumensTransferred++; baseCurrencyValue -= Globals.BaseValueLumen; } while (mGold > 0 && baseCurrencyValue >= (mGold * Globals.BaseValueGold)) { mGold--; goldTransferred++; baseCurrencyValue -= Globals.BaseValueGold; } while (mWarlock > 0 && baseCurrencyValue >= (mWarlock * Globals.BaseValueWarlock)) { mWarlock--; warlockTransferred++; baseCurrencyValue -= Globals.BaseValueWarlock; } while (mSilver > 0 && baseCurrencyValue >= (mSilver * Globals.BaseValueSilver)) { mSilver--; silverTransferred++; baseCurrencyValue -= Globals.BaseValueSilver; } //if we still have something left if (baseCurrencyValue > 0) { if (mBronze >= baseCurrencyValue) { //transfer everything mBronze -= baseCurrencyValue; bronzeTransferred = baseCurrencyValue; baseCurrencyValue = 0; } else { //transfer what we can bronzeTransferred = mBronze; baseCurrencyValue -= Bronze; mBronze = 0; } } bankToTransferTo.Add(bronzeTransferred, WICurrencyType.A_Bronze); bankToTransferTo.Add(silverTransferred, WICurrencyType.B_Silver); bankToTransferTo.Add(goldTransferred, WICurrencyType.C_Gold); bankToTransferTo.Add(lumensTransferred, WICurrencyType.D_Luminite); bankToTransferTo.Add(warlockTransferred, WICurrencyType.E_Warlock); RefreshAction.SafeInvoke(); OnMoneyAdded.SafeInvoke(); }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(BaseBankTable model) { return(dal.Add(model)); }
IEnumerator FillContainerOverTime(bool immediately) { if (!immediately) { yield return(null); //wait for a tick to let recepticles etc. update properties } State.LastFillTime = WorldClock.AdjustedRealTime; //fill container WIStackError error = WIStackError.None; WIStackContainer container = worlditem.StackContainer; int numDesired = State.NumberOfItems; int numAdded = 0; int lastItemIndex = 0; int maxDuplicates = 3; bool continueFilling = true; int hashCode = Mathf.Abs((worlditem.Group.Props.UniqueID + worlditem.FileName).GetHashCode()); int numDuplicates = 0; bool belowDuplicateThreshold = true; GenericWorldItem genericItem = null; WICategory category = null; IBank bank = null; if (State.FillBank) { Character character = null; if (worlditem.Is <Character> (out character) && character.HasBank) { bank = character.InventoryBank; Bank.FillWithRandomCurrency(bank, character.State.Flags.Wealth); } } switch (State.NumberOfItemsRandomness) { case ContainerFillRandomness.Slight: default: numDesired = Mathf.Max(1, numDesired + UnityEngine.Random.Range(-1, 1)); break; case ContainerFillRandomness.Moderate: numDesired = Mathf.Max(1, numDesired + UnityEngine.Random.Range(-5, 5)); break; case ContainerFillRandomness.Extreme: numDesired = Mathf.Max(1, numDesired + UnityEngine.Random.Range(-10, 10)); break; } yield return(null); switch (State.FillMethod) { case ContainerFillMethod.AllRandomItemsFromCategory: default: if (WorldItems.Get.Category(State.WICategoryName, out category)) { Dictionary <string, int> itemsSoFar = new Dictionary <string, int> (); if (category.HasMinInstanceItems) { gMinInstanceItems.Clear(); category.GetMinInstanceItems(gMinInstanceItems); for (int i = 0; i < gMinInstanceItems.Count; i++) { if (itemsSoFar.TryGetValue(gMinInstanceItems [i].PrefabName, out numDuplicates)) { numDuplicates++; itemsSoFar [gMinInstanceItems [i].PrefabName] = numDuplicates; } else { itemsSoFar.Add(gMinInstanceItems [i].PrefabName, 1); } StackItem item = gMinInstanceItems [i].ToStackItem(); if (item != null) { if (State.AddCurrencyToBank && bank != null && item.Is("Currency")) { bank.Add(Mathf.FloorToInt(item.BaseCurrencyValue), item.CurrencyType); item.Clear(); } else { //add the generic item to the container as a stack item if (!Stacks.Add.Items(item, container, ref error)) { continueFilling = false; } else { numAdded++; } } } } gMinInstanceItems.Clear(); } yield return(null); while (continueFilling && category.GetItem(State.Flags, hashCode, ref lastItemIndex, out genericItem)) { //make sure we don't have a duplicate if (itemsSoFar.TryGetValue(genericItem.PrefabName, out numDuplicates)) { numDuplicates++; if (numDuplicates < maxDuplicates) { itemsSoFar [genericItem.PrefabName] = numDuplicates; } else { belowDuplicateThreshold = false; } } else { itemsSoFar.Add(genericItem.PrefabName, 1); } yield return(null); if (belowDuplicateThreshold) { //this might be a currency item - if it is, add it to the bank StackItem item = genericItem.ToStackItem(); if (State.AddCurrencyToBank && bank != null && item.Is("Currency")) { bank.Add(Mathf.FloorToInt(item.BaseCurrencyValue), item.CurrencyType); item.Clear(); } else { //add the generic item to the container as a stack item if (!Stacks.Add.Items(item, container, ref error)) { continueFilling = false; } else { numAdded++; } } } //are we done yet? if (numAdded >= numDesired || container.IsFull || !belowDuplicateThreshold) { continueFilling = false; } //wait a tick unless we need to finish this immediately //if (!immediately) { yield return(null); //} } } break; case ContainerFillMethod.OneRandomItemFromCategory: if (WorldItems.Get.Category(State.WICategoryName, out category)) { if (category.GetItem(State.Flags, hashCode, ref lastItemIndex, out genericItem)) { for (int i = 0; i < numDesired; i++) { if (!Stacks.Add.Items(genericItem.ToStackItem(), container, ref error)) { break; } else { numAdded++; } if (container.IsFull) { break; } } } } break; case ContainerFillMethod.SpecificItems: if (WorldItems.Get.Category(State.WICategoryName, out category)) { for (int i = 0; i < State.SpecificItems.Count; i++) { GenericWorldItem specificItem = State.SpecificItems [i]; Stacks.Add.Items(specificItem.ToStackItem(), container, ref error); } } break; } State.NumTimesFilled++; mIsFilling = false; yield return(null); if (worlditem.Is <Stolen> ()) { //the goods in a stolen container are also marked as stolen Stacks.Add.ScriptToItems(container, "Stolen"); } yield break; }