//I hate this shit why did I do this // Sensible - STRENGTH = amount. COUNT = 1. // OTHER - STRENGTH = 1. COUNT = amout. public float AddWish(WishType type, float strength, int count) { // Debug.Log($"Adding wish {type} {strength} {count}\n"); if (type == WishType.Sensible) { wishes[0].my_wish.Strength += strength; onWishChanged?.Invoke(wishes[0].my_wish, strength > 0, true, strength); EagleEyes.Instance.UpdateToyButtons("blah", ToyType.Temporary, false); //EagleEyes.Instance.WishUpdate(wishes[0], true); return(wishes[0].my_wish.Strength); } if (count < 0) { SubtractWish(type, -count); return(GetWishCount(type)); } MyWishButton button = _getWishButton(type, strength); Wish w = null; if (button) { button.setCount(count, false); w = button.my_wish; w.Count += count; } else { string w_name = count.ToString(); w = new Wish(type, strength, w_name); w.Count = count; Wishlet wlet = new Wishlet(w, _getEmptyLabel()); if (wlet.my_label == null) { Debug.Log("Could not add wish because ran out of inventory slots!\n"); return(0); } wlet.my_label.InitWish(w); wlet.my_label.SetActive(true); wlet.my_label.SetInteractable(true); wishes.Add(wlet); ((MyWishButton)wlet.my_label.ui_button).setCount(count, true); } onWishChanged?.Invoke(w, true, true, strength); //EagleEyes.Instance.UpdateToyButtons("blah", ToyType.Temporary); return(strength); }
public bool SubtractWish(WishType type, float strength) { if (type != WishType.Sensible) { for (int i = 1; i < wishes.Count; i++) { if (wishes[i].my_wish.type != type) { continue; } if (!HaveWish(type, strength)) { return(false); } MyWishButton b = (MyWishButton)wishes[i].my_label.ui_button; wishes[i].my_wish.Count -= Mathf.FloorToInt(strength); int count = wishes[i].my_wish.Count; if (count >= 1) { //wishes[i].my_wish.Count--; b.setCount(count, true); } else { _removeWishLabel(i); wishes.RemoveAt(i); } return(true); } return(false); } if (!HaveWish(type, strength)) { return(false); } wishes[0].my_wish.Strength -= strength; onWishChanged?.Invoke(wishes[0].my_wish, false, true, strength); return(true); }
MyWishButton _getWishButton(WishType type, float strength) { // Debug.Log("Trying to get wishbutton for " + type + " " + strength + "\n"); foreach (GenericPanel panel in my_panels) { foreach (MyLabel l in panel.list) { if (l.type.Equals("inventory")) { MyWishButton checkme = (MyWishButton)l.ui_button; // Debug.Log("checking " + checkme.gameObject.name + " " + checkme.interactable + " " + checkme.my_wish.type + " " + checkme.my_wish.strength + "\n"); if (checkme.interactable && checkme.my_wish.type == type && Mathf.Approximately(checkme.my_wish.Strength, strength)) { return(checkme); } } } } // Debug.Log("DID NOT FIND wishbutton for " + type + " " + strength + "\n"); return(null); }