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 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 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 onWishChanged(Wish w, bool added, bool visible, float delta) { //if (w.type != WishType.Sensible) return; WishDial possible = getPossibleWish(w.type); if (possible == null) { WishDial add_me = new WishDial(); add_me.type = w.type; ListUtil.Add <WishDial>(ref this.possible_wishes, add_me); possible = getPossibleWish(w.type); } if (w.type == WishType.Sensible) { // Debug.Log("On wishes added " + w.type + " ADD " + added + "\n"); int add = (int)w.Strength; // I have no idea why this is so //adjustment = previous wish count if (add - (int)possible.adjustment > 0) { possible.count += add - (int)possible.adjustment; } possible.adjustment = add; } else { int add = w.count; // Debug.Log("On wishes added " + w.type + " ADD " + add + "\n"); if (added) { possible.count += add; } } }
public void CalculateWishes() { //after wish dials and waves are loaded Dictionary <string, Int> monster_count = new Dictionary <string, Int>(); //get total monster count foreach (wave w in Waves) { foreach (InitWavelet wlet in w.wavelets) { foreach (InitEnemyCount e in wlet.enemies) { Int count; monster_count.TryGetValue(e.name, out count); if (count == null) { monster_count.Add(e.name, new Int(e.c)); } else { count.value += e.c; } } } } //get total count by wishtype Dictionary <WishType, Float> wish_count = new Dictionary <WishType, Float>(); foreach (KeyValuePair <string, Int> kvp in monster_count) { List <Wish> inventory = null; // Debug.Log("Get " + kvp.Key + "\n"); inventory = Central.Instance.getEnemy(kvp.Key).inventory; if (inventory == null) { Debug.Log("moon could not find inventory for " + kvp.Key + ", moving on.\n"); } foreach (Wish wish in inventory) { float more = wish.percent * (float)kvp.Value.value; Float count = null; wish_count.TryGetValue(wish.type, out count); if (count == null) { wish_count.Add(wish.type, new Float(more)); } else { count.value += more; } } } //add dummy 1 dials if we are missing settings for any int last_found = wish_dials.Length - 1; for (int i = 0; i < wish_dials.Length; i++) { // Debug.Log("i " + i + "\n"); if (wish_dials[i] == null || wish_dials[i].type == WishType.Null) { last_found = i - 1; break; } } if (last_found != wish_dials.Length - 1) { foreach (WishType val in Enum.GetValues(typeof(WishType))) { WishDial found = null; for (int i = 0; i < last_found; i++) { if (wish_dials[i].type == val) { found = wish_dials[i]; } } if (found == null) { last_found++; wish_dials[last_found] = new WishDial(val, -1, 1); } } } foreach (WishDial dial in wish_dials) { if (dial.count == -1) { continue; } Float have = null; wish_count.TryGetValue(dial.type, out have); if (have == null) { continue; } float want = dial.count; dial.adjustment = want / have.value; } EagleEyes.Instance.WaveCountUpdate(); }