private CharacterDiceProfile FindCharacterDiceProfile(string name) { CharacterDiceProfile returnCDP = null; foreach (CharacterDiceProfile cD in GameObject.Find("CharacterDiceProfileHolder").GetComponents <CharacterDiceProfile>()) { if (cD.GetCharacterName().ToUpper().Equals(name.ToUpper())) { returnCDP = cD; } } return(returnCDP); }
public void SetupDiceCanvas(string characterName) { //Finding the relationship and character dice profile we are working with Relationship currRelationship = FindRelationship(characterName); CharacterDiceProfile currCDP = FindCharacterDiceProfile(characterName); //Getting starting position of button for (int i = 0; i < this.transform.childCount; i++) { if (!this.transform.GetChild(i).name.Contains("DontClear")) { Destroy(this.transform.GetChild(i).gameObject); } } Vector3 tempButtonPos = _buttonPos; //Get Level int level = currRelationship.GetCurrLevel(); //For each unlock level, instantiate a new dice button for (int i = 0; i < currCDP.GetUnlockLevels().Count; i++) { if (level >= currCDP.GetUnlockLevels()[i]) { DiceSkin newDiceSkin = FindDiceSkin(currCDP.GetDiceTypes()[i]); MakeButton(tempButtonPos, newDiceSkin); } else { MakeLockedButton(tempButtonPos, currCDP.GetUnlockLevels()[i]); } //Increase the gap between buttons tempButtonPos.y -= buttonGap; } //Get the objects that aren't destroyed on reset GameObject dontClear = Utilities.SearchChild("DontClear", this.gameObject); //Change the character image Utilities.SearchChild("CharacterImage", dontClear).GetComponent <Image>().sprite = currCDP.GetCharacterImage(); //Change superficial info Utilities.SearchChild("CharactersDice", dontClear).GetComponent <Text>().text = currCDP.GetCharacterName() + "'s Dice (Relationship Lvl: " + currRelationship.GetCurrLevel() + ")"; }