// Usability Functions private void setText(int id) { if (id != 1f) { tertiary.transform.parent.gameObject.SetActive(true); string name0 = PokemonDatabase.getPokemonbyID(id - 1).getName() + " " + toNum(id - 1); tertiary.text = name0; tertiaryShadow.text = name0; } else { tertiary.transform.parent.gameObject.SetActive(false); } string name = PokemonDatabase.getPokemonbyID(id).getName() + " " + toNum(id); primary.text = name; primaryShadow.text = name; if (id != PokemonDatabase.getPokedexLength() - 1) { secondary.transform.parent.gameObject.SetActive(true); string name0 = PokemonDatabase.getPokemonbyID(id + 1).getName() + " " + toNum(id + 1); secondary.text = name0; secondaryShadow.text = name0; } else { secondary.transform.parent.gameObject.SetActive(false); } // Set Image string path = AssetDatabase.GetAssetPath(spritesheet); Sprite[] sprites = AssetDatabase.LoadAllAssetsAtPath(path).OfType <Sprite>().ToArray(); preview.sprite = sprites [PokemonDatabase.getPokemonbyID(id).getID() - 1]; preview.gameObject.GetComponent <RectTransform> ().sizeDelta = sprites [PokemonDatabase.getPokemonbyID(id).getID() - 1].bounds.size * 37; setTyping(id); }
public IEnumerator control() { cursor = 1; setText(1); StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed)); bool running = true; while (running) { // Cursor Movement if (Input.GetAxis("Horizontal") < 0 && cursor > 1f) { cursor -= 1f; yield return(new WaitForSeconds(0.2f)); } else if (Input.GetAxis("Horizontal") > 0 && cursor < 2f) { cursor += 1f; yield return(new WaitForSeconds(0.2f)); } if (Input.GetButton("Back")) { cancelButton.GetComponent <Image>().sprite = cancelButtonSelected; yield return(new WaitForSeconds(0.2f)); running = false; } if (cursor == 1) { //Scrolling through list if (Input.GetAxis("Vertical") > 0 && activeID > 1f) { activeID -= 1f; setText((int)activeID); yield return(new WaitForSeconds(0.2f)); } else if (Input.GetAxis("Vertical") < 0 && activeID < PokemonDatabase.getPokedexLength() - 1) { activeID += 1f; setText((int)activeID); yield return(new WaitForSeconds(0.2f)); } cancelButton.GetComponent <Image>().sprite = cancelButtonUnselected; } else if (cursor == 2) { // Exiting cancelButton.GetComponent <Image>().sprite = cancelButtonSelected; if (Input.GetButton("Select")) { running = false; } } yield return(null); } StopCoroutine("animateIcons"); //yield return new WaitForSeconds(sceneTransition.FadeOut()); yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed))); GlobalVariables.global.resetFollower(); this.gameObject.SetActive(false); }