Esempio n. 1
0
 public static bool UnlockCreditWarp(string message)
 {
     if (get(1587) > 0)
     {
         return(false);
     }
     FoundBonusSkill(1587);
     ActiveBonus = 1587;
     message    += "\nPress " + RandomizerRebinding.BonusToggle.FirstBindName() + " to warp to credits";
     Randomizer.Print(message, 10, false, true, false, false);
     RandomizerStatsManager.WriteStatsFile();
     return(true);
 }
 // Token: 0x06003798 RID: 14232
 public static void CheckPickups(object sender, UploadValuesCompletedEventArgs e)
 {
     try
     {
         if (e.Error != null)
         {
             if (e.Error is System.NullReferenceException)
             {
                 return;
             }
             Randomizer.LogError("CheckPickups got error: " + e.Error.ToString());
         }
         if (!e.Cancelled && e.Error == null)
         {
             if (!Characters.Sein)
             {
                 return;
             }
             string[] array = System.Text.Encoding.UTF8.GetString(e.Result).Split(new char[]
             {
                 ','
             });
             int bf = int.Parse(array[0]);
             foreach (SkillInfoLine skillInfoLine in SkillInfos)
             {
                 if (getBit(bf, skillInfoLine.bit) && !Characters.Sein.PlayerAbilities.HasAbility(skillInfoLine.skill))
                 {
                     RandomizerSwitch.GivePickup(new RandomizerAction("SK", skillInfoLine.id), 0, false);
                 }
             }
             int bf2 = int.Parse(array[1]);
             foreach (EventInfoLine eventInfoLine in EventInfos)
             {
                 if (getBit(bf2, eventInfoLine.bit) && !eventInfoLine.checker())
                 {
                     RandomizerSwitch.GivePickup(new RandomizerAction("EV", eventInfoLine.id), 0, false);
                 }
             }
             int bf4 = int.Parse(array[2]);
             foreach (TeleportInfoLine teleportInfoLine in TeleportInfos)
             {
                 if (getBit(bf4, teleportInfoLine.bit) && !isTeleporterActivated(teleportInfoLine.id))
                 {
                     RandomizerSwitch.GivePickup(new RandomizerAction("TP", teleportInfoLine.id), 0, false);
                 }
             }
             if (array[3] != "")
             {
                 string[] upgrades = array[3].Split(';');
                 foreach (string rawUpgrade in upgrades)
                 {
                     string[] splitpair = rawUpgrade.Split('x');
                     int      id        = int.Parse(splitpair[0]);
                     int      cnt       = int.Parse(splitpair[1]);
                     if (id >= 100)
                     {
                         if (id >= 900)
                         {
                             if (id < 910)
                             {
                                 int    tree     = id - 899;
                                 string treeName = RandomizerTrackedDataManager.Trees[tree];
                                 if (RandomizerTrackedDataManager.SetTree(tree))
                                 {
                                     Randomizer.showHint(treeName + " tree (activated by teammate)");
                                 }
                             }
                             else if (id < 922)
                             {
                                 string relicZone = RandomizerTrackedDataManager.Zones[id - 911];
                                 if (RandomizerTrackedDataManager.SetRelic(relicZone))
                                 {
                                     Randomizer.showHint("#" + relicZone + " relic# (found by teammate)", 300);
                                 }
                             }
                         }
                         else if (!RandomizerBonusSkill.UnlockedBonusSkills.ContainsValue(id) && cnt > 0)
                         {
                             RandomizerBonus.UpgradeID(id);
                         }
                     }
                     else if (RandomizerBonus.UpgradeCount(id) < cnt)
                     {
                         RandomizerBonus.UpgradeID(id);
                     }
                     else if (!PickupQueue.Where((Pickup p) => p.type == "RB" && p.id == splitpair[0]).Any() && RandomizerBonus.UpgradeCount(id) > cnt)
                     {
                         RandomizerBonus.UpgradeID(-id);
                     }
                 }
             }
             if (array.Length > 5)
             {
                 foreach (string text in array[5].Split(new char[] { '|' }))
                 {
                     if (CurrentSignals.Contains(text))
                     {
                         continue;
                     }
                     if (text == "stop")
                     {
                         RandomizerChaosManager.ClearEffects();
                     }
                     else if (text.StartsWith("msg:"))
                     {
                         Randomizer.printInfo(text.Substring(4), 360);
                     }
                     else if (text.StartsWith("win:"))
                     {
                         if (!RandomizerBonusSkill.UnlockCreditWarp(text.Substring(4)))
                         {
                             Randomizer.Print(text.Substring(4), 10, false, true, false, false);
                             RandomizerStatsManager.WriteStatsFile();
                         }
                     }
                     else if (text.StartsWith("pickup:"))
                     {
                         string[]         parts = text.Substring(7).Split(new char[] { '|' });
                         RandomizerAction action;
                         if (Randomizer.StringKeyPickupTypes.Contains(parts[0]))
                         {
                             action = new RandomizerAction(parts[0], parts[1]);
                         }
                         else
                         {
                             int pickup_id;
                             int.TryParse(parts[1], out pickup_id);
                             action = new RandomizerAction(parts[0], pickup_id);
                         }
                         RandomizerSwitch.GivePickup(action, 0, false);
                     }
                     else if (text == "spawnChaos")
                     {
                         Randomizer.ChaosVerbose = true;
                         RandomizerChaosManager.SpawnEffect();
                         ChaosTimeoutCounter = 3600;
                     }
                     var client = new WebClient();
                     client.DownloadStringAsync(new Uri(RootUrl + "/callback/" + text));
                     CurrentSignals.Add(text);
                 }
             }
             else
             {
                 CurrentSignals.Clear();
             }
             return;
         }
         if (e.Error.GetType().Name == "WebException" && ((HttpWebResponse)((WebException)e.Error).Response).StatusCode == HttpStatusCode.PreconditionFailed)
         {
             if (Randomizer.SyncMode == 1)
             {
                 Randomizer.printInfo("Co-op server error, try reloading the seed (Alt+L)");
             }
             else
             {
                 Randomizer.LogError("Co-op server error, try reloading the seed (Alt+L)");
             }
             return;
         }
     }
     catch (Exception e2)
     {
         Randomizer.LogError("CheckPickups threw error: " + e2.Message);
     }
 }