/// <summary> /// Creates a new AnimalTile and stores it for use. /// /// Under construction. Needs work. /// Problem: Too specific to scene 'CollectAndFollowAnimalTestScene'; needs generalization. /// </summary> public virtual void CreateAnimalTile(AnimalStoredInfo animalStoredInfo, bool isNewTile) { if (animalStoredInfo == null) { return; } newTile = Instantiate <GameObject> (animalTilePrefab); // the prefab must have AnimalTile if (!newTile.GetComponent <AnimalTile> ()) { string errMsg = "[AnimalStorageUI.cs] Whoops! You tried creating a new Animal Tile in the animal storage process, and the prefab you spawned does not include the 'AnimalTile' component!"; OutputLog.Write(errMsg); Debug.LogError(errMsg); } AniTile = newTile.GetComponent <AnimalTile> (); // pull script from spawned object // ===== // Set the animal sprite, gender and index in the script data AniTile.animalImage.sprite = animalStoredInfo.icon; AniTile.sexIcon.sprite = animalStoredInfo.sex.ToLower() == "female" ? References.instance.sprites["femalesymbol"] : References.instance.sprites["malesymbol"]; if (isNewTile) { AniTile.index = AnimalStorage.instance.animalInfoDictionary.Count + 1; // Update animalStoredInfo's index to match the tile, then store this index with a reference into memory connecting the tile to the NPC. animalStoredInfo.index = AniTile.index; } else { AniTile.index = animalStoredInfo.index; } // If we call this function from an "Add" button, or similar, we modify the storage to now include the new information. if (!AnimalStorage.instance.animalInfoDictionary.ContainsKey(animalStoredInfo.index)) { AnimalStorage.instance.animalInfoDictionary.Add(animalStoredInfo.index, animalStoredInfo); } AniTile.info = animalStoredInfo; // Parent the tile to the menu viewport newTile.transform.SetParent(animalListContent); newTile.transform.localScale = Vector3.one; // grab the gameObject references and set to specific components newTile.transform.GetChild(1).GetChild(0).GetComponent <TextMeshProUGUI>().text = AniTile.info.animalName; // name on tile newTile.transform.GetChild(2).GetComponent <Image> ().sprite = AniTile.sexIcon.sprite; // gender icon on tile }
public virtual void ToggleChangeDemoAnimal(bool toggle, AnimalTile aniTile) { // ... }
/// <summary> /// Stores a specific 'AnimalTile' to the current slot. /// The 'currentAnimalTile' slot is used to display information visually. /// </summary> /// <param name="tile">Tile.</param> protected void SetCurrentAnimalTile(AnimalTile tile) { currentAnimalTile = tile; }