void Awake() { pawnSprite = transform.FindChild("Pawn").GetComponent <SpriteRenderer>(); pawnReflectionSprite = transform.FindChild("PawnReflection").GetComponent <SpriteRenderer>(); if (pokemonID != 0) { pawnLightSprite = transform.FindChild("PawnLight").GetComponent <SpriteRenderer>(); pawnLightReflectionSprite = transform.FindChild("PawnLightReflection").GetComponent <SpriteRenderer>(); npcLight = transform.FindChild("Point light").GetComponent <Light>(); } hitBox = transform.FindChild("NPC_Object"); if (pokemonID == 0) { spriteSheet = Resources.LoadAll <Sprite>("OverworldNPCSprites/" + npcSpriteName); } else { spriteSheet = OwnedPokemon.GetSpriteFromID(pokemonID.ToString(), false, false); // ToDo: Find out what is this f*****g light ! //npcLight.intensity = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(pokemonID).getLuminance(); //npcLight.color = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(pokemonID).getLightColor(); lightSheet = OwnedPokemon.GetSpriteFromID(pokemonID.ToString(), false, true); } exclaim = transform.FindChild("Exclaim").gameObject; }
public OwnedPokemon GetOwnedPokemon(List <OwnedPokemon> ownedPokemons) { OwnedPokemon PlayerPoke = new OwnedPokemon(); PlayerPoke = ownedPokemons[0]; return(PlayerPoke); }
private void updateSelectionMoveset(OwnedPokemon selectedPokemon) { var moveset = selectedPokemon.CurrentMoveset; for (int i = 0; i != OwnedPokemon.MOVESET_SIZE; ++i) { var ownedPokemonMove = moveset[i]; if (ownedPokemonMove != null) { moveNames[i].text = ownedPokemonMove.Move.Name; moveTypes[i].sprite = Resources.Load <Sprite>("PCSprites/type" + PokemonTypeHelper.GetName(ownedPokemonMove.Move.CurrentType)); movePPTexts[i].text = "PP"; movePPs[i].text = ownedPokemonMove.CurrentPP + "/" + ownedPokemonMove.CurrentMaxPP; } else { moveNames[i].text = null; moveTypes[i].sprite = Resources.Load <Sprite>("null"); movePPTexts[i].text = null; movePPs[i].text = null; } moveNameShadows[i].text = moveNames[i].text; movePPTextShadows[i].text = movePPTexts[i].text; movePPShadows[i].text = movePPs[i].text; } updateSelectedMove(null); }
public void swapPokemon(int box1, int pos1, int box2, int pos2) { OwnedPokemon temp = boxes[box1][pos1]; boxes[box1][pos1] = boxes[box2][pos2]; boxes[box2][pos2] = temp; }
//Add a new pokemon. If pokemon could not be added return false. public bool addPokemon(OwnedPokemon acquiredPokemon) { //attempt to add to party first. pack the party array if space available. if (hasSpace(0)) { packParty(); boxes[0][boxes[0].Length - 1] = acquiredPokemon; packParty(); return(true); } //attempt to add to the earliest available PC box. no array packing needed. else { for (int i = 1; i < boxes.Length; i++) { if (hasSpace(i)) { for (int i2 = 0; i2 < boxes[i].Length; i2++) { if (boxes[i][i2] == null) { boxes[i][i2] = acquiredPokemon; return(true); } } } } } //if could not add a pokemon, return false. Party and PC are both full. return(false); }
void Start() { for (int i = 0; i < trainerParty.Length; i++) { party[i] = new OwnedPokemon(trainerParty[i].ID.ToString(), trainerParty[i].gender, trainerParty[i].level, "Poké Ball", trainerParty[i].heldItem, trainerName, trainerParty[i].ability); } }
public void EnterBattle(Rarity rarity) { //Camera into BattleMode playerCamera.SetActive(false); battleCamera.SetActive(true); //change State bm.state = BattleState.Start; //Get a Random Pokemon from the List BasePokemon battlePokemon = GetRandomPokemonFromList(GetPokemonByRarity(rarity)); OwnedPokemon PlayerPokemon = GetOwnedPokemon(plyr.ownedPokemon); //Stop Player from Moving player.GetComponent <PlayerMovement>().isAllowedToMove = false; //Initiate Pokemon dPoke = Instantiate(emptyPoke, defencePodium.transform.position, Quaternion.identity) as GameObject; aPoke = Instantiate(emptyPoke, attackPodium.transform.position, Quaternion.identity) as GameObject; //Set Position to to a flat Number? Vector3 pokeLocalPos = new Vector3(0, 1, 0); Vector3 friendlyLocalPos = new Vector3(0, 0, 0); dPoke.transform.parent = defencePodium; aPoke.transform.parent = attackPodium; dPoke.transform.localPosition = pokeLocalPos; aPoke.transform.localPosition = friendlyLocalPos; dPoke.transform.parent = defencePodium; aPoke.transform.parent = attackPodium; //copy BasePokemon so it gets individuell tempPoke = dPoke.AddComponent <BasePokemon>() as BasePokemon; playerTempPoke = aPoke.AddComponent <BasePokemon>() as BasePokemon; tempPoke.AddMember(battlePokemon); playerTempPoke.AddMember(PlayerPokemon.pokemon); //Random level int p = Random.Range(2, 5); tempPoke.level = p; //PlayerPokemon Level playerTempPoke.level = PlayerPokemon.level; //calculate HP tempPoke.HP = (((2 * tempPoke.HP) * p) / 100) + p + 10; playerTempPoke.HP = (((2 * playerTempPoke.HP) * playerTempPoke.level) / 100) + playerTempPoke.level + 10; tempPoke.currentHP = tempPoke.HP; playerTempPoke.currentHP = playerTempPoke.HP; //Set Sprites dPoke.GetComponent <SpriteRenderer>().sprite = battlePokemon.image; aPoke.GetComponent <SpriteRenderer>().sprite = PlayerPokemon.pokemon.image; //User Interface Update bm.InfoText.text = "A wild " + battlePokemon.Name + " appeared!"; bm.ChangeMenu(BattleMenu.Info); bm.GetMoves(PlayerPokemon); bm.GetBattlePokemon(PlayerPokemon); //Update bm.UpdatePokemonDetails(tempPoke.Name, tempPoke.level, tempPoke.currentHP, tempPoke.HP, PlayerPokemon.NickName, playerTempPoke.level, playerTempPoke.currentHP, playerTempPoke.HP); }
public void GetMoves(OwnedPokemon ownedPokemon) { int moveCount = ownedPokemon.moves.Count; if (moveCount == 1) { moveOT = ownedPokemon.moves[0].name; moveO.text = moveOT; moveTT = "---"; moveT.text = moveTT; moveTHT = "---"; moveTH.text = moveTHT; movefT = "---"; moveF.text = movefT; } if (moveCount == 2) { moveOT = ownedPokemon.moves[0].name; moveO.text = moveOT; moveTT = ownedPokemon.moves[1].name; moveT.text = moveTT; moveTHT = "---"; moveTH.text = moveTHT; movefT = "---"; moveF.text = movefT; } if (moveCount == 3) { moveOT = ownedPokemon.moves[0].name; moveO.text = moveOT; moveTT = ownedPokemon.moves[1].name; moveT.text = moveTT; moveTHT = ownedPokemon.moves[2].name; moveTH.text = moveTHT; movefT = "---"; moveF.text = movefT; } if (moveCount == 4) { moveOT = ownedPokemon.moves[0].name; moveO.text = moveOT; moveTT = ownedPokemon.moves[1].name; moveT.text = moveTT; moveTHT = ownedPokemon.moves[2].name; moveTH.text = moveTHT; movefT = ownedPokemon.moves[3].name; moveF.text = movefT; } }
public void Attack(BasePokemon Attacker, BasePokemon Defender, OwnedPokemon ownedPokemon, int AttNbr, Text PokeHP) { MoveType moveType = ownedPokemon.moves[AttNbr].category; if (moveType == MoveType.Physical) { Defender.currentHP -= 4; } else if (moveType == MoveType.Status) { Debug.Log("Status"); } //Defender.currentHP += -(Damage); //PokeHP.text = Defender.currentHP + "/" + Defender.HP; }
public void packParty() { OwnedPokemon[] packedArray = new OwnedPokemon[6]; int i2 = 0; //counter for packed array for (int i = 0; i < 6; i++) { if (boxes[0][i] != null) { //if next object in box has a value packedArray[i2] = boxes[0][i]; //add to packed array i2 += 1; //ready packed array's next position } } boxes[0] = packedArray; }
private IEnumerator NavigateMoves(OwnedPokemon pokemon, bool learning, string newMoveString) { yield break; // ToDO: Redo this. //learnScreen.SetActive(learning); //newMove.gameObject.SetActive(learning); //Vector3 positionMod = (learning) ? new Vector3(0, 32) : new Vector3(0, 0); //moves.localPosition = positionMod; //if (learning) //{ // updateMoveToLearn(newMoveString); //} //string[] pokeMoveset = pokemon.GetMoveset(); //string[] moveset = new string[] //{ // pokeMoveset[0], pokeMoveset[1], // pokeMoveset[2], pokeMoveset[3], // newMoveString, newMoveString //}; //Vector3[] positions = new Vector3[] //{ // new Vector3(21, 32), new Vector3(108, 32), // new Vector3(21, 0), new Vector3(108, 0), // new Vector3(64, -32), new Vector3(64, -32) //}; //moveSelector.enabled = true; //selectedMove.enabled = false; //bool navigatingMoves = true; //bool selectingMove = false; //int currentMoveNumber = 0; //int selectedMoveNumber = -1; //moveSelector.rectTransform.localPosition = positions[0] + positionMod; //updateSelectedMove(moveset[currentMoveNumber]); //yield return null; //while (navigatingMoves) //{ // if (Input.GetAxisRaw("Horizontal") < 0) // { // if (currentMoveNumber == 1) // { // currentMoveNumber = 0; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // else if (currentMoveNumber == 3) // { // if (!string.IsNullOrEmpty(moveset[2])) // { // currentMoveNumber = 2; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // } // else if (learning) // { // if (currentMoveNumber == 5) // { // currentMoveNumber = 4; // } // } // } // else if (Input.GetAxisRaw("Horizontal") > 0) // { // if (currentMoveNumber == 0) // { // if (!string.IsNullOrEmpty(moveset[1])) // { // currentMoveNumber = 1; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // } // else if (currentMoveNumber == 2) // { // if (!string.IsNullOrEmpty(moveset[3])) // { // currentMoveNumber = 3; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // } // else if (learning) // { // if (currentMoveNumber == 4) // { // currentMoveNumber = 5; // } // } // } // else if (Input.GetAxisRaw("Vertical") > 0) // { // if (currentMoveNumber == 2) // { // currentMoveNumber = 0; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // else if (currentMoveNumber == 3) // { // if (!string.IsNullOrEmpty(moveset[1])) // { // currentMoveNumber = 1; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // } // else if (learning) // { // if (currentMoveNumber == 4) // { // if (!string.IsNullOrEmpty(moveset[2])) // { // currentMoveNumber = 2; // } // else // { // currentMoveNumber = 0; // } // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // else if (currentMoveNumber == 5) // { // if (!string.IsNullOrEmpty(moveset[3])) // { // currentMoveNumber = 3; // } // else if (!string.IsNullOrEmpty(moveset[1])) // { // currentMoveNumber = 1; // } // else // { // currentMoveNumber = 0; // } // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // } // } // else if (Input.GetAxisRaw("Vertical") < 0) // { // if (currentMoveNumber == 0) // { // if (!string.IsNullOrEmpty(moveset[2])) // { // currentMoveNumber = 2; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // else if (learning) // { // currentMoveNumber = 4; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // } // else if (currentMoveNumber == 1) // { // if (!string.IsNullOrEmpty(moveset[3])) // { // currentMoveNumber = 3; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // else if (learning) // { // currentMoveNumber = 5; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // } // else if (learning) // { // if (currentMoveNumber == 2) // { // currentMoveNumber = 4; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // else if (currentMoveNumber == 3) // { // currentMoveNumber = 5; // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(scrollClip); // yield return StartCoroutine(moveMoveSelector(positions[currentMoveNumber] + positionMod)); // } // } // } // else if (Input.GetButtonDown("Back")) // { // if (!learning) // { // if (selectingMove) // { // selectingMove = false; // selectedMove.enabled = false; // yield return new WaitForSeconds(0.2f); // } // else // { // navigatingMoves = false; // moveSelector.enabled = false; // updateSelectedMove(null); // SfxHandler.Play(returnClip); // yield return new WaitForSeconds(0.2f); // } // } // else // { // //Cancel learning move // navigatingMoves = false; // SfxHandler.Play(returnClip); // yield return new WaitForSeconds(0.2f); // } // } // else if (Input.GetButtonDown("Select")) // { // if (!learning) // { // if (selectingMove) // { // pokemon.SwapMoves(selectedMoveNumber, currentMoveNumber); // selectingMove = false; // selectedMove.enabled = false; // moveset = pokemon.GetMoveset(); // updateSelectionMoveset(pokemon); // updateSelectedMove(moveset[currentMoveNumber]); // SfxHandler.Play(selectClip); // yield return new WaitForSeconds(0.2f); // } // else // { // selectedMoveNumber = currentMoveNumber; // selectingMove = true; // selectedMove.rectTransform.localPosition = positions[currentMoveNumber] + positionMod; // selectedMove.enabled = true; // SfxHandler.Play(selectClip); // yield return new WaitForSeconds(0.2f); // } // } // else // { // if (currentMoveNumber < 4) // { // //Forget learned move // forget.SetActive(true); // selectedMove.enabled = true; // selectedMove.rectTransform.localPosition = positions[currentMoveNumber] + positionMod; // moveSelector.rectTransform.localPosition = positions[4] + positionMod; // SfxHandler.Play(selectClip); // yield return new WaitForSeconds(0.2f); // bool forgetPrompt = true; // while (forgetPrompt) // { // if (Input.GetButtonDown("Select")) // { // replacedMove = moveset[currentMoveNumber]; // pokemon.ReplaceMove(currentMoveNumber, newMoveString); // forgetPrompt = false; // navigatingMoves = false; // SfxHandler.Play(selectClip); // yield return new WaitForSeconds(0.2f); // } // else if (Input.GetButtonDown("Back")) // { // forget.SetActive(false); // selectedMove.enabled = false; // moveSelector.rectTransform.localPosition = positions[currentMoveNumber] + positionMod; // forgetPrompt = false; // SfxHandler.Play(returnClip); // yield return new WaitForSeconds(0.2f); // } // yield return null; // } // } // else // { // //Cancel learning move // navigatingMoves = false; // SfxHandler.Play(selectClip); // yield return new WaitForSeconds(0.2f); // } // } // } // yield return null; //} }
public void EnterBattle(Rarity rarity) { //changes active camera playerCamera.SetActive(false); battleCamera.SetActive(true); BasePokemon battlePokemon = GetRandomPokemonFromList(GetPokemonByRarity(rarity)); //runs 2 functions to get a random enemy pokemon Debug.Log(battlePokemon.PName); //write to console pokemon name bm.ename.text = battlePokemon.PName; //write to console enemy name player.GetComponent <PlayerMovement2>().isAllowedToMove = false; //make sure player doesnt move while in battle GameObject aPoke = Instantiate(pokebase, attackPodium.transform.position, Quaternion.identity) as GameObject; //create object aPoke GameObject dPoke = Instantiate(pokebase, defencePodium.transform.position, Quaternion.identity) as GameObject; //create object dPoke //creates clones of all of the players pokemon OwnedPokemon opoke1 = player.GetComponent <Player>().ownedPokemon[0]; OwnedPokemon opoke2 = player.GetComponent <Player>().ownedPokemon[1]; OwnedPokemon opoke3 = player.GetComponent <Player>().ownedPokemon[2]; OwnedPokemon opoke4 = player.GetComponent <Player>().ownedPokemon[3]; OwnedPokemon opoke5 = player.GetComponent <Player>().ownedPokemon[4]; OwnedPokemon opoke6 = player.GetComponent <Player>().ownedPokemon[5]; //decides which clone is the currently active pokemon BasePokemon ppoke = aPoke.AddComponent <BasePokemon>() as BasePokemon; ppoke = opoke1.pokemon; if (opoke1.pokemon.HP > 0) { ppoke = opoke1.pokemon; } else if (opoke2.pokemon.HP > 0) { ppoke = opoke2.pokemon; } else if (opoke3.pokemon.HP > 0) { ppoke = opoke3.pokemon; } else if (opoke4.pokemon.HP > 0) { ppoke = opoke4.pokemon; } else if (opoke5.pokemon.HP > 0) { ppoke = opoke5.pokemon; } else if (opoke6.pokemon.HP > 0) { ppoke = opoke6.pokemon; } else { Debug.Log("No Poke Error"); } Debug.Log(ppoke.PName); bm.pname.text = ppoke.PName; Vector3 pokeLocalPos = new Vector3(0, 1, 0); //lets all pokemon know own vector //sets all active pokemon to platform vector dPoke.transform.parent = defencePodium; dPoke.transform.localPosition = pokeLocalPos; aPoke.transform.parent = attackPodium; aPoke.transform.localPosition = pokeLocalPos; //sets up enemy pokemon stats, aswell as tags all pokemon so they can be deleted later. //enemy stats are derived from BasePokemon, and updated for level*statgain+basestat BasePokemon tempPoke = dPoke.AddComponent <BasePokemon>() as BasePokemon; tempPoke.AddMember(battlePokemon); tempPoke.level = Random.Range(EntLvlMin, EntLvlMax); bm.elevel.text = tempPoke.level.ToString(); tempPoke.maxHP = tempPoke.HPGain * tempPoke.level + tempPoke.maxHP; tempPoke.HP = tempPoke.maxHP; tempPoke.AttackStat = tempPoke.AttackGain * tempPoke.level + tempPoke.AttackStat; tempPoke.DefenceStat = tempPoke.DefenceGain * tempPoke.level + tempPoke.DefenceStat; tempPoke.SpeedStat = tempPoke.SpeedGain * tempPoke.level + tempPoke.SpeedStat; tempPoke.SpAttackStat = tempPoke.SpAttackGain * tempPoke.level + tempPoke.SpAttackStat; tempPoke.SpDefenceStat = tempPoke.SpDefenceStat * tempPoke.level + tempPoke.SpDefenceStat; tempPoke.XPtoLvl = 50 * tempPoke.level + tempPoke.XPtoLvl; dPoke.tag = "epoke"; aPoke.tag = "ppoke"; bm.plevel.text = ppoke.level.ToString(); //draws the health stat in the UI bm.epokehealthmin.text = tempPoke.HP.ToString(); bm.epokehealthmax.text = tempPoke.maxHP.ToString(); bm.ppokehealthmin.text = ppoke.HP.ToString(); bm.ppokehealthmax.text = ppoke.maxHP.ToString(); //derives player moves if (ppoke.Move1C != 0) { bm.moveO.text = allMoves[ppoke.Move1C].MoveName; } else { bm.moveO.text = "Empty"; } if (ppoke.Move2C != 0) { bm.moveT.text = allMoves[ppoke.Move2C].MoveName; } else { bm.moveT.text = "Empty"; } if (ppoke.Move3C != 0) { bm.moveTH.text = allMoves[ppoke.Move3C].MoveName; } else { bm.moveTH.text = "Empty"; } if (ppoke.Move2C != 0) { bm.moveF.text = allMoves[ppoke.Move2C].MoveName; } else { bm.moveF.text = "Empty"; } //derives player moves List <LearnableMoves> possibleMoves = new List <LearnableMoves>(); foreach (LearnableMoves lm in tempPoke.learnableMoves) { if (lm.LearnedLevel <= tempPoke.level) { possibleMoves.Add(lm); } } //more deriving enemy moves if (possibleMoves.Count > 0) { int pmindex = Random.Range(0, possibleMoves.Count - 1); tempPoke.Move1C = possibleMoves[pmindex].MoveCode; possibleMoves.RemoveAt(pmindex); } if (possibleMoves.Count > 0) { int pmindex = Random.Range(0, possibleMoves.Count - 1); tempPoke.Move2C = possibleMoves[pmindex].MoveCode; possibleMoves.RemoveAt(pmindex); } if (possibleMoves.Count > 0) { int pmindex = Random.Range(0, possibleMoves.Count - 1); tempPoke.Move3C = possibleMoves[pmindex].MoveCode; possibleMoves.RemoveAt(pmindex); } if (possibleMoves.Count > 0) { int pmindex = Random.Range(0, possibleMoves.Count - 1); tempPoke.Move4C = possibleMoves[pmindex].MoveCode; possibleMoves.RemoveAt(pmindex); } //adds finishing touches to scene, rendering everything, and resetting the battle setup if in second fight dPoke.GetComponent <SpriteRenderer>().sprite = battlePokemon.image; aPoke.GetComponent <SpriteRenderer>().sprite = ppoke.image; activePoke = ppoke; activeEPoke = tempPoke; bm.ChangeMenu(BattleMenu.Selection); bm.runused = false; }
/// <summary> /// Adding a caught pokemon (only a few customizable details) /// </summary> /// <param name="pPokemon"></param> /// <param name="pNickname"></param> /// <param name="pCaughtBall"></param> public OwnedPokemon(OwnedPokemon pPokemon, string pNickname, string pCaughtBall) : this(pPokemon.Species.GameId) { Nickname = pNickname; // Set status. CurrentStatus = pPokemon.CurrentStatus; // Set level and experience. CurrentLevel = pPokemon.CurrentLevel; CurrentExperience = pPokemon.CurrentExperience; // Set friendship. CurrentFriendship = pPokemon.Species.BaseFriendship; // Set gender. Gender = pPokemon.Gender; // Set rare value. RareValue = pPokemon.RareValue; // Set met data. MetData = pPokemon.MetData; // Set DO n°. generateDONumber(); // Set nature. Nature = pPokemon.Nature; // Set ability. CurrentAbility = pPokemon.CurrentAbility; Stats = pPokemon.Stats; //// Copy IVs. //Stats[PokemonStatType.HP].IV = pPokemon.GetIV(PokemonStatType.HP); //Stats[PokemonStatType.Attack].IV = pPokemon.GetIV(PokemonStatType.Attack); //Stats[PokemonStatType.Defence].IV = pPokemon.GetIV(PokemonStatType.Defence); //Stats[PokemonStatType.SpecialAttack].IV = pPokemon.GetIV(PokemonStatType.SpecialAttack); //Stats[PokemonStatType.SpecialDefence].IV = pPokemon.GetIV(PokemonStatType.SpecialDefence); //Stats[PokemonStatType.Speed].IV = pPokemon.GetIV(PokemonStatType.Speed); //// Copy EVs. //Stats[PokemonStatType.HP].EV = pPokemon.GetEV(PokemonStatType.HP); //Stats[PokemonStatType.Attack].EV = pPokemon.GetEV(PokemonStatType.Attack); //Stats[PokemonStatType.Defence].EV = pPokemon.GetEV(PokemonStatType.Defence); //Stats[PokemonStatType.SpecialAttack].EV = pPokemon.GetEV(PokemonStatType.SpecialAttack); //Stats[PokemonStatType.SpecialDefence].EV = pPokemon.GetEV(PokemonStatType.SpecialDefence); //Stats[PokemonStatType.Speed].EV = pPokemon.GetEV(PokemonStatType.Speed); // MoveSet. _currentMoveset = pPokemon._currentMoveset; _moveHistory = pPokemon._moveHistory; PPups = pPokemon.PPups; //set maxPP and PP to be the regular PP defined by the move in the database. maxPP = new int[4]; PP = new int[4]; for (int i = 0; i < 4; i++) { if (!string.IsNullOrEmpty(_currentMoveset[i])) { maxPP[i] = Mathf.FloorToInt(MoveDatabase.getMove(_currentMoveset[i]).getPP() * ((PPups[i] * 0.2f) + 1)); PP[i] = maxPP[i]; } } packMoveset(); }
public IEnumerator control() { //sceneTransition.FadeIn(); StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed)); running = true; switching = false; swapPosition = -1; currentPosition = 0; SaveData.currentSave.PC.packParty(); updateParty(); updateFrames(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); StartCoroutine("animateIcons"); while (running) { if (Input.GetAxisRaw("Horizontal") > 0) { if (currentPosition < 6) { shiftPosition(1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Horizontal") < 0) { if (currentPosition > 0) { shiftPosition(-1); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Vertical") > 0) { if (currentPosition > 0) { if (currentPosition == 6) { shiftPosition(-1); } else { shiftPosition(-2); } SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetAxisRaw("Vertical") < 0) { if (currentPosition < 6) { shiftPosition(2); SfxHandler.Play(selectClip); yield return(new WaitForSeconds(0.2f)); } } else if (Input.GetButton("Select")) { if (currentPosition == 6) { if (switching) { switching = false; swapPosition = -1; updateFrames(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); yield return(new WaitForSeconds(0.2f)); } else { SfxHandler.Play(selectClip); running = false; } } else if (switching) { if (currentPosition == swapPosition) { switching = false; swapPosition = -1; updateFrames(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); yield return(new WaitForSeconds(0.2f)); } else { yield return(StartCoroutine(switchPokemon(swapPosition, currentPosition))); switching = false; swapPosition = -1; updateFrames(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); yield return(new WaitForSeconds(0.2f)); } } else { OwnedPokemon selectedPokemon = SaveData.currentSave.PC.boxes[0][currentPosition]; int chosenIndex = -1; while (chosenIndex != 0) { string[] choices = new string[] { "Summary", "Switch", "Item", "Cancel" }; chosenIndex = -1; SfxHandler.Play(selectClip); Dialog.drawDialogBox(); Dialog.drawTextInstant("Do what with " + selectedPokemon.GetName() + "?"); Dialog.drawChoiceBox(choices); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigate(choices))); chosenIndex = Dialog.chosenIndex; if (chosenIndex == 3) { //Summary SfxHandler.Play(selectClip); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); //Set SceneSummary to be active so that it appears PKUScene.main.Summary.gameObject.SetActive(true); StartCoroutine(PKUScene.main.Summary.control(SaveData.currentSave.PC.boxes[0], currentPosition)); //Start an empty loop that will only stop when SceneSummary is no longer active (is closed) while (PKUScene.main.Summary.gameObject.activeSelf) { yield return(null); } chosenIndex = 0; Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } else if (chosenIndex == 2) { //Switch switching = true; swapPosition = currentPosition; updateFrames(); chosenIndex = 0; Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Move " + selectedPokemon.GetName() + " to where?"); yield return(new WaitForSeconds(0.2f)); } else if (chosenIndex == 1) { //Item Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); if (!string.IsNullOrEmpty(selectedPokemon.getHeldItem())) { yield return (StartCoroutine( Dialog.drawText(selectedPokemon.GetName() + " is holding " + selectedPokemon.getHeldItem() + "."))); choices = new string[] { "Swap", "Take", "Cancel" }; chosenIndex = -1; Dialog.drawChoiceBox(choices); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigate(choices))); chosenIndex = Dialog.chosenIndex; if (chosenIndex == 2) { //Swap SfxHandler.Play(selectClip); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); PKUScene.main.Bag.gameObject.SetActive(true); StartCoroutine(PKUScene.main.Bag.control(false, true)); while (PKUScene.main.Bag.gameObject.activeSelf) { yield return(null); } string chosenItem = PKUScene.main.Bag.chosenItem; Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); if (string.IsNullOrEmpty(chosenItem)) { Dialog.drawTextInstant("Choose a Pokémon."); } //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); if (!string.IsNullOrEmpty(chosenItem)) { Dialog.drawDialogBox(); yield return (StartCoroutine( Dialog.drawText("Swap " + selectedPokemon.getHeldItem() + " for " + chosenItem + "?"))); Dialog.drawChoiceBox(); yield return(StartCoroutine(Dialog.choiceNavigate())); chosenIndex = Dialog.chosenIndex; Dialog.undrawChoiceBox(); if (chosenIndex == 1) { string receivedItem = selectedPokemon.swapHeldItem(chosenItem); SaveData.currentSave.Bag.addItem(receivedItem, 1); SaveData.currentSave.Bag.removeItem(chosenItem, 1); Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "Gave " + chosenItem + " to " + selectedPokemon.GetName() + ",")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "and received " + receivedItem + " in return.")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } } } else if (chosenIndex == 1) { //Take Dialog.undrawChoiceBox(); string receivedItem = selectedPokemon.swapHeldItem(""); SaveData.currentSave.Bag.addItem(receivedItem, 1); updateParty(); updateFrames(); Dialog.drawDialogBox(); yield return (StartCoroutine( Dialog.drawText("Took " + receivedItem + " from " + selectedPokemon.GetName() + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } } else { yield return (StartCoroutine( Dialog.drawText(selectedPokemon.GetName() + " isn't holding anything."))); choices = new string[] { "Give", "Cancel" }; chosenIndex = -1; Dialog.drawChoiceBox(choices); yield return(new WaitForSeconds(0.2f)); yield return(StartCoroutine(Dialog.choiceNavigate(choices))); chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { //Give SfxHandler.Play(selectClip); //yield return new WaitForSeconds(sceneTransition.FadeOut(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); PKUScene.main.Bag.gameObject.SetActive(true); StartCoroutine(PKUScene.main.Bag.control(false, true)); while (PKUScene.main.Bag.gameObject.activeSelf) { yield return(null); } string chosenItem = PKUScene.main.Bag.chosenItem; Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); if (string.IsNullOrEmpty(chosenItem)) { Dialog.drawTextInstant("Choose a Pokémon."); } //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); if (!string.IsNullOrEmpty(chosenItem)) { selectedPokemon.swapHeldItem(chosenItem); SaveData.currentSave.Bag.removeItem(chosenItem, 1); updateParty(); updateFrames(); Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "Gave " + chosenItem + " to " + selectedPokemon.GetName() + ".")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } } } chosenIndex = 0; yield return(new WaitForSeconds(0.2f)); } } if (!switching) { Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); } } } else if (Input.GetButton("Back")) { if (switching) { switching = false; swapPosition = -1; updateFrames(); Dialog.undrawChoiceBox(); Dialog.drawDialogBox(); Dialog.drawTextInstant("Choose a Pokémon."); yield return(new WaitForSeconds(0.2f)); } else { currentPosition = 6; updateFrames(); SfxHandler.Play(selectClip); 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); }
public IEnumerator interact() { if (!Player.strength) { OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty("Strength"); if (targetPokemon != null) { if (Player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", interactText)); Dialog.drawChoiceBox(); //You CAN NOT get a value from a Coroutine. As a result, the coroutine runs and resets a public int in it's own script. yield return(Dialog.StartCoroutine(Dialog.choiceNavigate())); //it then assigns a value to that int Dialog.undrawChoiceBox(); if (Dialog.chosenIndex == 1) { Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance("Strength") + "!") ); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); //Activate strength Player.activateStrength(); yield return(new WaitForSeconds(0.5f)); } Dialog.undrawDialogBox(); } } else { if (Player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", examineText)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); } } } else { if (Player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", examineTextStrengthActive)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); } } yield return(new WaitForSeconds(0.2f)); Player.unsetCheckBusyWith(this.gameObject); }
public IEnumerator control(OwnedPokemon pokemon, string newMoveString) { yield return(StartCoroutine(control(new OwnedPokemon[] { pokemon }, 0, true, newMoveString))); }
private void PlayCry(OwnedPokemon pokemon) { SfxHandler.Play(pokemon.GetCry(), pokemon.GetCryPitch()); }
private void updateSelection(OwnedPokemon selectedPokemon) { frame = 0; PlayCry(selectedPokemon); selectedCaughtBall.sprite = Resources.Load <Sprite>("null"); selectedCaughtBall.sprite = Resources.Load <Sprite>("PCSprites/summary" + selectedPokemon.MetData.CaughtBall); selectedName.text = selectedPokemon.GetName(); selectedNameShadow.text = selectedName.text; if (selectedPokemon.Gender == PokemonGender.FEMALE) { selectedGender.text = "♀"; selectedGender.color = new Color(1, 0.2f, 0.2f, 1); } else if (selectedPokemon.Gender == PokemonGender.MALE) { selectedGender.text = "♂"; selectedGender.color = new Color(0.2f, 0.4f, 1, 1); } else { selectedGender.text = null; } selectedGenderShadow.text = selectedGender.text; selectedLevel.text = "" + selectedPokemon.CurrentLevel; selectedLevelShadow.text = selectedLevel.text; selectedSpriteAnimation = selectedPokemon.GetFrontAnim_(); if (selectedSpriteAnimation.Length > 0) { selectedSprite.sprite = selectedSpriteAnimation[0]; } if (string.IsNullOrEmpty(selectedPokemon.getHeldItem())) { selectedHeldItem.text = "None"; } else { selectedHeldItem.text = selectedPokemon.getHeldItem(); } selectedHeldItemShadow.text = selectedHeldItem.text; if (selectedPokemon.CurrentStatus != PokemonStatus.NONE) { selectedStatus.sprite = Resources.Load <Sprite>("PCSprites/status" + selectedPokemon.CurrentStatus.ToString()); } else { selectedStatus.sprite = Resources.Load <Sprite>("null"); } if (selectedPokemon.IsShiny) { selectedShiny.sprite = Resources.Load <Sprite>("PCSprites/shiny"); } else { selectedShiny.sprite = Resources.Load <Sprite>("null"); } dexNo.text = selectedPokemon.Species.GameId; dexNoShadow.text = dexNo.text; species.text = selectedPokemon.Species.Name; speciesShadow.text = species.text; // ToDo: implement types. //string type1string = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID()).getType1().ToString(); //string type2string = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID()).getType2().ToString(); //type1.sprite = Resources.Load<Sprite>("null"); //type2.sprite = Resources.Load<Sprite>("null"); //if (type1string != "NONE") //{ // type1.sprite = Resources.Load<Sprite>("PCSprites/type" + type1string); // type1.rectTransform.localPosition = new Vector3(71, type1.rectTransform.localPosition.y); //} //if (type2string != "NONE") //{ // type2.sprite = Resources.Load<Sprite>("PCSprites/type" + type2string); //} //else //{ // //if single type pokemon, center the type icon // type1.rectTransform.localPosition = new Vector3(89, type1.rectTransform.localPosition.y); //} // ToDo: implement owner. //OT.text = selectedPokemon.getOT(); //OTShadow.text = OT.text; //IDNo.text = "" + selectedPokemon.getIDno(); //IDNoShadow.text = IDNo.text; expPoints.text = "" + selectedPokemon.CurrentExperience; expPointsShadow.text = expPoints.text; float expCurrentLevel = PokemonLevelingRateHelper.GetRequiredExperienceToTargetLevel(selectedPokemon.Species.LevelingRate, selectedPokemon.CurrentLevel); float expNextlevel = PokemonLevelingRateHelper.GetRequiredExperienceToTargetLevel(selectedPokemon.Species.LevelingRate, selectedPokemon.CurrentLevel + 1); float expAlong = selectedPokemon.CurrentExperience - expCurrentLevel; float expDistance = expAlong / (expNextlevel - expCurrentLevel); toNextLevel.text = "" + (expNextlevel - selectedPokemon.CurrentExperience); toNextLevelShadow.text = toNextLevel.text; expBar.rectTransform.sizeDelta = new Vector2(Mathf.Floor(expDistance * 64f), expBar.rectTransform.sizeDelta.y); string natureFormatted = PokemonNatureHelper.GetNatureName(selectedPokemon.Nature); natureFormatted = natureFormatted.Substring(0, 1) + natureFormatted.Substring(1).ToLowerInvariant(); nature.text = "<color=#F22F>" + natureFormatted + "</color> nature."; natureShadow.text = natureFormatted + " nature."; metDate.text = "Met on " + selectedPokemon.MetData.Date; metDateShadow.text = metDate.text; metMap.text = "<color=#F22F>" + selectedPokemon.MetData.Location + "</color>"; metMapShadow.text = selectedPokemon.MetData.Location; metLevel.text = "Met at Level " + selectedPokemon.MetData.Level + "."; metLevelShadow.text = metLevel.text; string[][] characteristics = new string[][] { new string[] { "Loves to eat", "Takes plenty of siestas", "Nods off a lot", "Scatters things often", "Likes to relax" }, new string[] { "Proud of its power", "Likes to thrash about", "A little quick tempered", "Likes to fight", "Quick tempered" }, new string[] { "Sturdy body", "Capable of taking hits", "Highly persistent", "Good endurance", "Good perseverance" }, new string[] { "Highly curious", "Mischievous", "Thoroughly cunning", "Often lost in thought", "Very finicky" }, new string[] { "Strong willed", "Somewhat vain", "Strongly defiant", "Hates to lose", "Somewhat stubborn" }, new string[] { "Likes to run", "Alert to sounds", "Impetuous and silly", "Somewhat of a clown", "Quick to flee" } }; var highestIV = selectedPokemon.GetHighestIV(); characteristic.text = characteristics[(int)highestIV][selectedPokemon.GetIV(highestIV) % 5] + "."; characteristicShadow.text = characteristic.text; float currentHP = selectedPokemon.GetCurrentStatValue(PokemonStatType.HP); float maxHP = selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP); HP.text = currentHP + "/" + maxHP; HPShadow.text = HP.text; HPBar.rectTransform.sizeDelta = new Vector2(selectedPokemon.getPercentHP() * 48f, HPBar.rectTransform.sizeDelta.y); if (currentHP < (maxHP / 4f)) { HPBar.color = new Color(1, 0.125f, 0, 1); } else if (currentHP < (maxHP / 2f)) { HPBar.color = new Color(1, 0.75f, 0, 1); } else { HPBar.color = new Color(0.125f, 1, 0.065f, 1); } //float[] natureMod = new float[] //{ // NatureDatabase.getNature(selectedPokemon.Nature).getATK(), // NatureDatabase.getNature(selectedPokemon.Nature).getDEF(), // NatureDatabase.getNature(selectedPokemon.Nature).getSPA(), // NatureDatabase.getNature(selectedPokemon.Nature).getSPD(), // NatureDatabase.getNature(selectedPokemon.Nature).getSPE() //}; Stats.text = selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Attack) + "\n" + selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Defence) + "\n" + selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.SpecialAttack) + "\n" + selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.SpecialDefence) + "\n" + selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.Speed); StatsShadow.text = Stats.text; //string[] statsLines = new string[] { "Attack", "Defence", "Sp. Atk", "Sp. Def", "Speed" }; StatsTextShadow.text = ""; //for (int i = 0; i < 5; i++) //{ // if (natureMod[i] > 1) // { // StatsTextShadow.text += "<color=#A01010FF>" + statsLines[i] + "</color>\n"; // } // else if (natureMod[i] < 1) // { // StatsTextShadow.text += "<color=#0030A2FF>" + statsLines[i] + "</color>\n"; // } // else // { // StatsTextShadow.text += statsLines[i] + "\n"; // } //} //abilityName.text = PokemonDatabase.Instance.GetPokemonSpeciesByGameId(selectedPokemon.getID().ToString()).getAbility(selectedPokemon.getAbility()); abilityNameShadow.text = abilityName.text; //abilities not yet implemented abilityDescription.text = ""; abilityDescriptionShadow.text = abilityDescription.text; updateSelectionMoveset(selectedPokemon); }
private IEnumerator runEvent(CustomEventTree[] treesArray, int index) { CustomEventDetails currentEvent = treesArray[eventTreeIndex].events[index]; CustomEventDetails nextEvent = null; if (index + 1 < treesArray[eventTreeIndex].events.Length) { //if not the last event nextEvent = treesArray[eventTreeIndex].events[index + 1]; } NPCHandler targetNPC = null; CustomEventDetails.CustomEventType ty = currentEvent.eventType; Debug.Log("Run event. Type: " + ty.ToString()); switch (ty) { case (CustomEventDetails.CustomEventType.Wait): yield return(new WaitForSeconds(currentEvent.float0)); break; case (CustomEventDetails.CustomEventType.Walk): if (currentEvent.object0.GetComponent <NPCHandler>() != null) { targetNPC = currentEvent.object0.GetComponent <NPCHandler>(); int initialDirection = targetNPC.direction; targetNPC.direction = (int)currentEvent.dir; for (int i = 0; i < currentEvent.int0; i++) { targetNPC.direction = (int)currentEvent.dir; Vector3 forwardsVector = targetNPC.getForwardsVector(true); if (currentEvent.bool0) { //if direction locked in targetNPC.direction = initialDirection; } while (forwardsVector == new Vector3(0, 0, 0)) { targetNPC.direction = (int)currentEvent.dir; forwardsVector = targetNPC.getForwardsVector(true); if (currentEvent.bool0) { //if direction locked in targetNPC.direction = initialDirection; } yield return(new WaitForSeconds(0.1f)); } targetNPC.setOverrideBusy(true); yield return(StartCoroutine(targetNPC.move(forwardsVector, currentEvent.float0))); targetNPC.setOverrideBusy(false); } targetNPC.setFrameStill(); } //Move the player if set to player if (currentEvent.object0 == PlayerMovement.player.gameObject) { int initialDirection = PlayerMovement.player.direction; PlayerMovement.player.speed = (currentEvent.float0 > 0) ? PlayerMovement.player.walkSpeed / currentEvent.float0 : PlayerMovement.player.walkSpeed; for (int i = 0; i < currentEvent.int0; i++) { PlayerMovement.player.updateDirection((int)currentEvent.dir); Vector3 forwardsVector = PlayerMovement.player.getForwardVector(); if (currentEvent.bool0) { //if direction locked in PlayerMovement.player.updateDirection(initialDirection); } PlayerMovement.player.setOverrideAnimPause(true); yield return (StartCoroutine(PlayerMovement.player.move(forwardsVector, false, currentEvent.bool0))); PlayerMovement.player.setOverrideAnimPause(false); } PlayerMovement.player.speed = PlayerMovement.player.walkSpeed; } break; case (CustomEventDetails.CustomEventType.TurnTo): int direction; float xDistance; float zDistance; if (currentEvent.object0.GetComponent <NPCHandler>() != null) { targetNPC = currentEvent.object0.GetComponent <NPCHandler>(); } if (targetNPC != null) { if (currentEvent.object1 != null) { //calculate target objects's position relative to this objects's and set direction accordingly. xDistance = targetNPC.hitBox.position.x - currentEvent.object1.transform.position.x; zDistance = targetNPC.hitBox.position.z - currentEvent.object1.transform.position.z; if (xDistance >= Mathf.Abs(zDistance)) { //Mathf.Abs() converts zDistance to a positive always. direction = 3; } //this allows for better accuracy when checking orientation. else if (xDistance <= Mathf.Abs(zDistance) * -1) { direction = 1; } else if (zDistance >= Mathf.Abs(xDistance)) { direction = 2; } else { direction = 0; } targetNPC.setDirection(direction); } if (currentEvent.int0 != 0) { direction = targetNPC.direction + currentEvent.int0; while (direction > 3) { direction -= 4; } while (direction < 0) { direction += 4; } targetNPC.setDirection(direction); } } break; case (CustomEventDetails.CustomEventType.Dialog): for (int i = 0; i < currentEvent.strings.Length; i++) { Dialog.drawDialogBox(); yield return(StartCoroutine(Dialog.drawText(currentEvent.strings[i]))); if (i < currentEvent.strings.Length - 1) { while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } } if (nextEvent != null) { if (nextEvent.eventType != CustomEventDetails.CustomEventType.Choice) { while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } if (!EventRequiresDialogBox(nextEvent.eventType)) { Dialog.undrawDialogBox(); } // do not undraw the box if the next event needs it } } else { while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); } break; case (CustomEventDetails.CustomEventType.Choice): if (currentEvent.strings.Length > 1) { Dialog.drawChoiceBox(currentEvent.strings); yield return(StartCoroutine(Dialog.choiceNavigate(currentEvent.strings))); } else { Dialog.drawChoiceBox(); yield return(StartCoroutine(Dialog.choiceNavigate())); } int chosenIndex = Dialog.chosenIndex; chosenIndex = currentEvent.ints.Length - 1 - chosenIndex; //flip it to reflect the original input Dialog.undrawChoiceBox(); Dialog.undrawDialogBox(); if (chosenIndex < currentEvent.ints.Length) { //only change tree if index is valid if (currentEvent.ints[chosenIndex] != eventTreeIndex && currentEvent.ints[chosenIndex] < treesArray.Length) { JumpToTree(currentEvent.ints[chosenIndex]); } } break; case CustomEventDetails.CustomEventType.Sound: SfxHandler.Play(currentEvent.sound); break; case CustomEventDetails.CustomEventType.ReceiveItem: //Play Good for TM, Average for Item AudioClip itemGetMFX = (currentEvent.bool0) ? Resources.Load <AudioClip>("Audio/mfx/GetGood") : Resources.Load <AudioClip>("Audio/mfx/GetDecent"); BgmHandler.main.PlayMFX(itemGetMFX); string firstLetter = currentEvent.string0.Substring(0, 1).ToLowerInvariant(); Dialog.drawDialogBox(); if (currentEvent.bool0) { Dialog.StartCoroutine("drawText", SaveData.currentSave.playerName + " received TM" + ItemDatabase.getItem(currentEvent.string0).getTMNo() + ": " + currentEvent.string0 + "!"); } else { if (currentEvent.int0 > 1) { Dialog.StartCoroutine("drawText", SaveData.currentSave.playerName + " received " + currentEvent.string0 + "s!"); } else if (firstLetter == "a" || firstLetter == "e" || firstLetter == "i" || firstLetter == "o" || firstLetter == "u") { Dialog.StartCoroutine("drawText", SaveData.currentSave.playerName + " received an " + currentEvent.string0 + "!"); } else { Dialog.StartCoroutine("drawText", SaveData.currentSave.playerName + " received a " + currentEvent.string0 + "!"); } } yield return(new WaitForSeconds(itemGetMFX.length)); bool itemAdd = SaveData.currentSave.Bag.addItem(currentEvent.string0, currentEvent.int0); Dialog.drawDialogBox(); if (itemAdd) { if (currentEvent.bool0) { yield return (Dialog.StartCoroutine("drawTextSilent", SaveData.currentSave.playerName + " put the TM" + ItemDatabase.getItem(currentEvent.string0).getTMNo() + " \\away into the bag.")); } else { if (currentEvent.int0 > 1) { yield return (Dialog.StartCoroutine("drawTextSilent", SaveData.currentSave.playerName + " put the " + currentEvent.string0 + "s \\away into the bag.")); } else { yield return (Dialog.StartCoroutine("drawTextSilent", SaveData.currentSave.playerName + " put the " + currentEvent.string0 + " \\away into the bag.")); } } while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } else { yield return(Dialog.StartCoroutine("drawTextSilent", "But there was no room...")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } Dialog.undrawDialogBox(); break; case CustomEventDetails.CustomEventType.ReceivePokemon: if (SaveData.currentSave.PC.hasSpace(0)) { //Play Great for Pokemon AudioClip pokeGetMFX = Resources.Load <AudioClip>("Audio/mfx/GetGreat"); var pkmn = GameController.Instance.PokemonDb.GetPokemonSpeciesByGameId(currentEvent.ints[0].ToString()); string pkName = pkmn.Name; PokemonGender pkGender = PokemonGender.CALCULATE; if (pkmn.MaleRatio < 0) { pkGender = PokemonGender.NONE; } else if (pkmn.MaleRatio == 0) { pkGender = PokemonGender.FEMALE; } else if (pkmn.MaleRatio == 100) { pkGender = PokemonGender.MALE; } else { //if not a set gender if (currentEvent.ints[2] == 0) { pkGender = PokemonGender.MALE; } else if (currentEvent.ints[2] == 1) { pkGender = PokemonGender.FEMALE; } } Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", SaveData.currentSave.playerName + " received the " + pkName + "!")); BgmHandler.main.PlayMFX(pokeGetMFX); yield return(new WaitForSeconds(pokeGetMFX.length)); string nickname = currentEvent.strings[0]; if (currentEvent.strings[1].Length == 0) { //If no OT set, allow nicknaming of Pokemon Dialog.drawDialogBox(); yield return (StartCoroutine( Dialog.drawTextSilent("Would you like to give a nickname to \nthe " + pkName + " you received?"))); Dialog.drawChoiceBox(); yield return(StartCoroutine(Dialog.choiceNavigate())); int nicknameCI = Dialog.chosenIndex; Dialog.undrawDialogBox(); Dialog.undrawChoiceBox(); if (nicknameCI == 1) { //give nickname //SfxHandler.Play(selectClip); yield return(StartCoroutine(ScreenFade.main.Fade(false, 0.4f))); PKUScene.main.Typing.gameObject.SetActive(true); StartCoroutine(PKUScene.main.Typing.control(10, "", pkGender, OwnedPokemon.GetIconsFromID_(currentEvent.ints[0].ToString(), currentEvent.bool0))); while (PKUScene.main.Typing.gameObject.activeSelf) { yield return(null); } if (PKUScene.main.Typing.typedString.Length > 0) { nickname = PKUScene.main.Typing.typedString; } yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); } } if (!EventRequiresDialogBox(nextEvent.eventType)) { Dialog.undrawDialogBox(); } int[] IVs = new int[] { Random.Range(0, 32), Random.Range(0, 32), Random.Range(0, 32), Random.Range(0, 32), Random.Range(0, 32), Random.Range(0, 32) }; if (currentEvent.bool1) { //if using Custom IVs IVs[0] = currentEvent.ints[5]; IVs[1] = currentEvent.ints[6]; IVs[2] = currentEvent.ints[7]; IVs[3] = currentEvent.ints[8]; IVs[4] = currentEvent.ints[9]; IVs[5] = currentEvent.ints[10]; } //PokemonNature pkNature = (currentEvent.ints[3] == 0) // ? PokemonNatureHelper.GetRandomNature() // : (PokemonNature)currentEvent.ints[3] - 1; //string[] pkMoveset = pkd.GenerateMoveset(currentEvent.ints[1]); //for (int i = 0; i < 4; i++) //{ // if (currentEvent.strings[4 + i].Length > 0) // { // pkMoveset[i] = currentEvent.strings[4 + i]; // } //} //Debug.Log(pkMoveset[0] + ", " + pkMoveset[1] + ", " + pkMoveset[2] + ", " + pkMoveset[3]); //OwnedPokemon pk = new OwnedPokemon(currentEvent.ints[0], nickname, pkGender, currentEvent.ints[1], // currentEvent.bool0, currentEvent.strings[2], currentEvent.strings[3], // currentEvent.strings[1], IVs[0], IVs[1], IVs[2], IVs[3], IVs[4], IVs[5], 0, 0, 0, 0, 0, 0, // pkNature, currentEvent.ints[4], // pkMoveset, new int[4]); //SaveData.currentSave.PC.addPokemon(pk); } else { //jump to new tree JumpToTree(currentEvent.int0); } break; case (CustomEventDetails.CustomEventType.SetActive): if (currentEvent.bool0) { currentEvent.object0.SetActive(true); } else { if (currentEvent.object0 == this.gameObject) { deactivateOnFinish = true; } else if (currentEvent.object0 != PlayerMovement.player.gameObject) { //important to never deactivate the player currentEvent.object0.SetActive(false); } } break; case CustomEventDetails.CustomEventType.SetCVariable: SaveData.currentSave.setCVariable(currentEvent.string0, currentEvent.float0); break; case (CustomEventDetails.CustomEventType.LogicCheck): bool passedCheck = false; CustomEventDetails.Logic lo = currentEvent.logic; switch (lo) { case CustomEventDetails.Logic.CVariableEquals: if (currentEvent.float0 == SaveData.currentSave.getCVariable(currentEvent.string0)) { passedCheck = true; } break; case CustomEventDetails.Logic.CVariableGreaterThan: if (SaveData.currentSave.getCVariable(currentEvent.string0) > currentEvent.float0) { passedCheck = true; } break; case CustomEventDetails.Logic.CVariableLessThan: if (SaveData.currentSave.getCVariable(currentEvent.string0) < currentEvent.float0) { passedCheck = true; } break; case CustomEventDetails.Logic.GymBadgeNoOwned: if (Mathf.FloorToInt(currentEvent.float0) < SaveData.currentSave.gymsBeaten.Length && Mathf.FloorToInt(currentEvent.float0) >= 0) { //ensure input number is valid if (SaveData.currentSave.gymsBeaten[Mathf.FloorToInt(currentEvent.float0)]) { passedCheck = true; } } break; case CustomEventDetails.Logic.GymBadgesEarned: int badgeCount = 0; for (int bi = 0; bi < SaveData.currentSave.gymsBeaten.Length; bi++) { if (SaveData.currentSave.gymsBeaten[bi]) { badgeCount += 1; } } if (badgeCount >= currentEvent.float0) { passedCheck = true; } break; case CustomEventDetails.Logic.PokemonIDIsInParty: for (int pi = 0; pi < 6; pi++) { if (SaveData.currentSave.PC.boxes[0][pi] != null) { // ToDo: Update this script so it uses the right ID. //if (SaveData.currentSave.PC.boxes[0][pi].getID() == // Mathf.FloorToInt(currentEvent.float0)) //{ // passedCheck = true; // pi = 6; //} } } break; case CustomEventDetails.Logic.SpaceInParty: if (currentEvent.bool0) { if (!SaveData.currentSave.PC.hasSpace(0)) { passedCheck = true; } } else { if (SaveData.currentSave.PC.hasSpace(0)) { passedCheck = true; } } break; } if (passedCheck) { int newTreeIndex = currentEvent.int0; if (newTreeIndex != eventTreeIndex && //only change tree if index is valid newTreeIndex < treesArray.Length) { JumpToTree(newTreeIndex); } } break; case CustomEventDetails.CustomEventType.TrainerBattle: //custom cutouts not yet implemented StartCoroutine(ScreenFade.main.FadeCutout(false, ScreenFade.slowedSpeed, null)); //Automatic LoopStart usage not yet implemented PKUScene.main.Battle.gameObject.SetActive(true); Trainer trainer = currentEvent.object0.GetComponent <Trainer>(); if (trainer.battleBGM != null) { Debug.Log(trainer.battleBGM.name); BgmHandler.main.PlayOverlay(trainer.battleBGM, trainer.samplesLoopStart); } else { BgmHandler.main.PlayOverlay(PKUScene.main.Battle.defaultTrainerBGM, PKUScene.main.Battle.defaultTrainerBGMLoopStart); } PKUScene.main.Battle.gameObject.SetActive(false); yield return(new WaitForSeconds(1.6f)); PKUScene.main.Battle.gameObject.SetActive(true); StartCoroutine(PKUScene.main.Battle.control(true, trainer, currentEvent.bool0)); while (PKUScene.main.Battle.gameObject.activeSelf) { yield return(null); } //yield return new WaitForSeconds(sceneTransition.FadeIn(0.4f)); yield return(StartCoroutine(ScreenFade.main.Fade(true, 0.4f))); if (currentEvent.bool0) { if (PKUScene.main.Battle.victor == 1) { int newTreeIndex = currentEvent.int0; if (newTreeIndex != eventTreeIndex && //only change tree if index is valid newTreeIndex < treesArray.Length) { JumpToTree(newTreeIndex); } } } break; } }
private IEnumerator surfCheck() { OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty("Surf"); if (targetPokemon != null) { if (getForwardVector(direction, false) != Vector3.zero) { if (setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", "The water is dyed a deep blue. Would you \nlike to surf on it?")); Dialog.drawChoiceBox(); yield return(Dialog.StartCoroutine("choiceNavigate")); Dialog.undrawChoiceBox(); int chosenIndex = Dialog.chosenIndex; if (chosenIndex == 1) { Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance("Surf") + "!")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } surfing = true; updateMount(true, "surf"); BgmHandler.main.PlayMain(GlobalVariables.global.surfBGM, GlobalVariables.global.surfBgmLoopStart); //determine the vector for the space in front of the player by checking direction Vector3 spaceInFront = new Vector3(0, 0, 0); if (direction == 0) { spaceInFront = new Vector3(0, 0, 1); } else if (direction == 1) { spaceInFront = new Vector3(1, 0, 0); } else if (direction == 2) { spaceInFront = new Vector3(0, 0, -1); } else if (direction == 3) { spaceInFront = new Vector3(-1, 0, 0); } mount.transform.position = mount.transform.position + spaceInFront; followerScript.StartCoroutine("withdrawToBall"); StartCoroutine("stillMount"); forceMoveForward(); yield return(StartCoroutine("jump")); updateAnimation("surf", walkFPS); speed = surfSpeed; } Dialog.undrawDialogBox(); unsetCheckBusyWith(this.gameObject); } } } else { if (setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); yield return(Dialog.StartCoroutine("drawText", "The water is dyed a deep blue.")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); unsetCheckBusyWith(this.gameObject); } } yield return(new WaitForSeconds(0.2f)); }
public void GetBattlePokemon(OwnedPokemon ownedPokemon) { BattlerPoke = ownedPokemon; }
public IEnumerator control(OwnedPokemon pokemonToEvolve, string methodOfEvolution) { yield break; // ToDo: Implement evolution /* * selectedPokemon = pokemonToEvolve; * evolutionMethod = methodOfEvolution; * evolutionID = selectedPokemon.getEvolutionID(evolutionMethod); * string selectedPokemonName = selectedPokemon.GetName(); * * pokemonSpriteAnimation = selectedPokemon.GetFrontAnim_(); * evolutionSpriteAnimation = OwnedPokemon.GetFrontAnimFromID_(evolutionID, selectedPokemon.getGender(), * selectedPokemon.getIsShiny()); * pokemonSprite.sprite = pokemonSpriteAnimation[0]; * evolutionSprite.sprite = evolutionSpriteAnimation[0]; * StartCoroutine(animatePokemon()); * * pokemonSprite.rectTransform.sizeDelta = new Vector2(128, 128); * evolutionSprite.rectTransform.sizeDelta = new Vector2(0, 0); * * pokemonSprite.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); * evolutionSprite.color = new Color(0.5f, 0.5f, 0.5f, 0.5f); * * topBorder.rectTransform.sizeDelta = new Vector2(342, 0); * bottomBorder.rectTransform.sizeDelta = new Vector2(342, 0); * * glow.rectTransform.sizeDelta = new Vector2(0, 0); * * stopAnimations = false; * * * StartCoroutine(ScreenFade.main.Fade(true, 1f)); * yield return new WaitForSeconds(1f); * * dialog.DrawDialogBox(); * yield return StartCoroutine(dialog.DrawText("What?")); * while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) * { * yield return null; * } * yield return StartCoroutine(dialog.DrawText("\n" + selectedPokemon.GetName() + " is evolving!")); * while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) * { * yield return null; * } * * dialog.UndrawDialogBox(); * evolving = true; * * AudioClip cry = selectedPokemon.GetCry(); * SfxHandler.Play(cry); * yield return new WaitForSeconds(cry.length); * * BgmHandler.main.PlayOverlay(evolutionBGM, 753100); * yield return new WaitForSeconds(0.4f); * * c_animateEvolution = StartCoroutine(animateEvolution()); * SfxHandler.Play(evolvingClip); * * yield return new WaitForSeconds(0.4f); * * while (evolving) * { * if (Input.GetButtonDown("Back")) * { * evolving = false; * * //fadeTime = sceneTransition.FadeOut(); * //yield return new WaitForSeconds(fadeTime); * yield return StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed)); * * stopAnimateEvolution(); * * //fadeTime = sceneTransition.FadeIn(); * //yield return new WaitForSeconds(fadeTime); * yield return StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed)); * * * dialog.DrawDialogBox(); * yield return StartCoroutine(dialog.DrawText("Huh?")); * while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) * { * yield return null; * } * yield return StartCoroutine(dialog.DrawText("\n" + selectedPokemon.GetName() + " stopped evolving.")); * while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) * { * yield return null; * } * dialog.UndrawDialogBox(); * } * * yield return null; * } * * if (evolved) * { * selectedPokemon.evolve(evolutionMethod); * * yield return new WaitForSeconds(3.2f); * * cry = selectedPokemon.GetCry(); * BgmHandler.main.PlayMFX(cry); * yield return new WaitForSeconds(cry.length); * AudioClip evoMFX = Resources.Load<AudioClip>("Audio/mfx/GetGreat"); * BgmHandler.main.PlayMFXConsecutive(evoMFX); * * dialog.DrawDialogBox(); * yield return StartCoroutine(dialog.DrawTextSilent("Congratulations!")); * yield return new WaitForSeconds(0.8f); * StartCoroutine( * dialog.DrawTextSilent("\nYour " + selectedPokemonName + " evolved into " + * PokemonDatabase.Instance.GetPokemonSpeciesByGameId(evolutionID).getName() + "!")); * * //wait for MFX to stop * float extraTime = (evoMFX.length - 0.8f > 0) ? evoMFX.length - 0.8f : 0; * yield return new WaitForSeconds(extraTime); * * while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) * { * yield return null; * } * * string newMove = selectedPokemon.MoveLearnedAtLevel(selectedPokemon.getLevel()); * if (!string.IsNullOrEmpty(newMove) && !selectedPokemon.HasMove(newMove)) * { * yield return StartCoroutine(LearnMove(selectedPokemon, newMove)); * } * * dialog.UndrawDialogBox(); * bool running = true; * while (running) * { * if (Input.GetButtonDown("Select") || Input.GetButtonDown("Back")) * { * running = false; * } * * yield return null; * } * * yield return new WaitForSeconds(0.4f); * } * * StartCoroutine(ScreenFade.main.Fade(false, 1f)); * BgmHandler.main.ResumeMain(1.2f); * yield return new WaitForSeconds(1.2f); * * this.gameObject.SetActive(false); * //*/ }
private void updateFrames() { for (int i = 0; i < 6; i++) { OwnedPokemon selectedPokemon = SaveData.currentSave.PC.boxes[0][i]; if (selectedPokemon != null) { if (i == swapPosition) { if (i == 0) { if (i == currentPosition) { slot[i].texture = panelRoundSwapSel; } else { slot[i].texture = panelRoundSwap; } } else { if (i == currentPosition) { slot[i].texture = panelRectSwapSel; } else { slot[i].texture = panelRectSwap; } } } else { if (selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) == 0) { if (i == 0) { if (i == currentPosition) { if (switching) { slot[i].texture = panelRoundSwapSel; } else { slot[i].texture = panelRoundFaintSel; } } else { slot[i].texture = panelRoundFaint; } } else { if (i == currentPosition) { if (switching) { slot[i].texture = panelRectSwapSel; } else { slot[i].texture = panelRectFaintSel; } } else { slot[i].texture = panelRectFaint; } } } else { if (i == 0) { if (i == currentPosition) { if (switching) { slot[i].texture = panelRoundSwapSel; } else { slot[i].texture = panelRoundSel; } } else { slot[i].texture = panelRound; } } else { if (i == currentPosition) { if (switching) { slot[i].texture = panelRectSwapSel; } else { slot[i].texture = panelRectSel; } } else { slot[i].texture = panelRect; } } } } if (i == currentPosition) { selectBall[i].texture = selectBallOpen; } else { selectBall[i].texture = selectBallClosed; } } } if (currentPosition == 6) { cancel.texture = cancelHighlightTex; } else { cancel.texture = cancelTex; } }
private IEnumerator LearnMove(OwnedPokemon selectedPokemon, PokemonMove pMoveToLearn) { int chosenIndex = 1; if (chosenIndex == 1) { bool learning = true; while (learning) { //Moveset is full if (selectedPokemon.GetMoveCount() == 4) { dialog.DrawDialogBox(); yield return (StartCoroutine( dialog.DrawText(selectedPokemon.GetName() + " wants to learn the \nmove " + pMoveToLearn.Name + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); yield return (StartCoroutine( dialog.DrawText("However, " + selectedPokemon.GetName() + " already \nknows four moves."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); yield return (StartCoroutine(dialog.DrawText("Should a move be deleted and \nreplaced with " + pMoveToLearn.Name + "?"))); yield return(StartCoroutine(dialog.DrawChoiceBox())); chosenIndex = dialog.chosenIndex; dialog.UndrawChoiceBox(); if (chosenIndex == 1) { dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText("Which move should \nbe forgotten?"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } yield return(StartCoroutine(ScreenFade.main.Fade(false, ScreenFade.defaultSpeed))); //Set SceneSummary to be active so that it appears PKUScene.main.Summary.gameObject.SetActive(true); StartCoroutine(PKUScene.main.Summary.control(selectedPokemon, pMoveToLearn.Name)); //Start an empty loop that will only stop when SceneSummary is no longer active (is closed) while (PKUScene.main.Summary.gameObject.activeSelf) { yield return(null); } string replacedMove = PKUScene.main.Summary.replacedMove; yield return(StartCoroutine(ScreenFade.main.Fade(true, ScreenFade.defaultSpeed))); if (!string.IsNullOrEmpty(replacedMove)) { dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawTextSilent("1, "))); yield return(new WaitForSeconds(0.4f)); yield return(StartCoroutine(dialog.DrawTextSilent("2, "))); yield return(new WaitForSeconds(0.4f)); yield return(StartCoroutine(dialog.DrawTextSilent("and... "))); yield return(new WaitForSeconds(0.4f)); yield return(StartCoroutine(dialog.DrawTextSilent("... "))); yield return(new WaitForSeconds(0.4f)); yield return(StartCoroutine(dialog.DrawTextSilent("... "))); yield return(new WaitForSeconds(0.4f)); SfxHandler.Play(forgetMoveClip); yield return(StartCoroutine(dialog.DrawTextSilent("Poof!"))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); yield return (StartCoroutine( dialog.DrawText(selectedPokemon.GetName() + " forgot how to \nuse " + replacedMove + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText("And..."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.DrawDialogBox(); AudioClip mfx = Resources.Load <AudioClip>("Audio/mfx/GetAverage"); BgmHandler.main.PlayMFX(mfx); StartCoroutine(dialog.DrawTextSilent(selectedPokemon.GetName() + " learned \n" + pMoveToLearn.Name + "!")); yield return(new WaitForSeconds(mfx.length)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.UndrawDialogBox(); learning = false; } else { //give up? chosenIndex = 0; } } if (chosenIndex == 0) { //NOT ELSE because this may need to run after (chosenIndex == 1) runs dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText("Give up on learning the move \n" + pMoveToLearn.Name + "?"))); yield return(StartCoroutine(dialog.DrawChoiceBox())); chosenIndex = dialog.chosenIndex; dialog.UndrawChoiceBox(); if (chosenIndex == 1) { learning = false; chosenIndex = 0; } } } //Moveset is not full, can fit the new move easily else { selectedPokemon.TryAddMove(pMoveToLearn); dialog.DrawDialogBox(); AudioClip mfx = Resources.Load <AudioClip>("Audio/mfx/GetAverage"); BgmHandler.main.PlayMFX(mfx); StartCoroutine(dialog.DrawTextSilent(selectedPokemon.GetName() + " learned \n" + pMoveToLearn + "!")); yield return(new WaitForSeconds(mfx.length)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } dialog.UndrawDialogBox(); learning = false; } } } if (chosenIndex == 0) { //NOT ELSE because this may need to run after (chosenIndex == 1) runs //cancel learning loop dialog.DrawDialogBox(); yield return(StartCoroutine(dialog.DrawText(selectedPokemon.GetName() + " did not learn \n" + pMoveToLearn + "."))); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } } }
private void updateParty() { for (int i = 0; i < 6; i++) { OwnedPokemon selectedPokemon = SaveData.currentSave.PC.boxes[0][i]; if (selectedPokemon == null) { slot[i].gameObject.SetActive(false); } else { slot[i].gameObject.SetActive(true); selectBall[i].texture = selectBallClosed; icon[i].texture = selectedPokemon.GetIcons(); pokemonName[i].text = selectedPokemon.GetName(); pokemonNameShadow[i].text = pokemonName[i].text; if (selectedPokemon.Gender == PokemonGender.FEMALE) { gender[i].text = "♀"; gender[i].color = new Color(1, 0.2f, 0.2f, 1); } else if (selectedPokemon.Gender == PokemonGender.MALE) { gender[i].text = "♂"; gender[i].color = new Color(0.2f, 0.4f, 1, 1); } else { gender[i].text = null; } genderShadow[i].text = gender[i].text; HPBar[i].pixelInset = new Rect(HPBar[i].pixelInset.x, HPBar[i].pixelInset.y, Mathf.FloorToInt(48f * ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) / (float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP))), HPBar[i].pixelInset.height); if ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) < ((float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP) / 4f)) { HPBar[i].color = new Color(1, 0.125f, 0, 1); } else if ((float)selectedPokemon.GetCurrentStatValue(PokemonStatType.HP) < ((float)selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP) / 2f)) { HPBar[i].color = new Color(1, 0.75f, 0, 1); } else { HPBar[i].color = new Color(0.125f, 1, 0.065f, 1); } level[i].text = "" + selectedPokemon.CurrentLevel; levelShadow[i].text = level[i].text; currentHP[i].text = "" + selectedPokemon.GetCurrentStatValue(PokemonStatType.HP); currentHPShadow[i].text = currentHP[i].text; maxHp[i].text = "" + selectedPokemon.GetCurrentLevelStatValue(PokemonStatType.HP); maxHPShadow[i].text = maxHp[i].text; if (selectedPokemon.CurrentStatus != PokemonStatus.NONE) { status[i].texture = Resources.Load <Texture>("PCSprites/status" + selectedPokemon.CurrentStatus.ToString()); } else { status[i].texture = null; } if (!string.IsNullOrEmpty(selectedPokemon.getHeldItem())) { item[i].enabled = true; } else { item[i].enabled = false; } } } }
public IEnumerator interact() { OwnedPokemon targetPokemon = SaveData.currentSave.PC.getFirstFieldEffectUserInParty(fieldEffect); if (targetPokemon != null) { if (PlayerMovement.player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", interactText)); /* //This inactive code is used to print a third line of text. * while(!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")){ //these 3 lines stop the next bit from running until space is pressed. * yield return null; * } * Dialog.StartCoroutine("scrollText"); * yield return Dialog.StartCoroutine("drawText", "\\That'd be neat."); */ Dialog.drawChoiceBox(); //You CAN NOT get a value from a Coroutine. As a result, the coroutine runs and resets a public int in it's own script. yield return(Dialog.StartCoroutine(Dialog.choiceNavigate())); //it then assigns a value to that int Dialog.undrawChoiceBox(); if (Dialog.chosenIndex == 1) { //check that int's value Dialog.drawDialogBox(); yield return (Dialog.StartCoroutine("drawText", targetPokemon.GetName() + " used " + targetPokemon.getFirstFEInstance(fieldEffect) + "!")); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); yield return(new WaitForSeconds(0.5f)); //Run the animation and remove the tree objectLight.enabled = true; if (!breakSound.isPlaying && !breaking) { breakSound.volume = PlayerPrefs.GetFloat("sfxVolume"); breakSound.Play(); } myAnimator.SetBool("break", true); myAnimator.SetBool("rewind", false); breaking = true; yield return(new WaitForSeconds(1f)); } Dialog.undrawDialogBox(); yield return(new WaitForSeconds(0.2f)); PlayerMovement.player.unsetCheckBusyWith(this.gameObject); } } else { if (PlayerMovement.player.setCheckBusyWith(this.gameObject)) { Dialog.drawDialogBox(); //yield return StartCoroutine blocks the next code from running until coroutine is done. yield return(Dialog.StartCoroutine("drawText", examineText)); while (!Input.GetButtonDown("Select") && !Input.GetButtonDown("Back")) { yield return(null); } Dialog.undrawDialogBox(); yield return(new WaitForSeconds(0.2f)); PlayerMovement.player.unsetCheckBusyWith(this.gameObject); } } }