protected override void InitClassSelection()
        {
            SetTopText("Select a class");
            DnDCharacter character    = (DnDCharacter)AppStorage.Instance.CurrentCharacter;
            GameObject   buttonPref   = Resources.Load(cTwoPartPrefab) as GameObject;
            int          buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight;
            int          spacing      = (int)DragArea.transform.FindChild("ScrollArea").GetComponent <VerticalLayoutGroup>().spacing;

            buttonHeight += spacing;
            for (int i = 0; i < character.Classes.Count; ++i)
            {
                if (character.Classes[i].NeedsToPrepareSpells)
                {
                    GameObject button = GameObject.Instantiate(buttonPref) as GameObject;
                    button.transform.SetParent(DragArea.transform.FindChild("ScrollArea"));
                    ViewUtility.ChangeTwoPartButtonText(character.Classes[i].CharacterClass.ToString(), "level  " + character.Classes[i].ClassLevel, button);
                    button.GetComponent <IntButtonHandler>().NotificationInt     = i;
                    button.GetComponent <IntButtonHandler>().NotificationCatcher = this;
                    mTotalHeight += buttonHeight;
                    mButtonList.Add(button);
                }
            }
            if (mViewHeight < mTotalHeight)
            {
                mTotalHeight -= spacing;
            }
            if (mButtonList.Count == 1)
            {
                int selected = mButtonList[0].GetComponent <IntButtonHandler>().NotificationInt;
                int sender   = mButtonList[0].GetComponent <IntButtonHandler>().ButtonID;
                ButtonCLickHandler(selected, sender, gameObject);
            }
            UpdateNow = true;
        }
        protected override void InitRankSelection()
        {
            SetTopText("Select the spell Rank");
            DnDCharacter character = (DnDCharacter)AppStorage.Instance.CurrentCharacter;

            if (mSelectedClass > character.Classes.Count)
            {
                return;
            }
            DnDClassSoul soul = character.Classes[mSelectedClass];

            GameObject buttonPref   = Resources.Load(cSimplePrefab) as GameObject;
            int        buttonHeight = (int)buttonPref.GetComponent <LayoutElement>().minHeight;
            int        spacing      = (int)DragArea.transform.FindChild("ScrollArea").GetComponent <VerticalLayoutGroup>().spacing;

            buttonHeight += spacing;
            for (int i = 0; i < soul.KnownSpells.Count; ++i)
            {
                GameObject button = GameObject.Instantiate(buttonPref) as GameObject;
                button.transform.SetParent(DragArea.transform.FindChild("ScrollArea"));
                ViewUtility.ChangeSimpleButtonText("rank  " + i, button);
                button.GetComponent <IntButtonHandler>().NotificationInt     = i;
                button.GetComponent <IntButtonHandler>().NotificationCatcher = this;
                mTotalHeight += buttonHeight;
                ViewUtility.EnableSimpleButton(button, soul.KnownSpells[i].Count > 0);
                mButtonList.Add(button);
            }
            if (mViewHeight < mTotalHeight)
            {
                mTotalHeight -= spacing;
            }
            UpdateNow = true;
        }
        public override void Next()
        {
            DnDCharacter character = (DnDCharacter)AppStorage.Instance.CurrentCharacter;

            if (character.Classes.Count < mSelectedClass)
            {
                return;
            }
            DnDClassSoul soul = character.Classes[mSelectedClass];

            if (soul.KnownSpells.Count < mSelectedRank)
            {
                return;
            }
            List <Spell> rank = soul.KnownSpells[mSelectedRank];

            if (rank.Count < mSelectedSpell)
            {
                return;
            }
            Spell spell = rank[mSelectedSpell];

            if (mSelectedSpellSender == cRegularSpell)
            {
                soul.PrepareMainSpell(spell, mSelectedRank);
            }
            else if (mSelectedSpellSender == cExtraSpell)
            {
                soul.PrepareExtraSpell(spell, mSelectedRank);
            }
        }
        private string GetExtraTopText()
        {
            DnDCharacter character = (DnDCharacter)AppStorage.Instance.CurrentCharacter;

            if (character.Classes.Count < mSelectedClass)
            {
                return("");
            }
            DnDClassSoul soul = character.Classes[mSelectedClass];

            if (soul.KnownSpells.Count < mSelectedRank)
            {
                return("");
            }

            string result = "p / u";

            if (soul.CanCastExtraSpell)
            {
                result += " / +";
            }
            int prepared = soul.NumberOfPreparedMainSpells(mSelectedRank);
            int unused   = soul.SpellsPerDay()[mSelectedRank] - prepared;

            result += "\n" + prepared + "  /  " + unused;
            if (soul.CanCastExtraSpell)
            {
                int extra = soul.NumberOfPreparedExtraSpells(mSelectedRank);
                result += "  /  " + extra;
            }
            return(result);
        }
Esempio n. 5
0
        private void InitCharacters()
        {
            string data = "";

            data = IOManager.ReadData(mFilePath + cCharFileName);
            if (!string.IsNullOrEmpty(data))
            {
                mCharacters.Clear();
                JSONObject obj   = JSONObject.Parse(data);
                JSONArray  array = obj.GetArray(SerializableObject.CHARACTER_LIST);
                foreach (var val in array)
                {
                    PlayerCharacter newChar = null;
                    CharacterGame   game    = (CharacterGame)(int)val.Array[0].Number;
                    switch (game)
                    {
                    case CharacterGame.DnD_3_5:
                        newChar = new DnDCharacter();
                        break;

                    default:
                        break;
                    }
                    if (newChar != null)
                    {
                        newChar.Deserialize(val.Array[1].Obj);
                        mCharacters.Add(newChar);
                    }
                }
            }
        }
        protected override void InitSpellSelection()
        {
            SetTopText("Prepare spells", GetExtraTopText());
            DnDCharacter character = (DnDCharacter)AppStorage.Instance.CurrentCharacter;

            if (character.Classes.Count < mSelectedClass)
            {
                return;
            }
            DnDClassSoul soul = character.Classes[mSelectedClass];

            if (soul.KnownSpells.Count < mSelectedRank)
            {
                return;
            }

            mCurrentSpells = soul.KnownSpells[mSelectedRank];
            mCurrentSpells.Sort();
            if (soul.CanCastExtraSpell)
            {             // double buttons
                InitDualButtons();
            }
            else
            {             // single buttons
                InitSimpleButtons();
            }
        }
Esempio n. 7
0
        protected override void InitSpellSelection()
        {
            DnDCharacter character = (DnDCharacter)AppStorage.Instance.CurrentCharacter;

            if (character.Classes.Count < mSelectedClass)
            {
                return;
            }
            mSoul = character.Classes[mSelectedClass];

            if (mSoul.NeedsToPrepareSpells)
            {
                SetTopText("Cast spells", "");
                InitPreparedSpells();
            }
            else
            {
                SetTopText("Cast spells", GetExtraTopText());
                InitKnownSpells();
            }
            int spacing = (int)DragArea.transform.FindChild("ScrollArea").GetComponent <VerticalLayoutGroup>().spacing;

            if (mViewHeight < mTotalHeight)
            {
                mTotalHeight -= spacing;
            }
        }
Esempio n. 8
0
 private void Start()
 {
     if (AppStorage.Instance.CurrentCharacter != null)
     {
         if (AppStorage.Instance.CurrentCharacter.GetType() == typeof(DnDCharacter))
         {
             DnDCharacter character = AppStorage.Instance.CurrentCharacter as DnDCharacter;
             SelectedAlignment = character.Alignment;
         }
         else
         {
             SelectedAlignment = DnDAlignment.TrueNeutral;
         }
     }
     else
     {
         SelectedAlignment = DnDAlignment.TrueNeutral;
     }
     mPreviousSelected = (int)SelectedAlignment;
     if (ButtonBox != null)
     {
         for (int row = 0; row < mRows; ++row)
         {
             for (int column = 0; column < mColumns; ++column)
             {
                 Button button       = ButtonBox.transform.GetChild(row).GetChild(column).GetComponent <Button>();
                 int    notification = row * mRows + column;
                 button.onClick.AddListener(() => OnSelectedButtonChange(notification));
             }
         }
         OnSelectedButtonChange(mPreviousSelected);
     }
 }
        private void SetRaceText(Transform parent)
        {
            DnDCharacter character = AppStorage.Instance.CurrentCharacter as DnDCharacter;
            Text         text      = parent.FindChild(cView).FindChild("Text").GetComponent <Text>();

            text.text = string.Format(cRaceText, character.Race.ToString());
            Slider slider = parent.FindChild(cInput).FindChild("Slider").GetComponent <Slider>();

            slider.value = (int)character.Race;
            text         = parent.FindChild(cInput).FindChild("SliderText").GetComponent <Text>();
            text.text    = character.Race.ToString();
        }
Esempio n. 10
0
        private void SetGenderText(Transform parent)
        {
            DnDCharacter character = AppStorage.Instance.CurrentCharacter as DnDCharacter;
            Text         text      = parent.FindChild(cView).FindChild("Text").GetComponent <Text>();

            text.text = string.Format(cGenderText, character.Gender.ToString());
            var genders = Enum.GetValues(typeof(CharacterGender)).Cast <CharacterGender>().ToArray();

            for (int i = 0; i < genders.Length; ++i)
            {
                bool   chosen = character.Gender == genders[i];
                Toggle toggle = parent.FindChild(cInput).FindChild("GenderGroup").GetChild(i).GetComponent <Toggle>();
                toggle.isOn = chosen;
            }
        }
Esempio n. 11
0
        private void SetValues()
        {
            DnDCharacter character = (DnDCharacter)Storage.Character;
            var          genders   = Enum.GetValues(typeof(CharacterGender)).Cast <CharacterGender>().ToArray();

            for (int i = 0; i < genders.Length; ++i)
            {
                Toggle toggle = GenderGroup.transform.GetChild(i).GetComponent <Toggle>();
                if (toggle.isOn)
                {
                    character.Gender = genders[i];
                }
            }
            character.Race      = (DnDRace)(int)RaceObject.GetComponentInChildren <Slider>().value;
            character.Alignment = AlignmentGrid.SelectedAlignment;
        }
        static void Main(string[] args)
        {
            Console.WriteLine("200812 Lecture"); // sanity check

            Console.WriteLine("\nBase Character ---------------------------------");
            // create an instance of the DnDCharacter class and call availble methods
            DnDCharacter baseCharacter = new DnDCharacter("base character", 3, 7, 9);

            baseCharacter.OutputProps();
            baseCharacter.Attack();
            Console.WriteLine("--------------------------------------------------");

            Console.WriteLine("\nFighter Character ---------------------------------");
            // create an instance of the Fighter class and call availble methods
            Fighter fighter1 = new Fighter("fighter character", 2, 8, 6);

            fighter1.OutputProps();
            fighter1.Attack();
            // fighter1.Slash();
            fighter1.StockUp();
            fighter1.StockWeapons();
            Console.WriteLine("---------------------------------------------------");

            Console.WriteLine("\nWizard Character ---------------------------------");
            // create an instance of the Wizard class and call availble methods
            Wizard wizard1 = new Wizard("wizard character", 1, 10, 3, "casting awesome spells");

            wizard1.OutputProps();
            wizard1.Attack();
            wizard1.OutputMagic();
            // wizard1.Spell();
            wizard1.StockUp();
            wizard1.StockMagicItems();
            wizard1.StockMagicItems();
            wizard1.StockMagicItems();
            wizard1.RemoveFromInventory(2);             // passing an integer calls the method that accepts an intger
            wizard1.RemoveFromInventory("cooked meat"); // passing a string calls the method that accepts a string
            Console.WriteLine("---------------------------------------------------");
        }
Esempio n. 13
0
        private void SetAbilitiesTexts(Transform parent)
        {
            DnDCharacter character = AppStorage.Instance.CurrentCharacter as DnDCharacter;
            // str:
            Text text    = parent.FindChild(cView).FindChild("Left").FindChild("Str").FindChild("Value").GetComponent <Text>();
            int  ability = character.Abilities[DnDAbilities.Strength];

            text.text = ability.ToString();
            text      = parent.FindChild(cView).FindChild("Left").FindChild("Str").FindChild("Mod").GetComponent <Text>();
            ability   = (ability / 2 - 5);
            if (ability >= 0)
            {
                text.text = "+" + ability.ToString();
            }
            else
            {
                text.text = "  " + ability.ToString();
            }
            // dex:
            text      = parent.FindChild(cView).FindChild("Left").FindChild("Dex").FindChild("Value").GetComponent <Text>();
            ability   = character.Abilities[DnDAbilities.Dexterity];
            text.text = ability.ToString();
            text      = parent.FindChild(cView).FindChild("Left").FindChild("Dex").FindChild("Mod").GetComponent <Text>();
            ability   = (ability / 2 - 5);
            if (ability >= 0)
            {
                text.text = "+" + ability.ToString();
            }
            else
            {
                text.text = "  " + ability.ToString();
            }
            // con:
            text      = parent.FindChild(cView).FindChild("Left").FindChild("Con").FindChild("Value").GetComponent <Text>();
            ability   = character.Abilities[DnDAbilities.Constitution];
            text.text = ability.ToString();
            text      = parent.FindChild(cView).FindChild("Left").FindChild("Con").FindChild("Mod").GetComponent <Text>();
            ability   = (ability / 2 - 5);
            if (ability >= 0)
            {
                text.text = "+" + ability.ToString();
            }
            else
            {
                text.text = "  " + ability.ToString();
            }
            // int:
            text      = parent.FindChild(cView).FindChild("Right").FindChild("Int").FindChild("Value").GetComponent <Text>();
            ability   = character.Abilities[DnDAbilities.Intelligence];
            text.text = ability.ToString();
            text      = parent.FindChild(cView).FindChild("Right").FindChild("Int").FindChild("Mod").GetComponent <Text>();
            ability   = (ability / 2 - 5);
            if (ability >= 0)
            {
                text.text = "+" + ability.ToString();
            }
            else
            {
                text.text = " " + ability.ToString();
            }
            // wis:
            text      = parent.FindChild(cView).FindChild("Right").FindChild("Wis").FindChild("Value").GetComponent <Text>();
            ability   = character.Abilities[DnDAbilities.Wisdom];
            text.text = ability.ToString();
            text      = parent.FindChild(cView).FindChild("Right").FindChild("Wis").FindChild("Mod").GetComponent <Text>();
            ability   = (ability / 2 - 5);
            if (ability >= 0)
            {
                text.text = "+" + ability.ToString();
            }
            else
            {
                text.text = " " + ability.ToString();
            }
            // cha:
            text      = parent.FindChild(cView).FindChild("Right").FindChild("Cha").FindChild("Value").GetComponent <Text>();
            ability   = character.Abilities[DnDAbilities.Charisma];
            text.text = ability.ToString();
            text      = parent.FindChild(cView).FindChild("Right").FindChild("Cha").FindChild("Mod").GetComponent <Text>();
            ability   = (ability / 2 - 5);
            if (ability >= 0)
            {
                text.text = "+" + ability.ToString();
            }
            else
            {
                text.text = " " + ability.ToString();
            }
            // input placeholders:
            text      = parent.FindChild(cInput).FindChild("Left").FindChild("Str").FindChild("InputField").FindChild("Placeholder").GetComponent <Text>();
            text.text = character.Abilities[DnDAbilities.Strength].ToString();
            text      = parent.FindChild(cInput).FindChild("Left").FindChild("Dex").FindChild("InputField").FindChild("Placeholder").GetComponent <Text>();
            text.text = character.Abilities[DnDAbilities.Dexterity].ToString();
            text      = parent.FindChild(cInput).FindChild("Left").FindChild("Con").FindChild("InputField").FindChild("Placeholder").GetComponent <Text>();
            text.text = character.Abilities[DnDAbilities.Constitution].ToString();
            text      = parent.FindChild(cInput).FindChild("Right").FindChild("Int").FindChild("InputField").FindChild("Placeholder").GetComponent <Text>();
            text.text = character.Abilities[DnDAbilities.Intelligence].ToString();
            text      = parent.FindChild(cInput).FindChild("Right").FindChild("Wis").FindChild("InputField").FindChild("Placeholder").GetComponent <Text>();
            text.text = character.Abilities[DnDAbilities.Wisdom].ToString();
            text      = parent.FindChild(cInput).FindChild("Right").FindChild("Cha").FindChild("InputField").FindChild("Placeholder").GetComponent <Text>();
            text.text = character.Abilities[DnDAbilities.Charisma].ToString();
        }
Esempio n. 14
0
        private IEnumerator InitView()
        {
            float onePerCent = Screen.height / 100f;
            float multiplier = 0.18f;

            if (mFirstTime)
            {
                mFirstTime = false;
            }
            else
            {
                onePerCent = 1f;
                multiplier = 1f;
            }
            mTotalHeight = 0;
            const float  cWaitTime = 0.01f;
            DnDCharacter character = AppStorage.Instance.CurrentCharacter as DnDCharacter;
            // TOP:
            float         heightMultiplier = Screen.height * .2f / 160;
            Transform     currentParent    = transform.FindChild("Top");
            RectTransform rect             = currentParent.GetComponent <RectTransform>();

            rect.localScale = new Vector3(heightMultiplier, heightMultiplier, heightMultiplier);
            Image AvatarImage = currentParent.FindChild("Avatar").FindChild("AvatarMask").FindChild("Avatar").GetComponent <Image>();

            AvatarImage.sprite = ViewUtility.CreateSpriteUseTexture(character.AvatarBytes, AvatarImage);
            // MENU:
            // name:
            currentParent = transform.FindChild("Menu").FindChild("DragArea").FindChild("ScrollArea").FindChild("Name");
            Text text = currentParent.FindChild(cView).GetComponent <Text>();

            text.text = character.Name;
            text      = currentParent.FindChild(cInput).FindChild("Placeholder").GetComponent <Text>();
            text.text = character.Name;
            float current = currentParent.GetComponent <LayoutElement>().minHeight;

            currentParent.GetComponent <LayoutElement>().minHeight = current * multiplier * onePerCent;
            mTotalHeight += (int)currentParent.GetComponent <LayoutElement>().minHeight;
            UpdateNow     = true;
            currentParent.gameObject.SetActive(true);
            yield return(new WaitForSeconds(cWaitTime));

            // level / xp
            currentParent = transform.FindChild("Menu").FindChild("DragArea").FindChild("ScrollArea").FindChild("ExpLevel");
            currentParent.FindChild(cInput).FindChild("InputField").FindChild("Placeholder").GetComponent <Text>().text = character.Experience.ToString();
            currentParent.FindChild(cView).FindChild("Bottom").FindChild("Value").GetComponent <Text>().text            = character.Experience.ToString();
            currentParent.FindChild(cView).FindChild("Top").FindChild("Value").GetComponent <Text>().text = character.CharacterLevel.ToString();
            current = currentParent.GetComponent <LayoutElement>().minHeight;
            currentParent.GetComponent <LayoutElement>().minHeight = current * multiplier * onePerCent;
            mTotalHeight += (int)currentParent.GetComponent <LayoutElement>().minHeight;
            UpdateNow     = true;
            currentParent.gameObject.SetActive(true);
            yield return(new WaitForSeconds(cWaitTime));

            // abilities
            currentParent = transform.FindChild("Menu").FindChild("DragArea").FindChild("ScrollArea").FindChild("Attributes");
            SetAbilitiesTexts(currentParent);
            current = currentParent.GetComponent <LayoutElement>().minHeight;
            currentParent.GetComponent <LayoutElement>().minHeight = current * multiplier * onePerCent;
            mTotalHeight += (int)currentParent.GetComponent <LayoutElement>().minHeight;
            UpdateNow     = true;
            currentParent.gameObject.SetActive(true);
            yield return(new WaitForSeconds(cWaitTime));

            // gender:
            currentParent = transform.FindChild("Menu").FindChild("DragArea").FindChild("ScrollArea").FindChild("Gender");
            SetGenderText(currentParent);
            current = currentParent.GetComponent <LayoutElement>().minHeight;
            currentParent.GetComponent <LayoutElement>().minHeight = current * multiplier * onePerCent;
            mTotalHeight += (int)currentParent.GetComponent <LayoutElement>().minHeight;
            UpdateNow     = true;
            currentParent.gameObject.SetActive(true);
            yield return(new WaitForSeconds(cWaitTime));

            // race:
            currentParent = transform.FindChild("Menu").FindChild("DragArea").FindChild("ScrollArea").FindChild("Race");
            SetRaceText(currentParent);
            current = currentParent.GetComponent <LayoutElement>().minHeight;
            currentParent.GetComponent <LayoutElement>().minHeight = current * multiplier * onePerCent;
            mTotalHeight += (int)currentParent.GetComponent <LayoutElement>().minHeight;
            UpdateNow     = true;
            currentParent.gameObject.SetActive(true);
            yield return(new WaitForSeconds(cWaitTime));

            // alignment:
            currentParent = transform.FindChild("Menu").FindChild("DragArea").FindChild("ScrollArea").FindChild("Alignment");
            Image           image   = currentParent.FindChild(cView).FindChild("AlignmentImage").GetComponent <Image>();
            string          path    = mAlignmentPaths[(int)character.Alignment];
            ResourceRequest request = Resources.LoadAsync <Texture2D>(path);

            do
            {
                yield return(new WaitForSeconds(.001f));
            }while (!request.isDone);
            Texture2D tex = request.asset as Texture2D;

            byte[] array = tex.EncodeToPNG();
            image.sprite = ViewUtility.CreateSpriteUseTexture(array, image);
            yield return(new WaitForSeconds(.001f));

            text      = currentParent.FindChild(cInput).FindChild("Top").FindChild("BoxSetText").GetComponent <Text>();
            text.text = AlignmentGrid.SelectedAlignment.ToString();
            current   = currentParent.GetComponent <LayoutElement>().minHeight;
            currentParent.GetComponent <LayoutElement>().minHeight = current * multiplier * onePerCent;
            mTotalHeight += (int)currentParent.GetComponent <LayoutElement>().minHeight;
            UpdateNow     = true;
            currentParent.gameObject.SetActive(true);
            yield return(new WaitForSeconds(cWaitTime));

            // buffer:
            currentParent = transform.FindChild("Menu").FindChild("DragArea").FindChild("ScrollArea").FindChild("Buffer");
            currentParent.GetComponent <LayoutElement>().minHeight = (int)(Screen.height * 0.12f);
            mTotalHeight += (int)currentParent.GetComponent <LayoutElement>().minHeight;
            UpdateNow     = true;
        }
Esempio n. 15
0
        private void SaveItem(int notification, bool write = true)
        {
            Transform    parent    = transform.FindChild("Menu").FindChild("DragArea").FindChild("ScrollArea").GetChild(notification);
            DnDCharacter character = (DnDCharacter)AppStorage.Instance.CurrentCharacter;

            switch (notification)
            {
            case cNameId:
                string newName = parent.FindChild(cInput).GetComponent <InputField>().text.Trim();
                if (!string.IsNullOrEmpty(newName))
                {
                    character.Name = newName;
                    parent.FindChild(cInput).FindChild("Placeholder").GetComponent <Text>().text = newName;
                    parent.FindChild(cView).GetComponent <Text>().text = newName;
                }
                break;

            case cExpId:
                string currentText = parent.FindChild(cInput).FindChild("InputField").GetComponent <InputField>().text.Trim();
                if (!string.IsNullOrEmpty(currentText))
                {
                    try
                    {
                        character.Experience = int.Parse(currentText);
                    }
                    catch (Exception) { }
                    parent.FindChild(cInput).FindChild("InputField").FindChild("Placeholder").GetComponent <Text>().text = character.Experience.ToString();
                    parent.FindChild(cView).FindChild("Bottom").FindChild("Value").GetComponent <Text>().text            = character.Experience.ToString();
                    parent.FindChild(cView).FindChild("Top").FindChild("Value").GetComponent <Text>().text = character.CharacterLevel.ToString();
                }
                break;

            case cAttributesId:
                // str:
                string newAbility = parent.FindChild(cInput).FindChild("Left").FindChild("Str").FindChild("InputField").GetComponent <InputField>().text.Trim();
                if (!string.IsNullOrEmpty(newAbility))
                {
                    character.Abilities[DnDAbilities.Strength] = int.Parse(newAbility);
                }
                // dex:
                newAbility = parent.FindChild(cInput).FindChild("Left").FindChild("Dex").FindChild("InputField").GetComponent <InputField>().text.Trim();
                if (!string.IsNullOrEmpty(newAbility))
                {
                    character.Abilities[DnDAbilities.Dexterity] = int.Parse(newAbility);
                }
                // con:
                newAbility = parent.FindChild(cInput).FindChild("Left").FindChild("Con").FindChild("InputField").GetComponent <InputField>().text.Trim();
                if (!string.IsNullOrEmpty(newAbility))
                {
                    character.Abilities[DnDAbilities.Constitution] = int.Parse(newAbility);
                }
                // int:
                newAbility = parent.FindChild(cInput).FindChild("Right").FindChild("Int").FindChild("InputField").GetComponent <InputField>().text.Trim();
                if (!string.IsNullOrEmpty(newAbility))
                {
                    character.Abilities[DnDAbilities.Intelligence] = int.Parse(newAbility);
                }
                // wis:
                newAbility = parent.FindChild(cInput).FindChild("Right").FindChild("Wis").FindChild("InputField").GetComponent <InputField>().text.Trim();
                if (!string.IsNullOrEmpty(newAbility))
                {
                    character.Abilities[DnDAbilities.Wisdom] = int.Parse(newAbility);
                }
                // cha:
                newAbility = parent.FindChild(cInput).FindChild("Right").FindChild("Cha").FindChild("InputField").GetComponent <InputField>().text.Trim();
                if (!string.IsNullOrEmpty(newAbility))
                {
                    character.Abilities[DnDAbilities.Charisma] = int.Parse(newAbility);
                }
                SetAbilitiesTexts(parent);
                break;

            case cGenderId:
                var array = Enum.GetValues(typeof(CharacterGender)).Cast <CharacterGender>();
                foreach (CharacterGender gender in array)
                {
                    Toggle toggle = parent.FindChild(cInput).FindChild("GenderGroup").GetChild((int)gender).GetComponent <Toggle>();
                    if (toggle.isOn)
                    {
                        character.Gender = gender;
                    }
                }
                SetGenderText(parent);
                break;

            case cRaceId:
                Slider slider = parent.FindChild(cInput).FindChild("Slider").GetComponent <Slider>();
                character.Race = (DnDRace)slider.value;
                SetRaceText(parent);
                break;

            case cAlignmentId:
                character.Alignment = AlignmentGrid.SelectedAlignment;
                break;
            }
            if (write)
            {
                AppStorage.Instance.SaveCharacters();
            }
        }