Пример #1
0
    public Affix(AffixBase affixBase, bool isCrafted = false, bool isLocked = false)
    {
        Base        = affixBase;
        affixValues = new List <float>();
        AffixType   = affixBase.affixType;
        IsCrafted   = isCrafted;
        IsLocked    = isLocked;
        foreach (AffixBonusProperty mod in affixBase.affixBonuses)
        {
            if (mod.readAsFloat)
            {
                int roll = UnityEngine.Random.Range((int)(mod.minValue * 10f), (int)(mod.maxValue * 10f + 1));
                affixValues.Add((float)Math.Round(roll / 10d, 1));
            }
            else
            {
                affixValues.Add(UnityEngine.Random.Range((int)mod.minValue, (int)mod.maxValue + 1));
            }
        }

        if (affixBase.triggeredEffects.Count > 0)
        {
            addedEffectValues = new List <float>();
            foreach (TriggeredEffectBonusProperty addedEffect in affixBase.triggeredEffects)
            {
                int roll = UnityEngine.Random.Range((int)(addedEffect.effectMinValue * 10f), (int)(addedEffect.effectMaxValue * 10f + 1));
                addedEffectValues.Add((float)Math.Round(roll / 10d, 1));
            }
        }
    }
        private void AddWavePropertiesClick(object sender, RoutedEventArgs e)
        {
            if (StageListView.SelectedItem == null)
            {
                return;
            }
            if (EnemyWaveView.SelectedItem == null)
            {
                return;
            }
            if (WaveItemView.SelectedItem == null)
            {
                return;
            }
            if (WaveModComboBox.SelectedItem == null)
            {
                return;
            }

            EnemyWaveItem s = WaveItemView.SelectedItem as EnemyWaveItem;
            AffixBase     a = WaveModComboBox.SelectedItem as AffixBase;

            if (s.BonusProperties.Contains(a.IdName))
            {
                return;
            }
            s.BonusProperties.Add(a.IdName);
        }
Пример #3
0
    public void LoadEquipmentData()
    {
        if (equipDict == null)
        {
            equipDict = new Dictionary <Guid, EquipSaveData>();
        }
        else
        {
            equipDict.Clear();
        }

        GameManager.Instance.PlayerStats.ClearEquipmentInventory();
        foreach (EquipSaveData equipData in equipList)
        {
            Equipment equipment = null;
            if (equipData.rarity == RarityType.UNIQUE)
            {
                equipment = Equipment.CreateUniqueFromBase(equipData.baseId, equipData.ilvl, equipData.uniqueVersion);
            }
            else
            {
                equipment = Equipment.CreateEquipmentFromBase(equipData.baseId, equipData.ilvl);
            }

            if (equipment == null)
            {
                continue;
            }

            GameManager.Instance.PlayerStats.AddEquipmentToInventory(equipment);

            equipment.SetId(equipData.id);
            equipment.Name = equipData.name;
            equipment.SetRarity(equipData.rarity);

            if (equipData.rarity == RarityType.UNIQUE)
            {
                UniqueBase uniqueBase = equipment.Base as UniqueBase;
                if (uniqueBase.uniqueVersion == equipData.uniqueVersion)
                {
                    for (int i = 0; i < uniqueBase.fixedUniqueAffixes.Count; i++)
                    {
                        AffixBase affixBase = uniqueBase.fixedUniqueAffixes[i];
                        equipment.prefixes.Add(new Affix(affixBase, equipData.prefixes[i].affixValues, equipData.prefixes[i].triggerValues, false, false));
                    }
                }
            }
            else
            {
                LoadEquipmentAffixes(equipData, equipment);
            }

            equipment.UpdateItemStats();

            equipDict.Add(equipData.id, equipData);
        }
    }
        private void RandomAddButtonClick(object sender, RoutedEventArgs e)
        {
            if (EquipList.SelectedItem == null)
            {
                return;
            }
            UniqueBase uniqueBase = EquipList.SelectedItem as UniqueBase;
            AffixBase  temp       = new AffixBase
            {
                IdName    = uniqueBase.IdName + "R" + uniqueBase.RandomUniqueAffixes.Count,
                AffixType = AffixType.UNIQUE
            };

            AddPropertyListeners(uniqueBase, temp);

            uniqueBase.RandomUniqueAffixes.Add(temp);
            SortRandomAffixes();
        }
        private void RemoveAffixClick(object sender, RoutedEventArgs e)
        {
            if (ArchetypesList.SelectedItem == null)
            {
                return;
            }
            if (infusionList.SelectedItem == null || infusionList.SelectedItems.Count == 0)
            {
                return;
            }

            ArchetypeBase archetypeBase = ArchetypesList.SelectedItem as ArchetypeBase;

            for (int i = infusionList.SelectedItems.Count - 1; i >= 0; i--)
            {
                AffixBase affixBase = (AffixBase)infusionList.SelectedItems[i];
                archetypeBase.InfusionAffixes_Editor.Remove(affixBase);
            }
        }
        private void RandomCopyButtonClick(object sender, RoutedEventArgs e)
        {
            if (EquipList.SelectedItem == null)
            {
                return;
            }
            if (RandomAffixesList.SelectedItem == null)
            {
                return;
            }
            UniqueBase uniqueBase = EquipList.SelectedItem as UniqueBase;

            AffixBase temp = Helpers.DeepClone((AffixBase)RandomAffixesList.SelectedItem);

            temp.IdName = uniqueBase.IdName + "R" + uniqueBase.RandomUniqueAffixes.Count;
            AddPropertyListeners(uniqueBase, temp);
            uniqueBase.RandomUniqueAffixes.Add(temp);
            SortRandomAffixes();
        }
        private void AddPropertiesClick(object sender, RoutedEventArgs e)
        {
            if (StageListView.SelectedItem == null)
            {
                return;
            }
            if (StagePropertiesComboBox.SelectedItem == null)
            {
                return;
            }

            StageInfoCollection s = StageListView.SelectedItem as StageInfoCollection;
            AffixBase           a = StagePropertiesComboBox.SelectedItem as AffixBase;

            if (s.StageProperties.Contains(a.IdName))
            {
                return;
            }
            s.StageProperties.Add(a.IdName);
        }
        private void ConfirmClick(object sender, RoutedEventArgs e)
        {
            if (Groups.SelectedItem == null)
            {
                MessageBox.Show("Type not selected", "Error", MessageBoxButton.OK);
                return;
            }
            GroupType selectedType = GetSelectedType();
            int       t            = AffixBase.WeightContainsType(dic, selectedType);

            if (WeightInteger.Value == null)
            {
                MessageBox.Show("Value NaN", "Error", MessageBoxButton.OK);
                return;
            }

            if (t != -1)
            {
                MessageBox.Show("Key Already Exists", "Error", MessageBoxButton.OK);
                return;
            }
            else
            {
                if (isEdit)
                {
                    editTarget.type   = selectedType;
                    editTarget.weight = (int)WeightInteger.Value;
                }
                else
                {
                    AffixWeight w = new AffixWeight()
                    {
                        type   = selectedType,
                        weight = (int)WeightInteger.Value
                    };
                    dic.Insert(0, w);
                }
                this.Close();
                return;
            }
        }
        private void CopyWeight_Click(object sender, RoutedEventArgs e)
        {
            if (AffixesList.SelectedItem == null)
            {
                return;
            }

            AffixBase first = (AffixBase)AffixesList.SelectedItems[0];

            foreach (AffixBase b in AffixesList.SelectedItems)
            {
                if (b == first)
                {
                    continue;
                }
                b.SpawnWeight = new ObservableCollection <AffixWeight>();
                foreach (AffixWeight w in first.SpawnWeight)
                {
                    b.SpawnWeight.Add(w.CloneWeight());
                }
            }
        }
Пример #10
0
    public Affix(AffixBase a, List <float> values, List <float> effectValues, bool isCrafted, bool isLocked)
    {
        Base        = a;
        affixValues = new List <float>();
        AffixType   = a.affixType;
        IsCrafted   = isCrafted;
        IsLocked    = isLocked;
        int i = 0;

        foreach (AffixBonusProperty mod in a.affixBonuses)
        {
            if (mod.readAsFloat)
            {
                affixValues.Add(values[i]);
            }
            else
            {
                affixValues.Add((int)values[i]);
            }
            i++;
        }
        i = 0;
        if (a.triggeredEffects.Count > 0)
        {
            addedEffectValues = new List <float>();
            foreach (TriggeredEffectBonusProperty triggeredEffectBonus in a.triggeredEffects)
            {
                if (triggeredEffectBonus.readAsFloat)
                {
                    addedEffectValues.Add(effectValues[i]);
                }
                else
                {
                    addedEffectValues.Add((int)effectValues[i]);
                }
            }
        }
    }
Пример #11
0
    public bool AddAffix(AffixBase affix)
    {
        if (affix == null)
        {
            return(false);
        }

        if (affix.affixType == AffixType.PREFIX)
        {
            prefixes.Add(new Affix(affix, false));
        }
        else if (affix.affixType == AffixType.SUFFIX)
        {
            suffixes.Add(new Affix(affix, false));
        }
        else
        {
            return(false);
        }
        SortAffixes();
        UpdateItemStats();
        return(true);
    }
        private void AddButtonClick(object sender, RoutedEventArgs e)
        {
            if (!isContextSet)
            {
                Enum.TryParse(AffixProp, out AffixType aff);
                affixContext = aff;
            }
            AffixBase temp = new AffixBase
            {
                IdName    = "UNTITLED NEW",
                AffixType = affixContext,
                Tier      = 1
            };

            Affixes.Add(temp);


            temp.AffixBonuses.CollectionChanged     += temp.RaiseListStringChanged;
            temp.TriggeredEffects.CollectionChanged += temp.RaiseListStringChanged;

            //AffixesList.Items.Refresh();
            currentID++;
        }
Пример #13
0
    private IEnumerator SpawnEnemyList(EnemyWaveItem enemyWaveItem, float delayBetween)
    {
        spawnCoroutinesRunning++;

        if (enemyWaveItem.startDelay > 0)
        {
            spawnWarnings[enemyWaveItem.spawnerIndex].AddTimeInfo(new SpawnWarning.TimeInfo(enemyWaveItem.startDelay, currentWave));
        }

        yield return(new WaitForSeconds(enemyWaveItem.startDelay));

        Dictionary <BonusType, StatBonus> bonuses = new Dictionary <BonusType, StatBonus>();

        RarityType rarity = enemyWaveItem.enemyRarity;

        if (isSurvivalBattle)
        {
            int totalWaveCount = survivalLoopCount * Waves.Count + (currentWave + 1);

            StatBonus healthBonus = new StatBonus();
            healthBonus.AddBonus(ModifyType.MULTIPLY, 15 * survivalLoopCount);
            bonuses.Add(BonusType.MAX_HEALTH, healthBonus);

            StatBonus damageBonus = new StatBonus();
            damageBonus.AddBonus(ModifyType.MULTIPLY, 15 * survivalLoopCount);
            bonuses.Add(BonusType.GLOBAL_DAMAGE, damageBonus);
        }

        foreach (string affixName in enemyWaveItem.bonusProperties)
        {
            AffixBase affixBase = ResourceManager.Instance.GetAffixBase(affixName, AffixType.MONSTERMOD);
            foreach (AffixBonusProperty prop in affixBase.affixBonuses)
            {
                StatBonus bonus;
                if (bonuses.ContainsKey(prop.bonusType))
                {
                    bonus = bonuses[prop.bonusType];
                }
                else
                {
                    bonus = new StatBonus();
                    bonuses.Add(prop.bonusType, bonus);
                }
                bonus.AddBonus(prop.modifyType, prop.minValue);
            }
        }

        for (int j = 0; j < enemyWaveItem.enemyCount; j++)
        {
            int rarityMod = 0;
            if (survivalLoopCount > 0 && rarity < RarityType.RARE)
            {
                float rarityBoostIncrement = 0.05f;
                if (rarity == RarityType.NORMAL)
                {
                    rarityBoostIncrement = 0.08f;
                }

                float totalRarityBoostChance = survivalLoopCount * rarityBoostIncrement;
                if (Random.Range(0, 1f) < totalRarityBoostChance)
                {
                    rarityMod++;
                    if (rarity == RarityType.NORMAL && totalRarityBoostChance > 1f && Random.Range(0, 1f) < (1f - totalRarityBoostChance))
                    {
                        rarityMod++;
                    }
                }
            }
            SpawnEnemy(enemyWaveItem, bonuses, rarity + rarityMod);
            yield return(new WaitForSeconds(delayBetween));
        }
        spawnCoroutinesRunning--;
        yield break;
    }
Пример #14
0
    public static string BuildAffixString(AffixBase Base, float indent, Affix instancedAffix = null, IList <float> affixValues = null, IList <float> effectValues = null, bool showRange = false, bool showTier = false)
    {
        List <int> bonusesToSkip = new List <int>();
        string     s             = "";

        if (showTier)
        {
            indent += 2f;
            if (Base.tier > 0)
            {
                s += " T" + Base.tier;
            }
        }

        if (indent != 0)
        {
            s += "<indent=" + indent + "em>";
        }

        for (int i = 0; i < Base.affixBonuses.Count; i++)
        {
            if (bonusesToSkip.Contains(i))
            {
                continue;
            }
            AffixBonusProperty bonusProp = Base.affixBonuses[i];
            if (bonusProp.bonusType.ToString().Contains("DAMAGE_MIN") && bonusProp.modifyType == ModifyType.FLAT_ADDITION)
            {
                BonusType maxType      = (BonusType)Enum.Parse(typeof(BonusType), bonusProp.bonusType.ToString().Replace("_MIN", "_MAX"));
                int       matchedIndex = Base.affixBonuses.FindIndex(x => x.bonusType == maxType);

                if (matchedIndex > 0 && Base.affixBonuses[matchedIndex].modifyType == ModifyType.FLAT_ADDITION)
                {
                    bonusesToSkip.Add(matchedIndex);

                    if (bonusProp.restriction != GroupType.NO_GROUP)
                    {
                        s += LocalizationManager.Instance.GetLocalizationText_GroupTypeRestriction(bonusProp.restriction) + ", ";
                    }

                    s += LocalizationManager.Instance.GetLocalizationText("bonusType." + bonusProp.bonusType.ToString().Replace("_MIN", "")) + " ";
                    if (affixValues != null)
                    {
                        s += "<nobr>+" + affixValues[i] + "~" + affixValues[matchedIndex] + "</nobr>";
                        if (showRange && (bonusProp.minValue != bonusProp.maxValue || Base.affixBonuses[matchedIndex].minValue != Base.affixBonuses[matchedIndex].maxValue))
                        {
                            s += "<nobr><color=" + Helpers.AFFIX_RANGE_COLOR + "> (" + bonusProp.minValue + "-" + bonusProp.maxValue + ") (" + Base.affixBonuses[matchedIndex].minValue + "-" + Base.affixBonuses[matchedIndex].maxValue + ")</color></nobr>";
                        }
                    }
                    else
                    {
                        s += "<nobr>+(" + bonusProp.minValue + "-" + bonusProp.maxValue + ")~(" + Base.affixBonuses[matchedIndex].minValue + "-" + Base.affixBonuses[matchedIndex].maxValue + ")</nobr>";
                    }

                    s += '\n';
                    continue;
                }
            }

            if (affixValues != null)
            {
                s += LocalizationManager.Instance.GetLocalizationText_BonusType(bonusProp.bonusType, bonusProp.modifyType, affixValues[i], bonusProp.restriction);
                if (showRange && bonusProp.minValue != bonusProp.maxValue)
                {
                    s = s.TrimEnd('\n') + "<nobr><color=" + Helpers.AFFIX_RANGE_COLOR + "> (" + bonusProp.minValue + "-" + bonusProp.maxValue + ")</color></nobr>\n";
                }
            }
            else
            {
                s += LocalizationManager.Instance.GetLocalizationText_BonusType(bonusProp.bonusType, bonusProp.modifyType, bonusProp.minValue, bonusProp.maxValue, bonusProp.restriction);
            }
        }

        for (int i = 0; i < Base.triggeredEffects.Count; i++)
        {
            TriggeredEffectBonusProperty triggeredEffect = Base.triggeredEffects[i];

            if (effectValues != null)
            {
                s += LocalizationManager.Instance.GetLocalizationText_TriggeredEffect(triggeredEffect, effectValues[i]);
            }
            else
            {
                s += LocalizationManager.Instance.GetLocalizationText_TriggeredEffect(triggeredEffect, triggeredEffect.effectMinValue, triggeredEffect.effectMaxValue);
            }

            if (showRange && triggeredEffect.effectMinValue != triggeredEffect.effectMaxValue)
            {
                s = s.TrimEnd('\n') + "<nobr><color=" + Helpers.AFFIX_RANGE_COLOR + "> (" + triggeredEffect.effectMinValue + "-" + triggeredEffect.effectMaxValue + ")</color></nobr>\n";
            }
        }

        if (instancedAffix != null)
        {
            if (instancedAffix.IsLocked)
            {
                s = "<sprite=15> <color=#00802b>" + s.TrimEnd('\n') + "</color>\n";
            }
            else
            {
                s = "○ " + s;
            }
        }

        if (indent != 0)
        {
            s = s.TrimEnd('\n') + "</indent>\n";
        }

        return(s);
    }
 private static void AddPropertyListeners(UniqueBase uniqueBase, AffixBase temp)
 {
     temp.AffixBonuses.CollectionChanged += temp.RaiseListStringChanged;
     temp.AffixBonuses.CollectionChanged += uniqueBase.RaisePropertyAffixString;
 }