public Wish(string t) { type = Get.WishTypeFromString(t); Strength = 1; percent = 0; setAbs(); }
public Wish(WishType _type, float _strength, float _percent) { type = _type; Strength = _strength; percent = _percent; setAbs(); }
public string oldLoadWishes() { string line = file.Dequeue(); WishDial[] dials = new WishDial[Enum.GetValues(typeof(WishType)).Length]; int current = 0; while (line != null && !line[0].Equals(':')) { if (current < dials.Length) { JSONParser p = new JSONParser(line); p.parse(); JSONObject wishtype = new JSONObject(); JSONObject count = new JSONObject(); p.root.TryGetValue("wishtype", out wishtype); p.root.TryGetValue("count", out count); if (wishtype == null || count == null) { continue; } int c = int.Parse(count.value); WishType type = Get.WishTypeFromString(wishtype.value); dials[current] = new WishDial(type, c); current++; } line = file.Dequeue(); } Moon.Instance.SetWishDials(dials); return(line); }
public Wish(WishType t, float _strength, string n) { type = t; Strength = _strength; percent = 0; name = n; setAbs(); }
public float GetWish(WishType type) { if (type == WishType.Sensible) { return(wishes[0].my_wish.Strength); } Debug.Log("Trying to getWish of type " + type + ", not good\n"); return(0); }
public List <WishData> GetWishLogList(WishType type) { QueryParam param = new QueryParam() { WishType = type, Page = 1, Size = 6, EndId = 0 }; return(GetWishLogList(param)); }
public TemporarySaver getSaver(WishType type) { TemporarySaver saver = new TemporarySaver(); saver.percent = this.percent; saver.remaining_time = this.remaining_time; saver.my_name = this.my_name; saver.type = type; return(saver); }
//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 Wish getWish(WishType type) { foreach (Wish w in inventory) { if (w.type == type) { return(w); } } return(null); }
public WishDial getPossibleWish(WishType type) { foreach (WishDial d in possible_wishes) { if (d.type == type) { return(d); } } return(null); }
// STRENGTH for Sensible // COUNT for other potions public int GetWishCount(WishType type) { if (type == WishType.Sensible) { return(Mathf.FloorToInt(wishes[0].my_wish.strength)); } for (int i = 1; i < wishes.Count; i++) { if (wishes[i].my_wish.type == type) { return(wishes[i].my_wish.count); } } return(0); }
public void onWishChanged(Wish w, bool added, bool visible, float delta) { WishType tryme = Get.WishTypeFromString(text); if (condition == Condition.GotWish) { if (w.type == tryme) { selected = CheckWish(tryme); } } else if (condition == Condition.WishUsed) { //selected = (RewardOverseer.Instance.Total_wishes_used >= number); } }
public bool HaveWish(WishType type, float strength) { if (type == WishType.Sensible) { return(wishes[0].my_wish.Strength >= strength); } for (int i = 1; i < wishes.Count; i++) { if (wishes[i].my_wish.type == type) { return(wishes[i].my_wish.count >= strength); } } return(false); }
void Start() { _Item.SetActive(false); btns.Add(_ExpBtn); btns.Add(_MoneyBtn); btns.Add(_BabyBtn); btns.Add(_HuobanBtn); UIManager.SetButtonEventHandler(_ExpBtn.gameObject, EnumButtonEvent.OnClick, OnClickExp, 0, 0); UIManager.SetButtonEventHandler(_MoneyBtn.gameObject, EnumButtonEvent.OnClick, OnClickMoney, 1, 0); UIManager.SetButtonEventHandler(_BabyBtn.gameObject, EnumButtonEvent.OnClick, OnClickBaby, 2, 0); UIManager.SetButtonEventHandler(_HuobanBtn.gameObject, EnumButtonEvent.OnClick, OnClickHuoban, 3, 0); UIManager.SetButtonEventHandler(_XuyuanBtn.gameObject, EnumButtonEvent.OnClick, OnClickXuyuan, 0, 0); UIManager.SetButtonEventHandler(_TaoluBtn.gameObject, EnumButtonEvent.OnClick, OnClickTaolu, 0, 0); UIManager.SetButtonEventHandler(_CloseBtn.gameObject, EnumButtonEvent.OnClick, OnClickClose, 0, 0); _Wtype = WishType.WIT_Exp; SelectBtn(0); }
bool CheckWish(WishType tryme) //RETIRED { //satisfied by any wish of that type List <Wish> all = Peripheral.Instance.my_inventory.getWishList(); foreach (Wish w in all) { if (w.type == tryme && w.Strength >= number) { return(true); } } return(false); }
public float getWishSpawnAdjustment(WishType type) { foreach (WishDial dial in wish_dials) { if (dial.type != type) { continue; } float base_adjustment = dial.adjustment; float level_mod = Peripheral.Instance.getLevelMod().sensible_wish_uplift; if (type == WishType.Sensible) { base_adjustment *= (1 + level_mod); } if (level_mod == -99) { return(0); //used by tutorial gameevent } WishDial current_wishes_dial = ScoreKeeper.Instance.getPossibleWish(type); int current_wishes = (current_wishes_dial != null) ? current_wishes_dial.count : 0; //Peripheral.Instance.my_inventory.GetWishCount(type); float max_wishes = (float)(dial.count); if (current_wishes < max_wishes * 0.50f) { return(base_adjustment); } if (current_wishes < max_wishes * 0.75f) { return(base_adjustment * 0.8f); } if (current_wishes < max_wishes) { return(base_adjustment * 0.6f); } return(base_adjustment * .50f); } return(1); }
public void LoadWish(InitLevel level) { WishDial[] dials = new WishDial[level.wishes.Length]; for (int i = 0; i < level.wishes.Length; i++) { WishType type = EnumUtil.EnumFromString <WishType>(level.wishes[i].wishtype, WishType.Null); if (type == WishType.Null) { Debug.Log("Trying to load Null wishtype from file\n"); continue; } dials[i] = new WishDial(type, level.wishes[i].count); } Moon.Instance.SetWishDials(dials); }
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); }
public Temporary(GenericPanel panel, WishType type, float _percent, float _time, string label_name, bool has_label) { percent = _percent; remaining_time = _time; if (has_label) { getLabel(panel); label.content = label_name; label.gameObject.name = label_name; Sprite sp = Resources.Load("GUI/Inventory/" + type.ToString() + "_image", typeof(Sprite)) as Sprite; label.image.sprite = sp; panel.AddLabel(label, true, true); panel.UpdatePanel(); Blink(); } else { Debug.Log("Has no label!\n"); } }
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); }
public InitWish(WishType wishtype, int count) { this.wishtype = wishtype.ToString(); this.count = count; }
/* * public void StopTween(GameObject obj){ * Tweener[] stopme = obj.GetComponentsInChildren<Tweener> (); * for (int i = 0; i < stopme.Length; i++) * { * stopme[i].StopMe(); * } * } */ public void Do() { // Debug.Log("Doing gameaction " + this._type + " " + this.name + " " + _text + "\n"); switch (_type) { case ActionType.UIFilter: if (_name.Equals("")) { EagleEyes.Instance.ResetUIFilter(); } else { EagleEyes.Instance.SetUIFilter(_name, _text); } break; case ActionType.SetSensibleWishUplift: Peripheral.Instance.getLevelMod().sensible_wish_uplift = _number; break; case ActionType.Panel: if (Peripheral.Instance == null) { Debug.Log("NO PERIPHERAL\n"); return; } if (Peripheral.Instance.zoo == null) { Debug.Log("NO ZOO\n"); return; } GameObject panel = Peripheral.Instance.zoo.getObject(_name, true); if (panel == null) { Debug.LogError("GameAction could not find object " + _name + "\n"); } if (!_bool) { panel.transform.SetParent(EagleEyes.Instance.events.transform); } else { panel.transform.SetParent(EagleEyes.Instance.world_space_events.transform); } panel.gameObject.transform.GetChild(0).gameObject.SetActive(true); panel.transform.localPosition = Vector3.zero; panel.transform.localScale = Vector3.one; panel.transform.localRotation = Quaternion.identity; break; case ActionType.ShowIslands: Debug.Log("Show islands " + _name + " " + _bool); IslandType type = EnumUtil.EnumFromString <IslandType>(_name, IslandType.Null); if (type == IslandType.Null) { Debug.LogError("Event trying to show (" + _bool + ")islands of invalid type: " + _name + "\n"); return; } Monitor.Instance.ShowIslandSprites(_bool, type); break; case ActionType.EnemyDescription: GameObject enemy_desc = Peripheral.Instance.zoo.getObject("Tutorial/Descriptions/generic_enemy_description", true); if (enemy_desc == null) { Debug.LogError("GameAction could not find object " + _name + "\n"); } enemy_desc.transform.SetParent(EagleEyes.Instance.events.transform); enemy_desc.gameObject.transform.GetChild(0).gameObject.SetActive(true); enemy_desc.transform.localPosition = Vector3.zero; enemy_desc.transform.localScale = Vector3.one; enemy_desc.transform.localRotation = Quaternion.identity; enemy_desc.GetComponent <EnemyDescriptionLabel>().setType(_text); RectTransform b = enemy_desc.GetComponent <EnemyDescriptionButton>().button; Vector3 pos = b.localPosition; pos.y += _number * -6.5f; //Debug.Log(_number + "\n"); b.localPosition = pos; break; case ActionType.MakeFloaty: //GameObject floaty = Peripheral.Instance.zoo.getObject(_name, true); //if (floaty == null) { Debug.Log("GameAction could not find object " + _name + "\n"); } // floaty.GetComponent<Floaty>().Init(_vector); break; case ActionType.AddWish: WishType w = Get.WishTypeFromString(_text); // Debug.Log("We should add a wish " + _text + " " + w + "\n"); Peripheral.Instance.my_inventory.AddWish(w, _number, 1); break; case ActionType.AddDream: if (_number <= 0) { return; } Peripheral.Instance.addDreams(_number, Vector3.zero, false); break; case ActionType.GiveSpecialSkill: EffectType effect_type = EnumUtil.EnumFromString <EffectType>(_name, EffectType.Null); RuneType rune_type = EnumUtil.EnumFromString <RuneType>(_text, RuneType.Null); Rune r = Central.Instance.getHeroRune(rune_type); if (r == null) { Debug.LogError("Cannot find a rune for hero of type " + rune_type + ", cannot give skill " + effect_type + "\n"); } r.GiveSpecialSkill(effect_type); break; case ActionType.MakeWish: List <Wish> inv = new List <Wish>(); inv.Add(new Wish(WishType.Sensible, 0.2f * _number)); inv.Add(new Wish(WishType.MoreDamage, 0.1f * _number)); inv.Add(new Wish(WishType.MoreXP, 015f * _number)); inv.Add(new Wish(WishType.MoreDreams, 0.1f * _number)); inv.Add(new Wish(WishType.MoreHealth, 0.1f * _number)); if (onMakeWish != null) { onMakeWish(inv, _vector); } Debug.Log("We should make a wish\n"); break; case ActionType.Pause: Peripheral.Instance.Pause(true); break; case ActionType.Resume: // Debug.Log("Resuming\n"); Peripheral.Instance.Pause(false); break; case ActionType.DisableMonitor: Monitor.Instance.is_active = _bool; break; case ActionType.HideUIElement: //name is include, //text is exclude // Debug.Log("Setting " + _name + " to " + _bool + "\n"); EagleEyes.Instance.PlaceElement(_name, _bool); break; case ActionType.DisableUIElement: //name is include, //text is exclude //BUTTON HAS TO BE in GUI STATES WITH A MYLABEL EagleEyes.Instance.DisableElement(_name, _bool); //EagleEyes.Instance.SetEnableButtons(_name, _text, _bool); break; case ActionType.RemoveEventObjects: RemoveEventObjects(); break; case ActionType.UnlockToy: Debug.Log("Unlocking toy " + _text + "\n"); //Peripheral.Instance.ActivateToy(_text); unitStats toy = Central.Instance.getToy(_text); toy.isUnlocked = true; EagleEyes.Instance.UpdateToyButtons("blah", ToyType.Null, false); break; case ActionType.PointSpyGlass: if (Monitor.Instance != null) { Monitor.Instance.my_spyglass.PointSpyglass(_vector, true); } break; case ActionType.EnableSpyGlass: if (Monitor.Instance != null) { Monitor.Instance.my_spyglass.DisableByEvent(!_bool); } break; case ActionType.RemoveObject: if (_target != null) { foreach (GameObject t in _target) { Peripheral.Instance.zoo.returnObject(t); } } if (_name != null) { Debug.Log("GameAction removing object with name, TERRIBLE\n"); } Peripheral.Instance.zoo.returnObject(GameObject.Find(_name)); break; case ActionType.EnableReward: RewardType rt = EnumUtil.EnumFromString <RewardType>(_text, RewardType.Null); if (rt != RewardType.Null) { RewardOverseer.RewardInstance.EnableReward(rt); } else { Debug.LogError(this.gameObject.name + " RewardType gameAction has an invalid rewardType( " + _text + ")\n"); } break; default: Debug.LogError(this.gameObject.name + " " + _type + " gameAction has an unsupported ActionType\n"); break; } }
public void Init(WishType w, float _strength) { stats = new Wish(w, initStrength); stats.Strength = _strength; }
public WishDial(WishType _type, int _count, float _adj) //GLOBAL settings per wishtype { type = _type; count = _count; adjustment = _adj; }
void OnClickHuoban(ButtonScript obj, object args, int param1, int param2) { _Wtype = WishType.WIT_Employee; SelectBtn(param1); }
void OnClickBaby(ButtonScript obj, object args, int param1, int param2) { _Wtype = WishType.WIT_Baby; SelectBtn(param1); }
public WishDial() { type = WishType.Null; count = 0; adjustment = 0; }
public WishDial(WishType _type, int _count) //GLOBAL settings per wishtype { type = _type; count = _count; }
void onWishMake(List <Wish> inventory, Vector3 pos) { float random = UnityEngine.Random.Range(0, 1f); // Debug.Log("On make Wish\n"); bool make = false; Wish e = new Wish(); string h = ""; float random_place = 0; float strength = 0f; for (int i = 0; i < inventory.Count; i++) { WishType t = inventory[i].type; if (t == WishType.Null) { continue; } // if (t == WishType.MoreXP) { continue; } e = inventory[i]; strength = e.Strength; h += "init strength " + strength; float percent = e.percent * Moon.Instance.getWishSpawnAdjustment(t); percent = (LevelBalancer.Instance.am_enabled) ? percent * LevelBalancer.Instance.currentPointPercent : percent; random_place += percent; if (random < random_place) { make = true; if (t != WishType.Sensible) { break; } if (random < random_place * 1f / 10f) { strength += e.Strength; } if (random < random_place * 1f / 5f) { strength += e.Strength; } break; } } if (make) { //if (strength > 3)Debug.Log("Want to make wish " + e.type + " strength " + strength + " " + h + "\n") ; GameObject wish = Peripheral.Instance.zoo.getObject("Wishes/" + e.type.ToString(), false); Effect_Button w = wish.GetComponent <Effect_Button>(); if (w == null) { Peripheral.Instance.zoo.returnObject(wish); } wish.transform.localRotation = Quaternion.identity; wish.transform.SetParent(Wishes.Instance.transform); Vector3 p = Get.fixPosition(pos); p.z = 5f; wish.transform.position = p; w.Init(e.type, strength); wish.SetActive(true); } }