private IEnumerator CreateSpellButtons() { yield return(StartCoroutine(Clean())); yield return(null); int rank = storage.selectedRank; CharClassEnum cclass = storage.selectedChar.cclass; List <Spell> spells = new List <Spell>(); if (storage.selectedRankMain) { // main class spells spells.AddRange(storage.spellList.GetSpellsOfClassAndRank(cclass, rank)); } else { // extra spells (domains / school-spec) if (cclass == CharClassEnum.Cleric) { ClericDomain dom_1 = (ClericDomain)storage.selectedChar.attributes[0]; ClericDomain dom_2 = (ClericDomain)storage.selectedChar.attributes[1]; spells.AddRange(storage.spellList.Get2DomainSpellsWithRank(dom_1, dom_2, rank)); } else if (cclass == CharClassEnum.Wizard) { MagicSchool school = (MagicSchool)storage.selectedChar.attributes[0]; spells.AddRange(storage.spellList.GetWizardSchoolSpecializationSpells(school, rank)); } } CreateSpellButtons(spells); }
private void CreateRankButton(int rank) { CharClassEnum cclass = storage.selectedChar.cclass; if (cclass == CharClassEnum.Ranger || cclass == CharClassEnum.Paladin) { // can't cast rank 0 spells rank++; } bool extraSpell = storage.SelectedCharHasExtraSpell(); GameObject mainButton = (GameObject)Instantiate(ButtonPrefab); mainButton.GetComponent <RankSelectionButton>().rank = rank; mainButton.GetComponent <RankSelectionButton>().main = true; if (extraSpell) { Transform target = table.FindChild("MainButtonGrid"); mainButton.transform.parent = target; AnchorObjectToTable(target, mainButton, rank); CreateExtraRankButton(rank); } else { mainButton.transform.parent = table; AnchorObjectToTable(table, mainButton, rank); } UILabel label = mainButton.transform.FindChild("B_Label").GetComponent <UILabel>(); label.text = "Rank: " + rank; }
public Character(string name, CharClassEnum charClass, int lvl, int mod, List <int> attributeList) { mName = name; mCClass = charClass; mLevel = lvl; mModifier = mod; mAttributes = attributeList; }
public List <Spell> GetSpellsOfClassAndRank(CharClassEnum cclass, int rank) { List <Spell> result = mSpellList.FindAll( delegate(Spell temp) { return(temp.Contains(cclass, rank)); }); return(result); }
public bool Contains(CharClassEnum charClass, int rank) { foreach (SpellAttribute attribute in mClasses) { if (attribute.attributeValue == (int)charClass && attribute.rank == rank) { return(true); } } return(false); }
public bool Contains(MagicSchool school, CharClassEnum cclass, int rank) { foreach (SpellAttribute attribute in mClasses) { if (attribute.attributeValue == (int)cclass && attribute.rank == rank) { return(mSchool == school); } } return(false); }
public static System.Type EnumToCharClass(CharClassEnum type) { switch (type) { case CharClassEnum.Artorias: { return(typeof(Artorias_Character)); } case CharClassEnum.Lamia: { return(typeof(LamiaChar)); } default: { return(typeof(EnemyTest1)); } } }
public void Deserialize(JSONObject obj) { mName = obj.GetString("name"); mCClass = (CharClassEnum)obj.GetNumber("class"); mLevel = (int)obj.GetNumber("level"); mModifier = (int)obj.GetNumber("mod"); // attributes mAttributes.Clear(); JSONArray tempArray = obj.GetArray("attributes"); foreach (var val in tempArray) { mAttributes.Add((int)val.Number); } // main spells mMainSpells.Clear(); tempArray = obj.GetArray("mainSpells"); foreach (var array in tempArray) { List <KeyValuePair <Spell, bool> > dic = new List <KeyValuePair <Spell, bool> >(); foreach (var pairObj in array.Array) { Spell spell = new Spell(); spell.Deserialize(pairObj.Obj.GetObject("spell")); bool used = pairObj.Obj.GetBoolean("used"); dic.Add(new KeyValuePair <Spell, bool>(spell, used)); } mMainSpells.Add(dic); } // extra spells mExtraSpells.Clear(); tempArray = obj.GetArray("extraSpells"); foreach (var array in tempArray) { Spell spell = new Spell(); spell.Deserialize(array.Obj.GetObject("spell")); bool used = array.Obj.GetBoolean("used"); mExtraSpells.Add(new KeyValuePair <Spell, bool>(spell, used)); } }
private void SetTitleText() { string text = "Rank: " + storage.selectedRank; if (!storage.selectedRankMain) { text += "\n"; CharClassEnum cclass = storage.selectedChar.cclass; if (cclass == CharClassEnum.Wizard) { text += ((MagicSchool)(storage.selectedChar.attributes[0])).ToString(); text += " spell"; } else if (cclass == CharClassEnum.Cleric) { text += ((ClericDomain)(storage.selectedChar.attributes[0])).ToString(); text += "/" + ((ClericDomain)(storage.selectedChar.attributes[1])).ToString(); text += " spell"; } } UILabel label = gameObject.transform.FindChild("PSSR_Title").GetComponent <UILabel>(); label.text = text; }
public List <ICharacterStats> LoadData() { string json = File.ReadAllText(Application.dataPath + "jjjjsave.txt"); string[] splitedJson = json.Split(new string[] { SEPARATOR }, System.StringSplitOptions.None); characters = new List <ICharacterStats>(); // Debug.Log(splitedJson); foreach (string i in splitedJson) { if (i != "") { CharClassEnum typeEnum = (CharClassEnum)Enum.Parse(typeof(CharClassEnum), (i.Substring(i.IndexOf("charClass") + 11, 1))); System.Type type = Tools.EnumToCharClass(typeEnum); //var character = Activator.CreateInstance(type); ICharacterStats character = JsonUtility.FromJson(i, type) as ICharacterStats; characters.Add(character); } } return(characters); }