Пример #1
0
        public GenericSpell FindNewSpellNew(GameObject caster, int max_spell_level)
        {
            if (caster == null)
            {
                return(null);
            }
            CharacterStats component = caster.GetComponent <CharacterStats>();

            if (component == null)
            {
                return(null);
            }
            List <GenericSpell> list = new List <GenericSpell>();
            int num = MaxSpellLevel;

            if (max_spell_level < num)
            {
                num = max_spell_level;
            }
            for (int i = 0; i < num; i++)
            {
                for (int j = 0; j < MaxSpellsPerLevel + (int)IEModOptions.ExtraWizardSpells; j++)
                {
                    if (this.Spells[i].SpellData[j] != null)
                    {
                        bool flag = false;
                        foreach (GenericAbility current in component.ActiveAbilities)
                        {
                            if (current is GenericSpell && this.Spells[i].SpellData[j].DisplayName.StringID == current.DisplayName.StringID)
                            {
                                flag = true;
                                break;
                            }
                        }
                        if (!flag)
                        {
                            list.Add(this.Spells[i].SpellData[j]);
                        }
                    }
                }
            }
            GenericSpell result = null;

            if (list.Count > 0)
            {
                int index = UnityEngine.Random.Range(0, list.Count);
                result = list[index];
            }
            return(result);
        }
Пример #2
0
		public bool HasSpellNew(GenericSpell spell)
		{
			if (spell != null)
			{
				int num = spell.SpellLevel - 1;
				if (num >= 0 && num < 6)
				{
					for (int i = 0; i < 4 + (int)IEModOptions.ExtraWizardSpells; i++)
					{
						if (this.Spells[num].SpellData[i] != null && this.Spells[num].SpellData[i].DisplayName.StringID == spell.DisplayName.StringID)
						{
							return true;
						}
					}
				}
			}
			return false;
		}
Пример #3
0
 public bool HasSpellNew(GenericSpell spell)
 {
     if (spell != null)
     {
         int num = spell.SpellLevel - 1;
         if (num >= 0 && num < MaxSpellLevel)
         {
             for (int i = 0; i < MaxSpellsPerLevel + (int)IEModOptions.ExtraWizardSpells; i++)
             {
                 if (this.Spells[num].SpellData[i] != null && this.Spells[num].SpellData[i].DisplayName.StringID == spell.DisplayName.StringID)
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Пример #4
0
		private void StartNew()
		{
			if (this.Spells.Length != 6)
			{
				if (this.Spells.Length > 6)
				{
					Debug.LogError("Too many spell levels in grimoire '" + base.name + "': some will be dropped!");
				}
				Grimoire.SpellChapter[] array = new Grimoire.SpellChapter[6];
				this.Spells.CopyTo(array, 0);
				this.Spells = array;
            
			}
			for (int i = 0; i < this.Spells.Length; i++)
			{
				if (this.Spells[i] == null)
				{
					this.Spells[i] = new Grimoire.SpellChapter();
				}
				else if (this.Spells[i].SpellData.Length != (4 + (int)IEModOptions.ExtraWizardSpells))
				{
					if (this.Spells[i].SpellData.Length > (4 + (int)IEModOptions.ExtraWizardSpells))
					{
						Debug.LogError(string.Concat(new object[]
						{
							"Too many spell slots in grimoire '",
							base.name,
							"' for level ",
							i + 1,
							": some will be dropped!"
						}));
					}
					GenericSpell[] array2 = new GenericSpell[(4 + (int)IEModOptions.ExtraWizardSpells)];
					for (int j = 0; j < Mathf.Min(array2.Length, this.Spells[i].SpellData.Length); j++)
					{
						array2[j] = this.Spells[i].SpellData[j];
					}
					this.Spells[i].SpellData = array2;
				}
			}
		}
Пример #5
0
 private void StartNew()
 {
     if (this.Spells.Length != MaxSpellLevel)
     {
         if (this.Spells.Length > MaxSpellLevel)
         {
             Debug.LogError("Too many spell levels in grimoire '" + base.name + "': some will be dropped!");
         }
         Grimoire.SpellChapter[] array = new Grimoire.SpellChapter[MaxSpellLevel];
         this.Spells.CopyTo(array, 0);
         this.Spells = array;
     }
     for (int i = 0; i < this.Spells.Length; i++)
     {
         if (this.Spells[i] == null)
         {
             this.Spells[i] = new Grimoire.SpellChapter();
         }
         else if (this.Spells[i].SpellData.Length != MaxSpellsPerLevel + (int)IEModOptions.ExtraWizardSpells)
         {
             if (this.Spells[i].SpellData.Length > MaxSpellsPerLevel + (int)IEModOptions.ExtraWizardSpells)
             {
                 Debug.LogError(string.Concat(new object[]
                 {
                     "Too many spell slots in grimoire '",
                     base.name,
                     "' for level ",
                     i + 1,
                     ": some will be dropped!"
                 }));
             }
             GenericSpell[] array2 = new GenericSpell[(MaxSpellsPerLevel + (int)IEModOptions.ExtraWizardSpells)];
             for (int j = 0; j < Mathf.Min(array2.Length, this.Spells[i].SpellData.Length); j++)
             {
                 array2[j] = this.Spells[i].SpellData[j];
             }
             this.Spells[i].SpellData = array2;
         }
     }
 }
Пример #6
0
        public void ReloadNew(int spellLevel)
        {
            this.m_SpellLevel = spellLevel;
            int      i = 0;
            Grimoire loadedGrimoire = UIGrimoireManager.Instance.LoadedGrimoire;

            if (loadedGrimoire && spellLevel - 1 < loadedGrimoire.Spells.Length)
            {
                GenericSpell[] spellData = loadedGrimoire.Spells[spellLevel - 1].SpellData;
                for (int j = 0; j < spellData.Length; j++)
                {
                    GenericSpell genericSpell = spellData[j];
                    if (!(genericSpell == null))
                    {
                        if (i >= this.m_Spells.Count)
                        {
                            Debug.LogWarning(string.Concat(new object[]
                            {
                                "Grimoire has too many spells for UI (",
                                UIGrimoireManager.Instance.LoadedGrimoire.name,
                                " S.L.",
                                spellLevel,
                                ")"
                            }));
                            break;
                        }
                        this.m_Spells[i].SetSpell(genericSpell);
                        this.m_Spells[i].SetVisibility(true);
                        this.m_Spells[i].SetSelected(i < (4 + (int)IEModOptions.ExtraWizardSpells) && spellLevel == UIGrimoireManager.Instance.LevelButtons.CurrentLevel);
                        this.m_Spells[i].SetDisabled(GameState.InCombat || !UIGrimoireManager.Instance.CanEditGrimoire);
                        i++;
                    }
                }
            }
            while (i < this.m_Spells.Count)
            {
                this.m_Spells[i].SetVisibility(false);
                i++;
            }
        }
Пример #7
0
        public static bool mod_ShowOnSpellBar(GenericAbility ability, CharacterStats stats, int spellLevel)
        {
            if (ability.Passive)
            {
                return(false);
            }
            GenericSpell         genericSpell         = ability as GenericSpell;
            GenericCipherAbility genericCipherAbility = ability as GenericCipherAbility;

            if (!genericSpell)
            {
                return(genericCipherAbility && (spellLevel <= 0 || genericCipherAbility.SpellLevel == spellLevel));
            }

            if (genericSpell.SpellClass != stats.CharacterClass && spellLevel > 0 && genericSpell.SpellLevel == spellLevel && IEModOptions.HideAnticlassSpells)
            {
                return(true);
            }

            if (genericSpell.SpellClass != stats.CharacterClass || (spellLevel > 0 && genericSpell.SpellLevel != spellLevel))
            {
                return(false);
            }
            if (stats.CharacterClass != CharacterStats.Class.Wizard || !genericSpell.NeedsGrimoire)
            {
                return(true);
            }
            Equipment component = stats.GetComponent <Equipment>();

            if (component == null || component.CurrentItems == null || component.CurrentItems.Grimoire == null)
            {
                return(false);
            }
            Grimoire component2 = component.CurrentItems.Grimoire.GetComponent <Grimoire>();

            return(!(component2 == null) && component2.HasSpell(genericSpell));
        }
Пример #8
0
        public void mod_FindNewSpells(List <GenericSpell> newSpells, CharacterStats casterStats, int maxSpellLevel)
        {
            if (!casterStats)
            {
                return;
            }
            int num = Mathf.Min(maxSpellLevel, 8);

            for (int i = 0; i < num; i++)
            {
                for (int j = 0; j < MaxSpellsPerLevel + (int)IEModOptions.ExtraWizardSpells; j++)
                {
                    GenericSpell spellData = this.Spells[i].SpellData[j];
                    if (spellData != null)
                    {
                        bool flag = false;
                        IEnumerator <GenericAbility> enumerator = casterStats.ActiveAbilities.GetEnumerator();
                        try
                        {
                            while (enumerator.MoveNext())
                            {
                                GenericAbility current = enumerator.Current;
                                if (!(current is GenericSpell) || spellData.DisplayName.StringID != current.DisplayName.StringID)
                                {
                                    continue;
                                }
                                flag = true;
                                break;
                            }
                        }
                        finally
                        {
                            if (enumerator == null)
                            {
                            }
                            enumerator.Dispose();
                        }
                        if (!flag && !newSpells.Contains(spellData))
                        {
                            newSpells.Add(spellData);
                        }
                    }
                }
            }
            //if (caster == null)
            //{
            //	return null;
            //}
            //CharacterStats component = caster.GetComponent<CharacterStats>();
            //if (component == null)
            //{
            //	return null;
            //}
            //List<GenericSpell> list = new List<GenericSpell>();
            //int num = MaxSpellLevel;
            //if (max_spell_level < num)
            //{
            //	num = max_spell_level;
            //}
            //for (int i = 0; i < num; i++)
            //{
            //	for (int j = 0; j < MaxSpellsPerLevel + (int)IEModOptions.ExtraWizardSpells; j++)
            //	{
            //		if (this.Spells[i].SpellData[j] != null)
            //		{
            //			bool flag = false;
            //			foreach (GenericAbility current in component.ActiveAbilities)
            //			{
            //				if (current is GenericSpell && this.Spells[i].SpellData[j].DisplayName.StringID == current.DisplayName.StringID)
            //				{
            //					flag = true;
            //					break;
            //				}
            //			}
            //			if (!flag)
            //			{
            //				list.Add(this.Spells[i].SpellData[j]);
            //			}
            //		}
            //	}
            //}
            //GenericSpell result = null;
            //if (list.Count > 0)
            //{
            //	int index = UnityEngine.Random.Range(0, list.Count);
            //	result = list[index];
            //}
            //return result;
        }