private void AddCharacters(PlayerCharacterData[] characters) { // will need to add empty slots if there are empty characters for (int i = 0; i < characters.Length; i++) { int charId = characters[i].id; UICharacter character = dataFormat.CreateUICharacter(characters[i], data); GameObject newCharacter = GameObject.Find("CharacterObjectPool").GetComponent <SimpleObjectPool>().GetObject(); newCharacter.transform.SetParent(GameObject.Find("CharacterContainer").transform); newCharacter.GetComponent <Button>().interactable = true; newCharacter.GetComponent <Button>().onClick.RemoveAllListeners(); newCharacter.GetComponent <Button>().onClick.AddListener(delegate { SelectPartyCharacter(charId); }); SampleCharacter sampleCharacter = newCharacter.GetComponent <SampleCharacter>(); sampleCharacter.Setup(character, this); } }
private void AddCharacters(PlayerCharacterData[] characters) { // will need to add empty slots if there are empty characters for (int i = 0; i < characters.Length; i++) { int charId = characters[i].id; int slot1 = -1; int slot2 = -1; int slot3 = -1; int slot4 = -1; if (data.GetPreviousPage() == 3) { PlayerPartyData party = data.GetPartyToEdit(); slot1 = party.slotOneCharacterId; slot2 = party.slotTwoCharacterId; slot3 = party.slotThreeCharacterId; slot4 = party.slotFourCharacterId; GameObject.Find("Backbutton").GetComponent <Button>().onClick.RemoveAllListeners(); GameObject.Find("Backbutton").GetComponent <Button>().onClick.AddListener(delegate { new SceneLoader().PartiesMenu(); }); } if (charId != slot1 && charId != slot2 && charId != slot3 && charId != slot4) { UICharacter character = dataFormat.CreateUICharacter(characters[i], data); GameObject newCharacter = GameObject.Find("CharacterObjectPool").GetComponent <SimpleObjectPool>().GetObject(); newCharacter.transform.SetParent(GameObject.Find("CharacterContainer").transform); newCharacter.GetComponent <Button>().interactable = true; newCharacter.GetComponent <Button>().onClick.RemoveAllListeners(); if (data.GetPreviousPage() == 3) { newCharacter.GetComponent <Button>().onClick.AddListener(delegate { SelectPartyCharacter(charId); }); } else { newCharacter.GetComponent <Button>().onClick.AddListener(delegate { EditPartyCharacter(charId); }); } SampleCharacter sampleCharacter = newCharacter.GetComponent <SampleCharacter>(); sampleCharacter.Setup(character, this); } } }