// Use this for initialization void Start() { database = GetComponent <AnimalDatabase>(); // How many slots slotAmount = 25; // Find InventoryPanel and instantiate slots inventoryPanel = GameObject.Find("Inventory Panel"); slotPanel = inventoryPanel.transform.Find("SlotPanel").gameObject; for (int i = 0; i < slotAmount; i++) { animals.Add(new Animal()); slots.Add(GameObject.Instantiate(inventorySlot)); slots[i].transform.SetParent(slotPanel.transform); } aquired = PlayerPrefsX.GetIntArray("AnimalsAquired"); for (int i = 1; i <= database.Count(); i++) { if (!contains(i)) { addAnimal(-i); } else { addAnimal(i); } } }
// Use this for initialization void Start() { database = gameObject.GetComponent <AnimalDatabase>(); Animal animal = database.FetchAnimalByID(DataManager.animalClicked); GameObject.Find("AnimalIcon").GetComponent <Image>().sprite = animal.sprite; }
// Use this for initialization void Start() { database = GetComponent <AnimalDatabase>(); // Get previous clicked animal ID animal = database.FetchAnimalByID(DataManager.animalClicked); _scene = scene.GetComponent <Crosstales.RTVoice.Demo.AniVoice>(); // Instantiate model for previously clicked animal Debug.Log(animal.id); model = Instantiate((GameObject)Resources.Load("Prefab/Models" + animal.modelPath)); model.transform.SetParent(GameObject.Find("UserDefinedTarget").transform); model.transform.localScale = new Vector3(animal.scale, animal.scale, animal.scale); model.transform.position = Vector3.zero; model.transform.Rotate(0, animal.rotation, 0); model.SetActive(false); model.name = "Model"; /* * * // Instantiate Animation deleted after 2 seconds in the UDTEventHandler script * GameObject mod = Instantiate((GameObject)Resources.Load("Prefab/Summon/SummonGround")); * mod.transform.parent = model.transform; * mod.transform.localScale = new Vector3(1F, 1F, 1F); * */ // Set Animal's name animalName.GetComponent <Text>().text = animal.name; // Vectors string[] splitted1 = animal.part1_vector.Split(','); string[] splitted2 = animal.part2_vector.Split(','); string[] splitted3 = animal.part3_vector.Split(','); // Rotations string[] splittedrot1 = animal.part1_rotation.Split(','); string[] splittedrot2 = animal.part2_rotation.Split(','); string[] splittedrot3 = animal.part3_rotation.Split(','); for (int i = 0; i < 3; i++) { part1_vector[i] = float.Parse(splitted1[i]); part2_vector[i] = float.Parse(splitted2[i]); part3_vector[i] = float.Parse(splitted3[i]); part1_rotation[i] = float.Parse(splittedrot1[i]); part2_rotation[i] = float.Parse(splittedrot2[i]); part3_rotation[i] = float.Parse(splittedrot3[i]); } // Set ScreenManager modified to false GameObject.Find("SceneManager").GetComponent <ScreenManager>().setModify(false); infoPanel = GameObject.Find("TargetBuilderCanvas").transform.GetChild(5).gameObject; imagePanel = GameObject.Find("TargetBuilderCanvas").transform.GetChild(6).gameObject; }
public void processImage(FoundImageObject c) { // Acquiring animal phase database = GameObject.Find("Image").GetComponent <AnimalDatabase>(); ScreenManager sManager = GameObject.Find("SceneManager").GetComponent <ScreenManager>(); Animal animal; foreach (Category cat in c.categories) { // Fetch animal from database if animal fetched is not null then add to acquired animals animal = database.FetchAnimalByName(cat.name.Replace("\"", "")); if (animal != null) { int[] animals = PlayerPrefsX.GetIntArray("AnimalsAquired"); int[] dummy = new int[animals.Length + 1]; Debug.Log("-- " + animal.id + " " + database.FetchAnimalByID(animal.id)); for (int i = 0; i < animals.Length; i++) { dummy[i] = animals[i]; } if (!contains(animals, animal.id)) { dummy[dummy.Length - 1] = animal.id; PlayerPrefsX.SetIntArray("AnimalsAquired", dummy); DataManager.animalClicked = animal.id; // Set Found Animals PlayerPrefs.SetInt("foundAnimals", PlayerPrefs.GetInt("foundAnimals") + 1); PlayerPrefs.SetInt(animal.type, PlayerPrefs.GetInt(animal.type) + 1); // Set ScreenManager modified to false sManager.setModify(false); // Off camera cam.Exit(); showNoFoundPanel = false; // Redirect to FoundNewAnimal Screen SceneManager.LoadScene("FoundNewAnimal"); } else { showNoFoundPanel = false; StartCoroutine(activateDuplicatePanel()); } break; } } if (showNoFoundPanel) { StartCoroutine(activateNoFoundPanel()); } }
public void AddAnimal(string animalName) { var animalObject = gameObject.FindChild(SubObjectsNames[0]); AnimalObjects.Add(animalObject); var animalData = AnimalDatabase.Get(animalName); AnimalData.Add(animalData); SubObjectsNames.RemoveAt(0); var index = animalData.spriteIndex - 1; var row = index % 10; var col = index / 10; foreach (var r in animalObject.GetComponentsInChildren <Renderer>()) { r.enabled = true; r.material.mainTextureOffset = new Vector2(row / 10f, 1 - col / 10f - 1 / 10f); } totemSpeed = (int)Math.Round(AnimalData.Average(x => x.speed)); TotemIntelligence = AnimalData.Max(x => x.intelligence); TotemMaxHealth = AnimalData.Sum(x => x.health) * 20; TotemCurrentHealth = TotemMaxHealth; if (Network.isServer) { attackTimeBuffers.Add(0); } if (AnimalObjects.Count == 1) { name = animalName; } else { name += " " + animalName; } }
void OnGUI() { GUI.matrix = Matrix4x4.TRS(new Vector3(0, 400 * CameraMotion.PanFactor, 0), Quaternion.identity, Vector3.one); var textureHeight = containerStyle.normal.background.height; GUILayout.BeginArea(new Rect(0, Screen.height - textureHeight, containerStyle.normal.background.width, textureHeight), containerStyle); GUILayout.EndArea(); GUILayout.BeginArea(new Rect(291, Screen.height - 140, 414 - 48, 162)); GUILayout.BeginHorizontal(textBoxStyle); string[] words = text.Split(' '); for (int i = 0; i < words.Length; i++) { string word = words[i]; if (AnimalDatabase.Get(word) == null) { GUI.color = errorTint; } else { GUI.color = successTint; } GUILayout.Label(word, textStyle); GUI.color = Color.white; if (i < words.Length - 1) { GUILayout.Space(11); } else { GUILayout.Label("|", textStyle); } } var thisSummoner = TerrainGrid.Instance.Summoners[Network.isServer ? TerrainGrid.ServerPlayerId : TerrainGrid.ClientPlayerId]; var enemySummoner = TerrainGrid.Instance.Summoners[Network.isServer ? TerrainGrid.ClientPlayerId : TerrainGrid.ServerPlayerId]; GUILayout.EndHorizontal(); { ShowHealthBar(thisSummoner, hpGoodColor, hpBadColor); } GUILayout.EndArea(); GUI.matrix = Matrix4x4.TRS(new Vector3(0, -100 * CameraMotion.PanFactor, 0), Quaternion.identity, Vector3.one); GUILayout.BeginArea(new Rect(Screen.width - 414 + 48 - 20, 20, 414 - 48, 162)); { ShowHealthBar(enemySummoner, hpEnemyGoodColor, hpEnemyBadColor); } GUILayout.EndArea(); GUI.matrix = Matrix4x4.TRS(new Vector3(0, 400 * CameraMotion.PanFactor, 0), Quaternion.identity, Vector3.one); //GUILayout.BeginArea(new Rect(300 - 48, Screen.height - 45, 410, 25)); //GUILayout.BeginHorizontal(hpTextStyle); //GUILayout.EndHorizontal(); //GUILayout.EndArea(); // idle : 2/3f // hurt : 0/3f // fail : 1/3f var offset = thisSummoner.HasTakenDamage ? 0 : thisSummoner.HasFailed ? 1 / 3f : 2 / 3f; GUI.DrawTextureWithTexCoords(new Rect(0, Screen.height - portraits.height, 512, portraits.height), portraits, new Rect(offset, 0, 1 / 3f, 1)); GUI.matrix = Matrix4x4.identity; if (GameFlow.State == GameState.Gameplay) { // handle text entry Event e = Event.current; if (e.type == EventType.KeyDown) { if (char.IsLetter(e.character) || (e.character == ' ' && words.Length < 3 && words.Length > 0 && words[0].Trim().Length > 0)) { text += char.ToUpper(e.character); } else if (e.character == '\n') { var validWords = words.Where(x => AnimalDatabase.Get(x) != null).Distinct(StringComparer.InvariantCultureIgnoreCase).ToList(); foreach (var w in validWords.ToArray()) { foreach (var t in TerrainGrid.Instance.Totems.Values.SelectMany(x => x)) { if (t.AnimalData.Any(x => x.name.Equals(w, StringComparison.InvariantCultureIgnoreCase))) { validWords.Remove(w); } } } if (words.Length != validWords.Count) { thisSummoner.HasFailed = true; TaskManager.Instance.WaitFor(0.5f).Then(() => { thisSummoner.HasFailed = false; }); audio.PlayOneShot(mistakeSound); } else if (validWords.Count > 0) { audio.PlayOneShot(enterSound); } if (validWords.Count > 0) { thisSummoner.TrySpawnOnServer(validWords.ToArray()); } //foreach(string word in words) //{ // if(AnimalDatabase.Get(word) != null) // { // print("awesoem word: " + word); // } //} text = ""; } else if (e.keyCode == KeyCode.Backspace && text.Length > 0) { text = text.Remove(text.Length - 1); } } } }