Exemplo n.º 1
0
        public UpgradeEntry RollEntryFromSubList(UpgradeEntry[] list, NetworkRandom nr, int min, DateTime date, ref string log, float linkRerollChance)
        {
            UpgradeEntry r = null;

            CalculateLimit(list, date);
            float rand = nr.Float(min < 0 ? 0f : list[min].RandomLimit, 1f);

            for (int i = 0; i < list.Length; i++)
            {
                UpgradeEntry u = list[i];
                if (rand <= u.RandomLimit && CheckUpgradeCond(u, date))
                {
                    r = u;
                    break;
                }
            }
            log += $" -> {r.ID} ({rand}, {min}, {list[0].Name})";
            if (r.ListLink && nr.Float(0f, 1f) <= linkRerollChance)
            {
                UpgradeEntry li = RollEntryFromMatchingSubList(r.ID, nr, date, ref log, linkRerollChance);
                if (li != null)
                {
                    r = li;
                }
            }
            return(r);
        }
Exemplo n.º 2
0
 private static bool CheckUpgradeCond(UpgradeEntry u, DateTime d)
 {
     if (u.MinDate > d)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Fills the entry with the data of the character.
 /// </summary>
 /// <param name="statsCon"></param>
 public void FillData(int index, UpgradeEntry upgrade, bool done, int totalScrap, int totalMoney)
 {
     entryName.text   = upgrade.entryName;
     icon.color       = upgrade.repColor;
     upgradeType.text = upgrade.item.weaponType.ToString();
     this.index       = index;
     this.upgrade     = upgrade;
     this.done        = done;
     affordable       = (!done && totalMoney >= upgrade.cost && totalScrap >= upgrade.scrap);
     doneIcon.enabled = done;
 }
Exemplo n.º 4
0
    private void SetupDevelopInfo()
    {
        if (entryList.GetEntry() == null)
        {
            upgradeName.text = "";
            itemIcon.sprite  = null;

            costMoney.text   = "Cost:";
            costScrap.text   = "Scrap:";
            relatedItem.text = "Item:";

            invPwrText.text   = "";
            invRangeText.text = "";
            invHitText.text   = "";
            invCritText.text  = "";
            invReqText.text   = "";
            return;
        }

        UpgradeEntry upgrade = entryList.GetEntry().upgrade;

        upgradeName.text = upgrade.entryName;
        relatedItem.text = "Item:  " + upgrade.item.entryName;
        itemIcon.sprite  = upgrade.item.icon;
        itemIcon.color   = upgrade.repColor;

        if (entryList.GetEntry().done)
        {
            costMoney.text = "";
            costScrap.text = "";
            alreadyResearched.SetActive(true);
        }
        else
        {
            costMoney.text = "Cost:  " + upgrade.cost;
            costScrap.text = "Scrap:  " + upgrade.scrap;
            alreadyResearched.SetActive(false);
        }

        for (int i = 0; i < levelStars.Length; i++)
        {
            levelStars[i].enabled = i < upgrade.rank;
        }

        invPwrText.text   = "Power:  " + upgrade.item.power;
        invRangeText.text = "Range:  " + upgrade.item.range.ToString();
        invHitText.text   = "Hit Rate:  " + upgrade.item.hitRate;
        invCritText.text  = "Crit Rate:  " + upgrade.item.critRate;
        invReqText.text   = "Req:  " + upgrade.item.skillReq.ToString();
        return;
    }
Exemplo n.º 5
0
        public UpgradeEntry RollEntryFromMatchingSubList(string baseid, NetworkRandom nr, DateTime date, ref string log, float linkRerollChance)
        {
            UpgradeEntry[] sublist = GetUpgradeArrayAndOffset(baseid, out int min);
            UpgradeEntry   r       = null;

            if (sublist != null)
            {
                r = RollEntryFromSubList(sublist, nr, min, date, ref log, linkRerollChance);
            }
            else
            {
                log += " no sublist found";
            }
            return(r);
        }
Exemplo n.º 6
0
 public UpgradeEntry[] GetUpgradeArrayAndOffset(string comp, out int min)
 {
     foreach (UpgradeEntry[] list in Upgrades)
     {
         for (int i = 0; i < list.Length; i++)
         {
             UpgradeEntry u = list[i];
             if (u.ID.Equals(comp) && !u.ListLink)
             {
                 min = (u.AllowDowngrade || this.AllowDowngrade) ? -1 : i;
                 return(list);
             }
         }
     }
     min = -1;
     return(null);
 }
Exemplo n.º 7
0
    public override void CopyValues(ScrObjLibraryEntry other)
    {
        base.CopyValues(other);
        UpgradeEntry up = (UpgradeEntry)other;

        item = up.item;
        type = up.type;
        rank = up.rank;

        cost  = up.cost;
        scrap = up.scrap;

        power     = up.power;
        hit       = up.hit;
        crit      = up.crit;
        charges   = up.charges;
        costValue = up.costValue;
    }
Exemplo n.º 8
0
    protected override void DrawContentWindow()
    {
        UpgradeEntry upgradeEntry = (UpgradeEntry)entryValues;

        upgradeEntry.entryName = EditorGUILayout.TextField("Name", upgradeEntry.entryName);
        upgradeEntry.type      = (UpgradeType)EditorGUILayout.EnumPopup("Upgrade Type", upgradeEntry.type);
        upgradeEntry.item      = (ItemEntry)EditorGUILayout.ObjectField("Related item", upgradeEntry.item, typeof(ItemEntry), false);
        upgradeEntry.rank      = Mathf.Clamp(EditorGUILayout.IntField("Upgrade Rank", upgradeEntry.rank), 1, 5);

        upgradeEntry.cost  = EditorGUILayout.IntField("Money Cost", upgradeEntry.cost);
        upgradeEntry.scrap = EditorGUILayout.IntField("Scrap Cost", upgradeEntry.scrap);

        GUILayout.Space(10);

        if (upgradeEntry.type == UpgradeType.UPGRADE)
        {
            upgradeEntry.costValue = EditorGUILayout.IntField("Value increase", upgradeEntry.costValue);
            GUILayout.Label("Improvements", EditorStyles.boldLabel);
            upgradeEntry.power   = EditorGUILayout.IntField("Power", upgradeEntry.power);
            upgradeEntry.hit     = EditorGUILayout.IntField("Hit Rate", upgradeEntry.hit);
            upgradeEntry.crit    = EditorGUILayout.IntField("Crit Rate", upgradeEntry.crit);
            upgradeEntry.charges = EditorGUILayout.IntField("Max Charges", upgradeEntry.charges);
        }
    }
Exemplo n.º 9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="entries"></param>
 /// <param name="container"></param>
 public UpgradeEditorWindow(ScrObjLibraryVariable entries, UpgradeEntry container)
 {
     entryLibrary = entries;
     entryValues  = container;
     LoadLibrary();
 }
Exemplo n.º 10
0
        void _optimizer_EvaluateUpgradeCompleted(object sender, EvaluateUpgradeCompletedEventArgs e)
        {
            switch (currentOperation)
            {
                case AsyncOperation.BuildUpgradeList:
                    upgradeListEnumerator.Current.Value += e.UpgradeValue * CurrentBatchCharacter.Weight;
                    upgradeListEnumerator.Current.ValueList.Add(e.UpgradeValue);
                    if (upgradeListEnumerator.MoveNext())
                    {
                        EvaluateUpgradeCurrentBatchCharacter(false);
                    }
                    else
                    {
                        do
                        {
                            batchIndex++;
                        } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                        if (batchIndex < BatchCharacterList.Count)
                        {
                            upgradeListEnumerator = GetUpgradeListEnumerator();
                            upgradeListEnumerator.MoveNext();
                            EvaluateUpgradeCurrentBatchCharacter(true);
                        }
                        else
                        {
                            currentOperation = AsyncOperation.None;
                            UpdateStatusLabel();
                            if (OperationCompleted != null)
                            {
                                OperationCompleted(this, EventArgs.Empty);
                            }

                            float totalValue = 0f;
                            foreach (BatchCharacter batchCharacter in BatchCharacterList)
                            {
                                if (batchCharacter.Character != null)
                                {
                                    totalValue += batchCharacter.Weight;
                                }
                            }

                            Dictionary<CharacterSlot, List<ComparisonCalculationUpgrades>> upgrades = new Dictionary<CharacterSlot, List<ComparisonCalculationUpgrades>>();

                            foreach (var kvp in upgradeList)
                            {
                                Dictionary<string, UpgradeEntry> filtered = new Dictionary<string, UpgradeEntry>();
                                foreach (UpgradeEntry entry in kvp.Value.Values)
                                {
                                    UpgradeEntry existingEntry;
                                    filtered.TryGetValue(entry.Item.SuffixId, out existingEntry);
                                    if (entry.Value > 0 && (existingEntry == null || entry.Value > existingEntry.Value))
                                    {
                                        filtered[entry.Item.SuffixId] = entry;
                                    }
                                }

                                upgrades[kvp.Key] = new List<ComparisonCalculationUpgrades>();
                                foreach (UpgradeEntry entry in filtered.Values)
                                {
                                    ComparisonCalculationUpgrades itemCalc = new ComparisonCalculationUpgrades();
                                    itemCalc.ItemInstance = entry.Item;
                                    itemCalc.CharacterItems = null;
                                    itemCalc.Name = entry.Item.Name;
                                    itemCalc.Equipped = false;
                                    itemCalc.OverallPoints = entry.Value / totalValue;
                                    itemCalc.SubPoints = entry.ValueList.ToArray();

                                    upgrades[kvp.Key].Add(itemCalc);                                    
                                }
                            }
                            List<string> customSubpoints = new List<string>();
                            foreach (BatchCharacter batchCharacter in BatchCharacterList)
                            {
                                customSubpoints.Add(batchCharacter.Name);
                            }
                            Upgrades = upgrades;
                            CustomSubpoints = customSubpoints.ToArray();
                            if (UpgradeListCompleted != null)
                            {
                                UpgradeListCompleted(this, EventArgs.Empty);
                            }
                        }
                    }
                    break;
                case AsyncOperation.BuildProgressiveUpgradeList:
                    if (e.Cancelled || e.Error != null)
                    {
                        currentOperation = AsyncOperation.None;
                        UpdateStatusLabel();
                        if (OperationCompleted != null)
                        {
                            OperationCompleted(this, EventArgs.Empty);
                        }
                        break;
                    }
                    CharacterSlot slot = Character.GetCharacterSlotByItemSlot(optimizedItemInstance.Slot);
                    Dictionary<string, UpgradeEntry> map;
                    if (!upgradeList.TryGetValue(slot, out map))
                    {
                        map = new Dictionary<string, UpgradeEntry>();
                        upgradeList[slot] = map;
                    }
                    string key = optimizedItemInstance.SuffixId;
                    UpgradeEntry upgradeEntry;
                    if (!map.TryGetValue(key, out upgradeEntry))
                    {
                        upgradeEntry = new UpgradeEntry();
                        upgradeEntry.Item = optimizedItemInstance;
                        map[key] = upgradeEntry;
                    }
                    if (e.UpgradeValue > 0)
                    {
                        // make item restrictions based on best character
                        itemGenerator.AddItemRestrictions(e.Upgrade.CharacterItems, workingCharacter.CurrentCalculations.IncludeOffHandInCalculations(workingCharacter));
                        upgradeEntry.Value += e.UpgradeValue * CurrentBatchCharacter.Weight;
                        upgradeEntry.ValueList.Add(e.UpgradeValue);
                    }
                    else
                    {
                        // make item restrictions based on best character without using the item
                        itemGenerator.AddItemRestrictions(workingCharacter);
                        upgradeEntry.ValueList.Add(0.0f);
                    }
                    // move to next character
                    do
                    {
                        batchIndex++;
                    } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                    if (batchIndex < BatchCharacterList.Count)
                    {                        
                        // we made item restrictions, first we have to optimize character without the item
                        int _thoroughness = Thoroughness;
                        workingCharacter = CurrentBatchCharacter.Character.Clone();
                        // regularize character with current item restrictions
                        itemGenerator.RegularizeCharacter(workingCharacter);
                        optimizer.InitializeItemCache(workingCharacter, CurrentBatchCharacter.Model, itemGenerator);
                        optimizer.OptimizeCharacterAsync(workingCharacter, _thoroughness, true);
                    }
                    else
                    {
                        // we finished all characters for this item
                        // move to next item
                        itemIndex++;
                        if (itemIndex < itemList.Length)
                        {
                            batchIndex = 0;
                            upgradeListPhase = 0;
                            int _thoroughness = Thoroughness;
                            // we have to reinitialize item generator because of the restrictions we made
                            //CreateBatchItemGenerator();
                            itemGenerator.RestoreAvailabilityInformation();
                            optimizer.InitializeItemCache(CurrentBatchCharacter.Character, CurrentBatchCharacter.Model, itemGenerator);
                            workingCharacter = CurrentBatchCharacter.Character;
                            optimizer.ComputeUpgradesAsync(CurrentBatchCharacter.Character, _thoroughness, itemList[itemIndex]);
                        }
                        else
                        {
                            // we're done
                            WrapUpProgressiveUpgradeList();
                        }
                    }
                    break;
            }
        }
Exemplo n.º 11
0
 void _optimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     switch (currentOperation)
     {
         case AsyncOperation.BuildUpgradeList:
             if (e.Cancelled || e.Error != null)
             {
                 currentOperation = AsyncOperation.None;
                 UpdateStatusLabel();
                 if (OperationCompleted != null)
                 {
                     OperationCompleted(this, EventArgs.Empty);
                 }
                 break;
             }
             if (upgradeListPhase == 0)
             {
                 foreach (KeyValuePair<CharacterSlot, List<ComparisonCalculationUpgrades>> kvp in e.Upgrades)
                 {
                     Dictionary<string, UpgradeEntry> map;
                     if (!upgradeList.TryGetValue(kvp.Key, out map))
                     {
                         map = new Dictionary<string, UpgradeEntry>();
                         upgradeList[kvp.Key] = map;
                     }
                     foreach (ComparisonCalculationBase comp in kvp.Value)
                     {
                         string key = comp.ItemInstance.GemmedId;
                         UpgradeEntry upgradeEntry;
                         if (!map.TryGetValue(key, out upgradeEntry))
                         {
                             upgradeEntry = new UpgradeEntry();
                             upgradeEntry.Item = comp.ItemInstance;
                             map[key] = upgradeEntry;
                         }
                     }
                 }
                 do
                 {
                     batchIndex++;
                 } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                 if (batchIndex < BatchCharacterList.Count)
                 {
                     ComputeUpgradesCurrentBatchCharacter();
                 }
                 else
                 {
                     upgradeListPhase = 1;
                     batchIndex = 0;
                     upgradeListEnumerator = GetUpgradeListEnumerator();
                     if (upgradeListEnumerator.MoveNext())
                     {
                         EvaluateUpgradeCurrentBatchCharacter(true);
                     }
                     else
                     {
                         // upgrade list is empty, abort
                         currentOperation = AsyncOperation.None;
                         UpdateStatusLabel();
                         if (OperationCompleted != null)
                         {
                             OperationCompleted(this, EventArgs.Empty);
                         }
                         break;
                     }
                 }
             }
             break;
         case AsyncOperation.BuildProgressiveUpgradeList:
             {
                 if (e.Cancelled || e.Error != null)
                 {
                     currentOperation = AsyncOperation.None;
                     UpdateStatusLabel();
                     if (OperationCompleted != null)
                     {
                         OperationCompleted(this, EventArgs.Empty);
                     }
                     break;
                 }
                 ComparisonCalculationUpgrades bestComp = null;
                 foreach (KeyValuePair<CharacterSlot, List<ComparisonCalculationUpgrades>> kvp in e.Upgrades)
                 {
                     if (kvp.Value.Count > 0 && kvp.Value[0].OverallPoints > (bestComp != null ? bestComp.OverallPoints : 0))
                     {
                         bestComp = kvp.Value[0];
                     }
                 }
                 SuffixItem item = itemList[itemIndex];
                 CharacterSlot slot = Character.GetCharacterSlotByItemSlot(item.Item.Slot);
                 Dictionary<string, UpgradeEntry> map;
                 if (!upgradeList.TryGetValue(slot, out map))
                 {
                     map = new Dictionary<string, UpgradeEntry>();
                     upgradeList[slot] = map;
                 }
                 string key = item.SuffixId;
                 UpgradeEntry upgradeEntry;
                 if (!map.TryGetValue(key, out upgradeEntry))
                 {
                     upgradeEntry = new UpgradeEntry();
                     map[key] = upgradeEntry;
                 }
                 if (bestComp != null)
                 {
                     upgradeListPhase = 1; // item was used, from now on we do evaluate upgrade on specific item instance only
                     optimizedItemInstance = bestComp.ItemInstance;
                     // make item restrictions based on best character
                     itemGenerator.AddItemRestrictions(bestComp.CharacterItems, workingCharacter.CurrentCalculations.IncludeOffHandInCalculations(workingCharacter));
                     upgradeEntry.Item = bestComp.ItemInstance;
                     upgradeEntry.Value += bestComp.OverallPoints * CurrentBatchCharacter.Weight;
                     upgradeEntry.ValueList.Add(bestComp.OverallPoints);
                 }
                 else
                 {
                     // make item restrictions based on best character without using the item
                     itemGenerator.AddItemRestrictions(workingCharacter);
                     // with the addition of support for multiples of the same item the semantics of this changes
                     // we now treat the upgrade as completely separate item, so no need to restrict to it if it is used
                     // as that one is a separate instance
                     if (upgradeListPhase == 1)
                     {
                         upgradeEntry.Item = optimizedItemInstance;
                     }
                     upgradeEntry.ValueList.Add(0.0f);
                 }
                 // move to next character
                 do
                 {
                     batchIndex++;
                 } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
                 if (batchIndex < BatchCharacterList.Count)
                 {
                     if (upgradeListPhase == 0)
                     {
                         // so far we haven't made any changes yet
                         // we're working under assumption that the starting batch is valid i.e. an item will have the same gemming in all characters
                         int _thoroughness = Thoroughness;
                         workingCharacter = CurrentBatchCharacter.Character;
                         optimizer.InitializeItemCache(workingCharacter, CurrentBatchCharacter.Model, itemGenerator);
                         optimizer.ComputeUpgradesAsync(workingCharacter, _thoroughness, itemList[itemIndex]);
                     }
                     else
                     {
                         // we made item restrictions, first we have to optimize character without the item
                         int _thoroughness = Thoroughness;
                         workingCharacter = CurrentBatchCharacter.Character.Clone();
                         // regularize character with current item restrictions
                         itemGenerator.RegularizeCharacter(workingCharacter);
                         optimizer.InitializeItemCache(workingCharacter, CurrentBatchCharacter.Model, itemGenerator);
                         if (ConsiderMultipleNewItems)
                         {
                             optimizer.ComputeUpgradesAsync(workingCharacter, _thoroughness, itemList[itemIndex]);
                         }
                         else
                         {
                             optimizer.OptimizeCharacterAsync(workingCharacter, _thoroughness, true);
                         }
                     }
                 }
                 else
                 {
                     // we finished all characters for this item
                     // move to next item
                     itemIndex++;
                     if (itemIndex < itemList.Length)
                     {
                         batchIndex = 0;
                         upgradeListPhase = 0;
                         int _thoroughness = Thoroughness;
                         // we have to reinitialize item generator because of the restrictions we made
                         //CreateBatchItemGenerator();
                         itemGenerator.RestoreAvailabilityInformation();
                         optimizer.InitializeItemCache(CurrentBatchCharacter.Character, CurrentBatchCharacter.Model, itemGenerator);
                         workingCharacter = CurrentBatchCharacter.Character;
                         optimizer.ComputeUpgradesAsync(CurrentBatchCharacter.Character, _thoroughness, itemList[itemIndex]);
                     }
                     else
                     {
                         // we're done
                         WrapUpProgressiveUpgradeList();
                     }
                 }
             }
             break;
     }
 }
Exemplo n.º 12
0
    private void SetupUpgradeInfo()
    {
        if (entryList.GetEntry(0) == null)
        {
            upgradeName.text = "";
            itemIcon.sprite  = null;

            costMoney.text   = "Cost:";
            costScrap.text   = "Scrap:";
            relatedItem.text = "Item:";
            for (int i = 0; i < levelStars.Length; i++)
            {
                levelStars[i].enabled = false;
            }

            pwrText.gameObject.SetActive(false);
            hitText.gameObject.SetActive(false);
            critText.gameObject.SetActive(false);
            chargesText.gameObject.SetActive(false);
            costValueText.gameObject.SetActive(false);
            return;
        }

        UpgradeEntry upgrade = entryList.GetEntry().upgrade;

        upgradeName.text = upgrade.entryName;
        InventoryTuple tuple = new InventoryTuple(upgrade.item);

        tuple.UpdateUpgrades(playerData.upgrader);
        relatedItem.text = "Item:  " + tuple.entryName;
        itemIcon.sprite  = tuple.icon;
        itemIcon.color   = upgrade.repColor;

        if (entryList.GetEntry().done)
        {
            costMoney.text = "";
            costScrap.text = "";
            alreadyResearched.SetActive(true);
            pwrText.text       = "Power:  " + tuple.power;
            hitText.text       = "Hit Rate:  " + tuple.hitRate;
            critText.text      = "Crit Rate:  " + tuple.critRate;
            chargesText.text   = "Max Charges:  " + tuple.maxCharge;
            costValueText.text = "Item Value:  " + tuple.cost;
        }
        else
        {
            costMoney.text = "Cost:  " + upgrade.cost;
            costScrap.text = "Scrap:  " + upgrade.scrap;
            alreadyResearched.SetActive(false);
            pwrText.text       = "Power:  " + tuple.power + "  ->  " + (tuple.power + upgrade.power);
            hitText.text       = "Hit Rate:  " + tuple.hitRate + "  ->  " + (tuple.hitRate + upgrade.hit);
            critText.text      = "Crit Rate:  " + tuple.critRate + "  ->  " + (tuple.critRate + upgrade.crit);
            chargesText.text   = "Max Charges:  " + tuple.maxCharge + "  ->  " + (tuple.maxCharge + upgrade.charges);
            costValueText.text = "Item Value:  " + tuple.cost + "  ->  " + (tuple.cost + upgrade.costValue);
        }

        for (int i = 0; i < levelStars.Length; i++)
        {
            levelStars[i].enabled = i < upgrade.rank;
        }

        pwrText.gameObject.SetActive(upgrade.power != 0);
        hitText.gameObject.SetActive(upgrade.hit != 0);
        critText.gameObject.SetActive(upgrade.crit != 0);
        chargesText.gameObject.SetActive(upgrade.charges != 0);
        costValueText.gameObject.SetActive(upgrade.costValue != 0);
    }
Exemplo n.º 13
0
 void _optimizer_ComputeUpgradesCompleted(object sender, ComputeUpgradesCompletedEventArgs e)
 {
     switch (currentOperation)
     {
     case AsyncOperation.BuildUpgradeList:
         if (e.Cancelled || e.Error != null)
         {
             currentOperation        = AsyncOperation.None;
             buttonCancel.Enabled    = false;
             statusLabel.Text        = "";
             statusProgressBar.Value = 0;
             break;
         }
         if (upgradeListPhase == 0)
         {
             foreach (KeyValuePair <Character.CharacterSlot, List <ComparisonCalculationBase> > kvp in e.Upgrades)
             {
                 Dictionary <string, UpgradeEntry> map;
                 if (!upgradeList.TryGetValue(kvp.Key, out map))
                 {
                     map = new Dictionary <string, UpgradeEntry>();
                     upgradeList[kvp.Key] = map;
                 }
                 foreach (ComparisonCalculationBase comp in kvp.Value)
                 {
                     string       key = comp.Item.GemmedId + "." + ((comp.Enchant == null) ? "0" : comp.Enchant.Id.ToString());
                     UpgradeEntry upgradeEntry;
                     if (!map.TryGetValue(key, out upgradeEntry))
                     {
                         upgradeEntry         = new UpgradeEntry();
                         upgradeEntry.Item    = comp.Item;
                         upgradeEntry.Enchant = comp.Enchant;
                         map[key]             = upgradeEntry;
                     }
                 }
             }
             do
             {
                 batchIndex++;
             } while (batchIndex < BatchCharacterList.Count && CurrentBatchCharacter.Character == null);
             if (batchIndex < BatchCharacterList.Count)
             {
                 ComputeUpgradesCurrentBatchCharacter();
             }
             else
             {
                 upgradeListPhase      = 1;
                 batchIndex            = 0;
                 upgradeListEnumerator = GetUpgradeListEnumerator();
                 if (upgradeListEnumerator.MoveNext())
                 {
                     EvaluateUpgradeCurrentBatchCharacter(true);
                 }
                 else
                 {
                     // upgrade list is empty, abort
                     currentOperation        = AsyncOperation.None;
                     buttonCancel.Enabled    = false;
                     statusLabel.Text        = "";
                     statusProgressBar.Value = 0;
                     break;
                 }
             }
         }
         break;
     }
 }
Exemplo n.º 14
0
 public UpgradeItem(UpgradeEntry entry, bool researched = false)
 {
     upgrade         = entry;
     this.researched = researched;
 }
Exemplo n.º 15
0
    /// <summary>
    /// Does the actual loading of all the data and puts it into the game.
    /// </summary>
    public void Load()
    {
        if (saveFileData == null)
        {
            Debug.LogError("There's no file to read!");
            return;
        }

        // Read simple data
        currentTotalDays.value = simpleTotalDays[saveIndex.value].value;
        currentPlayTime.value  = simplePlayTimes[saveIndex.value].value;

        // Read data in save file
        SaveData loadedData = saveFileData.saveFiles[saveIndex.value];

        currentMoney.value = loadedData.money;
        currentScrap.value = loadedData.scrap;

        // Read map data
        currentMission.value = missionLibrary.GetEntry(loadedData.mapData.missionString);
        mapIndex.value       = loadedData.mapData.mapIndex;
        loadMapID.value      = (currentMission.value != null) ? ((MissionEntry)currentMission.value).maps[mapIndex.value].uuid : "";
        squad1.values.Clear();
        for (int i = 0; i < loadedData.mapData.squad1.Count; i++)
        {
            squad1.values.Add(new PrepCharacter(loadedData.mapData.squad1[i]));
        }
        squad2.values.Clear();
        for (int i = 0; i < loadedData.mapData.squad2.Count; i++)
        {
            squad2.values.Add(new PrepCharacter(loadedData.mapData.squad2[i]));
        }

        // Read player data
        playerData.ResetData();
        for (int i = 0; i < loadedData.upgrade.Count; i++)
        {
            UpgradeEntry upgrade = (UpgradeEntry)upgradeLibrary.GetEntry(loadedData.upgrade[i].id);
            playerData.upgrader.upgrades.Add(new UpgradeItem(upgrade, loadedData.upgrade[i].researched));
        }
        for (int i = 0; i < loadedData.characters.Count; i++)
        {
            CharEntry  cStats = (CharEntry)characterLibrary.GetEntry(loadedData.characters[i].id);
            ClassEntry cClass = (ClassEntry)classLibrary.GetEntry(loadedData.characters[i].currentClass);
            playerData.stats.Add(new StatsContainer(loadedData.characters[i], cStats, cClass));
            playerData.inventory.Add(new InventoryContainer(itemLibrary, loadedData.characters[i], playerData.upgrader));
            playerData.skills.Add(new SkillsContainer(skillLibrary, loadedData.characters[i]));
            playerData.baseInfo.Add(new SupportContainer(loadedData.characters[i]));
        }
        for (int i = 0; i < loadedData.items.Count; i++)
        {
            ItemEntry item = (ItemEntry)itemLibrary.GetEntry(loadedData.items[i].id);
            playerData.items.Add(new InventoryItem(item, loadedData.items[i].charges));
        }
        for (int i = 0; i < loadedData.missions.Count; i++)
        {
            playerData.missions.Add(new MissionProgress(loadedData.missions[i].id, loadedData.missions[i].cleared));
        }
        playerData.upgrader.CalculateResearch();
        Debug.Log("Successfully loaded the save data!");
        loadFinishedEvent.Invoke();
    }