public void PurchaseProduct(Product item) { CurrentMoney -= item.Price; if (CurrentMoney > 0) { foreach (var fe in moneyHandler.ReturnMoney(Pouch, CurrentMoney)) { ToReturn.Add(fe); } CurrentMoney = 0; } OnPropertyChanged(nameof(BankFT)); ((RelayCommand)ProductPurchaseCommand).RaiseCanExecuteChanged(); }
public void InstallMoney(int money) { if (ToReturn.Any()) { ToReturn.Clear(); } if (CurrentMoney < 1000) { CurrentMoney += money; moneyHandler.InstallMoney(Pouch, ref _bank, money); OnPropertyChanged(nameof(BankFT)); ((RelayCommand)ProductPurchaseCommand).RaiseCanExecuteChanged(); } }
static double GetAvgSum(List <int> array, ToReturn Rtrn) { double sum = 0.0d; double avg = 0.0d; for (int i = 0; i < array.Count; i++) { int currValue = array[i]; sum += currValue; } avg = sum / (double)array.Count; //Return options if (Rtrn == ToReturn.Avg) { return(avg); } return(sum); }
/// <summary> /// Gives One Object from pool. /// Usage: GameObject FromPool = Pool.GetFromPool(); /// </summary> public GameObject GetFromPool() { GameObject ToReturn; if (Objects.Count > 0) { //if there is an object in pool ToReturn = Objects[0]; Objects.RemoveAt(0); //Dont lose the referance //Why? i dont know! //nevermind, i deleted it ///TODO Maybe we should cashe PoolMember referance? //More event thingies YAAAY!!! ToReturn.GetComponent <PoolMember>().OnPoolOut(); //dont lose referance ObjectsInUse.Add(ToReturn); return(ToReturn); } if (Original == null) { Debug.LogError("Object Pool is empty. And we cant Instantiate new poll member because Original is missing. Returning A cube."); return(GameObject.CreatePrimitive(PrimitiveType.Cube)); } Debug.LogWarning("Object Pool For " + Original.name + "is empty!" + " Creating a new object and adding to the pool"); //else then make a new object ToReturn = Instantiate(Original); //Add PoolMember Script ToReturn.AddComponent <PoolMember>(); //PoolMember pm = ToReturn.AddComponent<PoolMember>(); //its on the pool //pm.OnPoolEnter(); //aaaand out //pm.OnPoolOut(); //this "if" is for my compiler :] thanks for all the warnings you give me, i can write code more elegantly. //Really thanks... Much thanks.. if (ToReturn != null) { //dont lose referance ObjectsInUse.Add(ToReturn); return(ToReturn); } Debug.LogError("::ERROR WE CANT INSTANTIATE A NEW OBJECT IN POOL." + " WE ARE PRETTY F****D UP RIGHT NOW:::"); //aaw nevermind i can give him a cube. that will solve it return(GameObject.CreatePrimitive(PrimitiveType.Cube)); }
/// <summary> /// The override of the ToString method /// </summary> /// <returns>Returns the book title and when it's supposed to be returned</returns> public override string ToString() { return(BookCopy.Book.Title + "To be returned: " + ToReturn.ToString()); }