public void TestPopulate() { for (int x = 0; x < 10; x++) { GameObject displayElement = Instantiate(characterDisplayElement, Vector3.zero, Quaternion.identity); displayElement.transform.SetParent(layoutManager.transform); CharacterDisplayElementHandler currentHandler = displayElement.GetComponent <CharacterDisplayElementHandler>(); currentHandler.SetLevel(x); currentHandler.SetID(x); currentHandler.button.onClick.AddListener(delegate { ButtonClicked(currentHandler.GetID()); }); } }
public void Populate(List <PlayerStats> playerStats) { int x = 0; characterList = new List <PlayerStats>(); foreach (PlayerStats stats in playerStats) { GameObject displayElement = Instantiate(characterDisplayElement, Vector3.zero, Quaternion.identity); displayElement.transform.SetParent(layoutManager.transform); CharacterDisplayElementHandler currentHandler = displayElement.GetComponent <CharacterDisplayElementHandler>(); currentHandler.SetLevel(CalculateLevelFromStats(stats)); currentHandler.SetID(x); currentHandler.SetName(stats.name); //temporary, needs to also factor in items, traits, and upgrades currentHandler.SetStats(stats.characterClass.attackPower, stats.characterClass.magicPower, stats.characterClass.resistance, stats.characterClass.movespeed); currentHandler.button.onClick.AddListener(delegate { ButtonClicked(currentHandler.GetID()); }); characterList.Add(stats); x++; } }