/// <summary> /// We read abilities from JSON and save them in our dictionary /// </summary> /// <param name="json_path"></param> public void PrepareAbilities(string json_path) { JSONNode info = JSON.Parse(Resources.Load(json_path).ToString()); Debug.Log("Total: " + info["skilltree"].Count); for (int i = 0; i < info["skilltree"].Count; i++) { ST_Ability ability = new ST_Ability(info["skilltree"][i]); Debug.Log("Parsing: " + ability.ID); // We have that ability if (m_character.CurrentLevel >= ability.LevelToUnlock) { Debug.Log("Learned " + ability.ID + " cause it's level to unlock is " + ability.LevelToUnlock); m_myAbilities.Add(ability.ID, ability); //Each ability checks it's evolutions for (int j = 0; j < ability.evolutions.Count; j++) { if (m_character.CurrentLevel >= ability.evolutions[j].LevelToUnlock) { m_myAbilities.Add(ability.evolutions[j].ID, ability); Debug.Log("Learned " + ability.evolutions[j].ID); } } } } Debug.Log("Total abilities learned at level " + m_character.CurrentLevel + ": " + m_myAbilities.Count); }
public void SetAbilitiesByPlayerLevel() { if (m_myAbilities == null) { Debug.Log("There are no abilities"); } List <ST_Ability> abilities_to_learn = new List <ST_Ability>(); foreach (string key in m_myAbilities.Keys) { ST_Ability ab = m_myAbilities[key]; Debug.Log("Checking evolutions from: " + ab.ID); //Each ability checks it's evolutions for (int j = 0; j < ab.evolutions.Count; j++) { if (m_character.CurrentLevel >= ab.evolutions[j].LevelToUnlock && !m_myAbilities.ContainsKey(ab.evolutions[j].ID)) { abilities_to_learn.Add(ab.evolutions[j]); Debug.Log("Learned " + ab.evolutions[j].ID); } else { Debug.Log("We can't learn " + ab.evolutions[j].ID); } } } for (int i = 0; i < abilities_to_learn.Count; i++) { m_myAbilities.Add(abilities_to_learn[i].ID, abilities_to_learn[i]); } Debug.Log("Total abilities learned at level " + m_character.CurrentLevel + ": " + m_myAbilities.Count); }