private IEnumerator ChangeNickname(PokemonInstance target) { string oldDisplayName = target.GetDisplayName(); string newNickname = null; nicknameCanvas.RunCanvas((nn) => { if (nn == null) { Debug.LogError("New nickname was null"); nn = ""; } else { newNickname = nn; } }); yield return(new WaitUntil(() => newNickname != null)); target.nickname = newNickname; yield return(StartCoroutine( textBoxController.RevealText(GetFormattedSpokenMessage( oldDisplayName + " is now called " + target.GetDisplayName()), true) )); }
public void UpdateValues(PokemonInstance pokemon) { imageIcon.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Icon); textName.text = pokemon.GetDisplayName(); healthBar.UpdateBar(pokemon.HealthProportion); if (pokemon.nonVolatileStatusCondition == PokemonInstance.NonVolatileStatusCondition.None) { imageStatusCondition.gameObject.SetActive(false); } else { imageStatusCondition.gameObject.SetActive(true); imageStatusCondition.sprite = SpriteStorage.GetNonVolatileStatusConditionSprite(pokemon.nonVolatileStatusCondition); } if (pokemon.heldItem == null) { imageHeldItem.enabled = false; } else { imageHeldItem.enabled = true; } }
/// <summary> /// Fully update the values on the overview pane using a specified pokemon /// </summary> /// <param name="pokemon">The pokemon to use</param> public virtual void FullUpdate(PokemonInstance pokemon) { UpdateHealthBar(pokemon.health, pokemon.GetStats().health); UpdateName(pokemon.GetDisplayName()); UpdateGender(pokemon.gender); UpdateLevel(pokemon.GetLevel()); UpdateNonVolatileStatsCondition(pokemon.nonVolatileStatusCondition); }
/// <summary> /// Sets the details of the menu including actions to take when each button is used /// </summary> /// <param name="pokemon">The pokmeon to use for consideration</param> /// <param name="replaceMove">Whether the menu is being used for replacing a move (instead of for cancelling learning the move)</param> /// <param name="replacedMoveIndex">(Only relevant if replaceMove is true) The index of the move that is being considered for replacement</param> public void SetDetails(PokemonInstance pokemon, int newMoveId, bool replaceMove, int replacedMoveIndex = -1) { if (textBoxController == null) { SetTextBoxController(); } PokemonMove newMove = PokemonMove.GetPokemonMoveById(newMoveId); noButton.onClick.AddListener(() => learnMoveUIController.ConfirmAction_ReturnToLearnMoveMenu()); if (replaceMove) { if (replacedMoveIndex < 0 || replacedMoveIndex > 3) { Debug.LogError("replacedMoveIndex was invalid when setting details for replacing a move"); } string prompt = replaceMovePrompt .Replace("{pokemonName}", pokemon.GetDisplayName()) .Replace("{oldMoveName}", PokemonMove.GetPokemonMoveById(pokemon.moveIds[replacedMoveIndex]).name) .Replace("{newMoveName}", newMove.name); textBoxController.SetTextInstant(prompt); yesButton.onClick.AddListener(() => learnMoveUIController.ConfirmAction_ReplaceMove(replacedMoveIndex)); } else { string prompt = cancelLearnMovePrompt .Replace("{pokemonName}", pokemon.GetDisplayName()) .Replace("{moveName}", newMove.name); textBoxController.SetTextInstant(prompt); yesButton.onClick.AddListener(() => learnMoveUIController.ConfirmAction_CancelLearningMove()); } }
public override IEnumerator PlayerInteraction() { #region Find target pokemon PokemonInstance target = null; for (byte i = 0; i < PlayerData.partyCapacity; i++) { PokemonInstance p = PlayerData.singleton.partyPokemon[i]; if (p != null) { target = p; break; } } if (target == null) { Debug.LogError("No pokemon able to be found in player party"); yield break; } #endregion string choicePrompt = GetFormattedSpokenMessage("Hi there. What would you like to do with " + target.GetDisplayName() + '?'); yield return(StartCoroutine(textBoxController.WaitForUserChoice( menuOptions, choicePrompt ))); switch (textBoxController.userChoiceIndexSelected) { case 0: //Goodbye //Do nothing break; case 1: //Friendship check yield return(StartCoroutine(FriendshipCheck(target))); break; case 2: //Change nickname yield return(StartCoroutine(ChangeNickname(target))); break; } }
public override void SetPokemon(PokemonInstance pokemon) { if (pokemon != null) { imagePokeBall.gameObject.SetActive(true); imagePokeBall.sprite = SpriteStorage.GetItemSprite( PokeBall.GetPokeBallById(pokemon.pokeBallId) .resourceName ); textName.text = pokemon.GetDisplayName(); imageGender.gameObject.SetActive(true); imageGender.sprite = SpriteStorage.GetGenderSprite(pokemon.gender); imageFront.gameObject.SetActive(true); imageFront.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Front1); imageType1.gameObject.SetActive(true); imageType2.gameObject.SetActive(true); imageType1.sprite = SpriteStorage.GetTypeSymbolSprite(pokemon.species.type1); Type?pokemonType2 = pokemon.species.type2; if (pokemonType2 == null) { imageType2.gameObject.SetActive(false); } else { imageType2.gameObject.SetActive(true); imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Type)pokemonType2); } imageCheatPokemon.gameObject.SetActive(pokemon.cheatPokemon); imageShinyPokemon.gameObject.SetActive(pokemon.IsShiny); } else { imageFront.gameObject.SetActive(false); imageType1.gameObject.SetActive(false); imageType2.gameObject.SetActive(false); imagePokeBall.gameObject.SetActive(false); textName.text = noPokemonPromptMessage; imageGender.gameObject.SetActive(false); imageCheatPokemon.gameObject.SetActive(false); imageShinyPokemon.gameObject.SetActive(false); } }
public override void RefreshDetails(PokemonInstance pokemon) { imagePokeBall.sprite = SpriteStorage.GetItemSprite( PokeBall.GetPokeBallById(pokemon.pokeBallId) .resourceName ); textName.text = pokemon.GetDisplayName(); imageGender.sprite = SpriteStorage.GetGenderSprite(pokemon.gender); textSpeciesName.text = pokemon.species.name; textSpeciesNumber.text = pokemon.species.id.ToString(); imageType1.sprite = SpriteStorage.GetTypeSymbolSprite(pokemon.species.type1); imageFront.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Front1); Type?pokemonType2 = pokemon.species.type2; if (pokemonType2 == null) { imageType2.gameObject.SetActive(false); } else { imageType2.gameObject.SetActive(true); imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Type)pokemonType2); } textLevel.text = pokemon.GetLevel().ToString(); textOriginalTrainer.text = pokemon.originalTrainerName; //TODO - once abilities made, set ability Text texts textAbilityName.text = ""; textAbilityDescription.text = ""; imageCheatPokemon.gameObject.SetActive(pokemon.cheatPokemon); imageShinyPokemon.gameObject.SetActive(pokemon.IsShiny); }
public void SetPokemon(PokemonInstance pokemon) { if (pokemon == null) { SetInteractable(false); return; } else { SetInteractable(true); } textName.text = pokemon.GetDisplayName(); textLevel.text = levelTextPrefix + pokemon.GetLevel().ToString(); imageIcon.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Icon); if (pokemon.nonVolatileStatusCondition == PokemonInstance.NonVolatileStatusCondition.None) { nvscImage.enabled = false; } else { nvscImage.enabled = true; nvscImage.sprite = SpriteStorage.GetNonVolatileStatusConditionSprite(pokemon.nonVolatileStatusCondition); } if (pokemon.heldItem == null) { imageHeldItem.enabled = false; } else { imageHeldItem.enabled = true; } healthBar.UpdateBar(pokemon.HealthProportion); }
public void SetPokemonDetails(PokemonInstance pokemon) { #region Images imageIcon.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Icon); imageFront.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Front1); imageBack.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Back); #endregion #region General Details imageType1.sprite = SpriteStorage.GetTypeSymbolSprite(pokemon.species.type1); Pokemon.Type?pokemonType2 = pokemon.species.type2; if (pokemonType2 == null) { imageType2.gameObject.SetActive(false); } else { imageType2.gameObject.SetActive(true); imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Pokemon.Type)pokemon.species.type2); } textName.text = pokemon.GetDisplayName(); imageGender.sprite = pokemon.LoadGenderSprite(); textLevelValue.text = pokemon.GetLevel().ToString(); if (pokemon.heldItem != null) { textItemName.text = pokemon.heldItem.itemName; imageItemIcon.enabled = true; imageItemIcon.sprite = pokemon.heldItem.LoadSprite(); } else { textItemName.text = "No held item"; imageItemIcon.enabled = false; } //TODO - set values for ability when and if implemented textAbilityName.text = ""; textAbilityDescription.text = ""; if (pokemon.nonVolatileStatusCondition != PokemonInstance.NonVolatileStatusCondition.None) { imageStatusCondition.gameObject.SetActive(true); Sprite statusConditionSprite = SpriteStorage.GetNonVolatileStatusConditionSprite(pokemon.nonVolatileStatusCondition); if (statusConditionSprite != null) { imageStatusCondition.gameObject.SetActive(true); imageStatusCondition.sprite = statusConditionSprite; } else { imageStatusCondition.gameObject.SetActive(false); } } else { imageStatusCondition.gameObject.SetActive(false); } imageCheatPokemon.gameObject.SetActive(pokemon.cheatPokemon); imageShinyPokemon.gameObject.SetActive(pokemon.IsShiny); #endregion #region Stats Pokemon.Stats <int> stats = pokemon.GetStats(); textAttackValue.text = stats.attack.ToString(); textDefenseValue.text = stats.defense.ToString(); textSpecialAttackValue.text = stats.specialAttack.ToString(); textSpecialDefenseValue.text = stats.specialDefense.ToString(); textSpeedValue.text = stats.speed.ToString(); healthBar.UpdateBar(pokemon.HealthProportion); #endregion }
public void SetPokemon(PokemonInstance pokemon) { if (pokemon == null) { SetPokemonShownState(false); } else { SetPokemonShownState(true); textDisplayName.text = pokemon.GetDisplayName(); imageGender.sprite = pokemon.LoadGenderSprite(); textLevel.text = levelPrefix + pokemon.GetLevel().ToString(); imageSprite.sprite = pokemon.LoadSprite(PokemonSpecies.SpriteType.Front1); textSpeciesName.text = pokemon.species.name; textSpeciesNumber.text = pokemon.species.id.ToString(); imageType1.sprite = SpriteStorage.GetTypeSymbolSprite(pokemon.species.type1); if (pokemon.species.type2 != null) { imageType2.sprite = SpriteStorage.GetTypeSymbolSprite((Type)pokemon.species.type2); } else { imageType2.enabled = false; } //This capitalises first letter of the nature's name textNature.text = pokemon.nature.name[0].ToString().ToUpper() + pokemon.nature.name.Substring(1); textItemName.text = pokemon.heldItem != null ? pokemon.heldItem.itemName : ""; textStatAttackValue.text = pokemon.GetStats().attack.ToString(); textStatDefenseValue.text = pokemon.GetStats().defense.ToString(); textStatSpecialAttackValue.text = pokemon.GetStats().specialAttack.ToString(); textStatSpecialDefenseValue.text = pokemon.GetStats().specialDefense.ToString(); textStatSpeedValue.text = pokemon.GetStats().speed.ToString(); textStatHealthValue.text = pokemon.GetStats().health.ToString(); statHexEV.values = new float[] { (float)pokemon.effortValues.attack / PokemonInstance.maximumEffortValue, (float)pokemon.effortValues.defense / PokemonInstance.maximumEffortValue, (float)pokemon.effortValues.specialAttack / PokemonInstance.maximumEffortValue, (float)pokemon.effortValues.specialDefense / PokemonInstance.maximumEffortValue, (float)pokemon.effortValues.speed / PokemonInstance.maximumEffortValue, (float)pokemon.effortValues.health / PokemonInstance.maximumEffortValue }; statHexIV.values = new float[] { (float)pokemon.individualValues.attack / PokemonInstance.maximumIndividualValue, (float)pokemon.individualValues.defense / PokemonInstance.maximumIndividualValue, (float)pokemon.individualValues.specialAttack / PokemonInstance.maximumIndividualValue, (float)pokemon.individualValues.specialDefense / PokemonInstance.maximumIndividualValue, (float)pokemon.individualValues.speed / PokemonInstance.maximumIndividualValue, (float)pokemon.individualValues.health / PokemonInstance.maximumIndividualValue }; imageCheatPokemon.enabled = pokemon.cheatPokemon; } }
public IEnumerator RunAnimation(PokemonInstance sendPmon, PokemonInstance recvPmon) { textBoxController = TextBoxController.GetTextBoxController(gameObject.scene); PokeBall sendPokeBall = PokeBall.GetPokeBallById(sendPmon.pokeBallId); PokeBall recvPokeBall = PokeBall.GetPokeBallById(recvPmon.pokeBallId); Vector3 pokemonInitialScale = PokemonTransform.localScale; //Initialise visibilities pokemonImage.enabled = true; pokeBallImage.enabled = false; //Initialise sprites pokemonImage.sprite = sendPmon.LoadSprite(PokemonSpecies.SpriteType.Front1); pokeBallImage.sprite = sendPokeBall.GetSprite(PokeBall.SpriteType.Neutral); //Initialise positions PokemonTransform.position = mainRootTransform.position; PokeBallTransform.position = mainRootTransform.position; //Goodbye message yield return(StartCoroutine( textBoxController.RevealText(goodbyeMessagePrefix + sendPmon.GetDisplayName() + goodbyeMessageSuffix, true) )); //Send pokemon cry SoundFXController.PlayPokemonCry(sendPmon.speciesId); //Send pokemon bouncing for (byte i = 0; i < sendPmonBonuceCount; i++) { yield return(StartCoroutine(Animation_Bounce(PokemonTransform))); } //Delay yield return(new WaitForSeconds(jumpScaleDelay)); //Open and show poke ball pokeBallImage.enabled = true; pokeBallImage.sprite = sendPokeBall.GetSprite(PokeBall.SpriteType.Open); //Shrink and hide pokemon yield return(StartCoroutine(GradualEffect( t => { PokemonTransform.localScale = pokemonInitialScale * (1 - t); }, shrinkGrowTime))); pokemonImage.enabled = false; //Close poke ball pokeBallImage.sprite = sendPokeBall.GetSprite(PokeBall.SpriteType.Neutral); //Delay yield return(new WaitForSeconds(pokeBallCloseSendDelay)); //Send away poke ball yield return(StartCoroutine(Animation_GradualLinearFunctionMovement(PokeBallTransform, pokeBallOffScreenTransform.position, t => Vector2.up * pokeBallFactorDisplacementCurve_y.Evaluate(t), t => Vector2.right * pokeBallAddedDisplacementCurve_x.Evaluate(t) * addedDisplacementFactor, pokeBallSendReturnTime))); //Wait yield return(new WaitForSeconds(pokeBallReturnDelay)); //Switch pokemon and poke ball sprites pokemonImage.sprite = recvPmon.LoadSprite(PokemonSpecies.SpriteType.Front1); pokeBallImage.sprite = recvPokeBall.GetSprite(PokeBall.SpriteType.Neutral); //Return poke ball yield return(StartCoroutine(Animation_GradualLinearFunctionMovement(PokeBallTransform, mainRootTransform.position, t => Vector2.up * pokeBallFactorDisplacementCurve_y.Evaluate(t), t => Vector2.right * pokeBallAddedDisplacementCurve_x.Evaluate(t) * addedDisplacementFactor, pokeBallSendReturnTime))); //Delay yield return(new WaitForSeconds(pokeBallRecvOpenDelay)); //Open poke ball pokeBallImage.sprite = recvPokeBall.GetSprite(PokeBall.SpriteType.Open); //Show and grow pokemon pokemonImage.enabled = true; yield return(StartCoroutine(GradualEffect( t => { PokemonTransform.localScale = pokemonInitialScale * t; }, shrinkGrowTime))); //Delay yield return(new WaitForSeconds(jumpScaleDelay)); //Recv pokemon cry SoundFXController.PlayPokemonCry(recvPmon.speciesId); //Receive pokemon bouncing for (byte i = 0; i < recvPmonBounceCount; i++) { yield return(StartCoroutine(Animation_Bounce(PokemonTransform))); } //Delay yield return(new WaitForSeconds(endDelayTime)); //Receiving message yield return(StartCoroutine( textBoxController.RevealText(receiveMessagePrefix + recvPmon.GetDisplayName() + receiveMessageSuffix, true) )); }