예제 #1
0
 // Update is called once per frame
 public override void Update()
 {
     base.Update();
     if (!mInitialized)
     {
         if (SelectedRank >= 0)
         {
             DnDWizard wizard = (DnDWizard)((DnDCharacter)Storage.Character).Classes.Find(x => x.CharacterClass == DnDCharClass.Wizard);
             if (wizard != null)
             {
                 var schools = Enum.GetValues(typeof(DnDMagicSchool)).Cast <DnDMagicSchool>();
                 List <DnDMagicSchool> castable = schools.ToList();
                 castable.RemoveAll(x => wizard.ForbiddenSchools.Contains(x));
                 mSpellsToDisplay = new List <Spell>();
                 foreach (DnDMagicSchool school in castable)
                 {
                     mSpellsToDisplay.AddRange(AppStorage.Instance.SpellList.GetWizardSchoolSpecializationSpells(school, SelectedRank));
                 }
                 if (wizard.KnownSpells.Count > SelectedRank)
                 {
                     mSpellsToDisplay.RemoveAll(x => wizard.KnownSpells[SelectedRank].Find(y => y.Equals(x)) != null);
                 }
                 mSpellsToDisplay.Sort();
                 InitButtons();
             }
         }
     }
 }
예제 #2
0
 private void Reset()
 {
     mSetText = false;
     if (mSoul != null)
     {
         mSoul.KnownSpells.Clear();
         mSoul = null;
     }
 }
예제 #3
0
        public void ButtonCLickHandler(int notification, int senderID, GameObject sender)
        {
            DnDWizard wizard = (DnDWizard)((DnDCharacter)Storage.Character).Classes.Find(x => x.CharacterClass == DnDCharClass.Wizard);

            if (wizard != null && SelectedRank >= 0)
            {
                // add spell:
                wizard.AddSpellToKnownList(mSpellsToDisplay[notification], SelectedRank);
                // disable button:
                ViewUtility.EnableSimpleButton(mButtons[notification], false);
            }
        }
예제 #4
0
        private void SetValues()
        {
            DnDWizard wizard = (DnDWizard)((DnDCharacter)Storage.Character).Classes.Find(x => x.CharacterClass == DnDCharClass.Wizard);

            if (wizard != null)
            {
                wizard.Specialization = (DnDMagicSchool)((int)SpecSlider.value);
                wizard.ForbiddenSchools.Clear();
                if (wizard.Specialization != DnDMagicSchool.NONE)
                {
                    wizard.ForbiddenSchools.Add((DnDMagicSchool)((int)ForbiddenOneSlider.value));
                    wizard.ForbiddenSchools.Add((DnDMagicSchool)((int)ForbiddenTwoSlider.value));
                }
            }
        }
예제 #5
0
 public override void Update()
 {
     if (mWizard == null)
     {
         mWizard = (DnDWizard)((DnDCharacter)Storage.Character).Classes.Find(x => x.CharacterClass == DnDCharClass.Wizard);
     }
     if (!mInitialized)
     {
         if (mWizard != null)
         {
             mNumberOfButtons = mWizard.HighestCastableRank;                     // Rank 0 is not needed (otherwhise would be +1)
             InitButtons();
         }
     }
     base.Update();
 }
예제 #6
0
        public override void Next()
        {
            int level = 1;

            if (!string.IsNullOrEmpty(LevelInput.text))
            {
                level = int.Parse(LevelInput.text);
            }
            DnDCharClass chosen     = (DnDCharClass)((int)ClassSlider.value);
            DnDClassSoul soul       = null;
            int          nextScreen = -1;

            switch (chosen)
            {
            case DnDCharClass.Wizard:
                soul       = new DnDWizard((DnDCharacter)Storage.Character, level);
                nextScreen = cWizardScreen;
                break;

            default:
                break;
            }
            if (soul != null)
            {
                ((DnDCharacter)Storage.Character).Classes.Add(soul);
            }
            if (nextScreen >= 0)
            {
                Storage.Screens[nextScreen].SetActive(true);
                this.gameObject.SetActive(false);
            }
            else
            {
                SwitchScene(ScreenBase.SCENE_SPELLMASTERY);
            }
        }
예제 #7
0
 // Update is called once per frame
 public override void Update()
 {
     base.Update();
     if (mSoul == null)
     {
         mSoul = ((DnDCharacter)(Storage.Character)).Classes.Find(x => x.CharacterClass == DnDCharClass.Wizard) as DnDWizard;
     }
     if (!mSetText)
     {
         mSetText = true;
         int numberOfUnknownSpells = 0;
         for (int i = 1; i <= mSoul.HighestCastableRank; ++i)
         {
             numberOfUnknownSpells += mSoul.NumberofUnknownSpells(i);
         }
         //disabling button if no more spells can be added:
         ViewUtility.EnableSimpleButton(transform.FindChild("Menu").FindChild("AddSpellsButton").gameObject, numberOfUnknownSpells != 0);
         // setting the top text:
         if (TopText != null)
         {
             if (mSoul.HighestCastableRank < 0)
             {
                 TopText.text = string.Format(cSpellBookExplanation, string.Format(cLowAbility, mSoul.SpellModifier.ToString()));
             }
             else if (mSoul.KnownSpells.Count == 0)
             {
                 AddZeroRankSpells();
                 TopText.text = string.Format(cSpellBookExplanation, cAddedZeroRankText);
             }
             else if (numberOfUnknownSpells == 0)
             {
                 TopText.text = cCantAddMore;
             }
             else
             {
                 TopText.text = string.Format(cSpellBookExplanation, cAddMoreText);
             }
         }
         // setting the current known spell texts:
         if (FirstRanksText != null && LastRanksText != null)
         {
             int    rank      = -1;
             string textFirst = "";
             string textLast  = "";
             foreach (var list in mSoul.KnownSpells)
             {
                 rank++;
                 if (rank > cMaxRankFirst)
                 {
                     textLast += string.Format(cShortRankText, rank, list.Count);
                     if (rank < cMaxRankLast)
                     {
                         textLast += "\n";
                     }
                 }
                 else
                 {
                     textFirst += string.Format(cShortRankText, rank, list.Count);
                     if (rank < cMaxRankFirst)
                     {
                         textFirst += "\n";
                     }
                 }
             }
             FirstRanksText.text = textFirst;
             LastRanksText.text  = textLast;
         }
     }
 }