/// <summary> /// New Pokemon with: random IVS, Shininess, default moveset, and EVS (0) /// </summary> /// <param name="pPokemonID"></param> /// <param name="pGender"></param> /// <param name="pLevel"></param> /// <param name="pCaughtBall"></param> /// <param name="pHeldItem"></param> /// <param name="pOT"></param> /// <param name="pAbility"></param> public OwnedPokemon(string pPokemonID, PokemonGender pGender, int pLevel, string pCaughtBall, string pHeldItem, string pOT, int pAbility) : this(pPokemonID) { // Set status. CurrentStatus = PokemonStatus.NONE; // Set level and experience. CurrentLevel = pLevel; CurrentExperience = PokemonLevelingRateHelper.GetRequiredExperienceToTargetLevel(Species.LevelingRate, CurrentLevel); // Set friendship. CurrentFriendship = Species.BaseFriendship; // Set gender. generateGender(pGender); // Set rare value. generateRareValue(); // Set met data. generateMetData(pLevel, pCaughtBall); // Set DO n°. generateDONumber(); // Set IVs and EVs. generateIVsAndEVs(); // Set nature. Nature = PokemonNatureHelper.GetRandomNature(); // Set ability. generateAbility(); // ToDo: Set default move set as 4 highest level learnable moves //Set moveset based off of the highest level moves possible. //_currentMoveset = thisPokemonData.GenerateMoveset(_currentLevel); _moveHistory = _currentMoveset; //set maxPP and PP to be the regular PP defined by the move in the database. PPups = new int[4]; maxPP = new int[4]; PP = new int[4]; for (int i = 0; i < 4; i++) { if (!string.IsNullOrEmpty(_currentMoveset[i])) { maxPP[i] = MoveDatabase.getMove(_currentMoveset[i]).getPP(); PP[i] = maxPP[i]; } } packMoveset(); }
/// <summary> /// Gets the stat's value according to the current level and nature. /// /// See http://bulbapedia.bulbagarden.net/wiki/Statistic for formula. /// </summary> /// <param name="pPokemonLevel"></param> /// <returns></returns> public int GetCurrentLevelValue(int pPokemonLevel, PokemonNature pNature) { if (BaseValue == 1) { return(1); } int currentValue = 1; switch (Type) { case PokemonStatType.HP: case PokemonStatType.Attack: case PokemonStatType.Defence: case PokemonStatType.SpecialAttack: case PokemonStatType.SpecialDefence: case PokemonStatType.Speed: currentValue = Mathf.CeilToInt(Mathf.Sqrt(EV)); currentValue = Mathf.FloorToInt(currentValue * 0.25f); currentValue += (BaseValue + IV) * 2; currentValue *= pPokemonLevel; currentValue = Mathf.FloorToInt(currentValue * 0.1f); currentValue += 5; if (Type == PokemonStatType.HP) { currentValue += pPokemonLevel + 5; } else { currentValue = Mathf.FloorToInt(currentValue * PokemonNatureHelper.GetStatFactorFromNature(Type, pNature)); } break; case PokemonStatType.Evasion: case PokemonStatType.Accuracy: // Should be 100. currentValue = BaseValue; break; } if (currentValue < 1) { currentValue = 1; } return(currentValue); }
private void UpdateUnfoldedEventData(SerializedProperty currentSEvent) { SetEventProps(currentSEvent); /* Draw a line */ GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) }); EditorGUILayout.PropertyField(eventType_Prop); EditorGUILayout.Space(); CustomEventDetails.CustomEventType ty = (CustomEventDetails.CustomEventType)eventType_Prop.enumValueIndex; switch (ty) { case CustomEventDetails.CustomEventType.Dialog: strings_Prop.arraySize = EditorGUILayout.IntField(new GUIContent("Lines"), strings_Prop.arraySize); EditorGUILayout.Space(); for (int i = 0; i < strings_Prop.arraySize; i++) { strings_Prop.GetArrayElementAtIndex(i).stringValue = EditorGUILayout.TextField(new GUIContent("Dialog " + (i + 1)), strings_Prop.GetArrayElementAtIndex(i).stringValue); } break; case CustomEventDetails.CustomEventType.Choice: strings_Prop.arraySize = EditorGUILayout.IntField(new GUIContent("Choices"), strings_Prop.arraySize); ints_Prop.arraySize = strings_Prop.arraySize; EditorGUILayout.Space(); for (int i = 0; i < strings_Prop.arraySize; i++) { strings_Prop.GetArrayElementAtIndex(i).stringValue = EditorGUILayout.TextField(new GUIContent("Choice " + (i + 1)), strings_Prop.GetArrayElementAtIndex(i).stringValue); ints_Prop.GetArrayElementAtIndex(i).intValue = EditorGUILayout.IntField(new GUIContent("Jump to Tree:"), ints_Prop.GetArrayElementAtIndex(i).intValue); } break; case CustomEventDetails.CustomEventType.Walk: EditorGUILayout.PropertyField(runSimul_Prop, new GUIContent("Run Simultaneously")); EditorGUILayout.Space(); EditorGUILayout.PropertyField(object0_Prop, new GUIContent("Character")); EditorGUILayout.PropertyField(dir_Prop, new GUIContent("Direction")); EditorGUILayout.PropertyField(int0_Prop, new GUIContent("Steps")); EditorGUILayout.PropertyField(bool0_Prop, new GUIContent("Lock Direction")); EditorGUILayout.PropertyField(float0_Prop, new GUIContent("Speed Multiplier")); break; case CustomEventDetails.CustomEventType.TurnTo: EditorGUILayout.PropertyField(object0_Prop, new GUIContent("Character")); EditorGUILayout.PropertyField(object1_Prop, new GUIContent("Turn Towards")); int0_Prop.intValue = EditorGUILayout.IntField(new GUIContent("Direction Mod"), int0_Prop.intValue); break; case CustomEventDetails.CustomEventType.Wait: EditorGUILayout.PropertyField(float0_Prop, new GUIContent("Seconds")); break; case CustomEventDetails.CustomEventType.LogicCheck: CustomEventDetails.Logic lo = (CustomEventDetails.Logic)logic_Prop.enumValueIndex; //Boolean Logic Checks if (lo == CustomEventDetails.Logic.SpaceInParty) { EditorGUILayout.PropertyField(bool0_Prop, new GUIContent("NOT")); } else { EditorGUILayout.PropertyField(float0_Prop, new GUIContent("Check Value:")); } EditorGUILayout.PropertyField(logic_Prop, new GUIContent("Computation")); //CVariable Logic Checks if (lo == CustomEventDetails.Logic.CVariableEquals || lo == CustomEventDetails.Logic.CVariableGreaterThan || lo == CustomEventDetails.Logic.CVariableLessThan) { EditorGUILayout.PropertyField(string0_Prop, new GUIContent("C Variable")); } EditorGUILayout.Space(); EditorGUILayout.PropertyField(int0_Prop, new GUIContent("Jump to Tree:")); break; case CustomEventDetails.CustomEventType.SetCVariable: EditorGUILayout.PropertyField(string0_Prop, new GUIContent("Set Variable:")); EditorGUILayout.PropertyField(float0_Prop, new GUIContent("To Value:")); break; case CustomEventDetails.CustomEventType.Sound: EditorGUILayout.PropertyField(sound_Prop, new GUIContent("Sound")); break; case CustomEventDetails.CustomEventType.SetActive: EditorGUILayout.PropertyField(object0_Prop, new GUIContent("Game Object")); EditorGUILayout.PropertyField(bool0_Prop, new GUIContent("Set Active")); break; case CustomEventDetails.CustomEventType.ReceiveItem: EditorGUILayout.PropertyField(bool0_Prop, new GUIContent("Is TM")); string0_Prop.stringValue = EditorGUILayout.TextField(new GUIContent("Item"), string0_Prop.stringValue); if (!bool0_Prop.boolValue) { int0_Prop.intValue = EditorGUILayout.IntField(new GUIContent("Quantity"), int0_Prop.intValue); } break; case CustomEventDetails.CustomEventType.ReceivePokemon: ints_Prop.arraySize = 11; strings_Prop.arraySize = 8; int0_Prop.intValue = EditorGUILayout.IntField(new GUIContent("Jump To on Fail"), int0_Prop.intValue); EditorGUILayout.Space(); ints_Prop.GetArrayElementAtIndex(0).intValue = EditorGUILayout.IntField(new GUIContent("Pokemon ID"), ints_Prop.GetArrayElementAtIndex(0).intValue); // ToDO: change ints_Prop. var pkmn = GameController.Instance.PokemonDb.GetPokemonSpeciesByGameId(ints_Prop.GetArrayElementAtIndex(0).intValue.ToString()); string pokemonName = (pkmn != null) ? pkmn.Name : "null"; EditorGUILayout.LabelField(new GUIContent(" "), new GUIContent(pokemonName)); EditorGUILayout.Space(); strings_Prop.GetArrayElementAtIndex(0).stringValue = EditorGUILayout.TextField(new GUIContent("Nickname"), strings_Prop.GetArrayElementAtIndex(0).stringValue); ints_Prop.GetArrayElementAtIndex(1).intValue = EditorGUILayout.IntSlider(new GUIContent("Level"), ints_Prop.GetArrayElementAtIndex(1).intValue, 1, 100); //Gender if (pkmn != null) { if (pkmn.MaleRatio < 0) { EditorGUILayout.LabelField(new GUIContent("Gender"), new GUIContent("Genderless")); } else if (pkmn.MaleRatio == 0) { EditorGUILayout.LabelField(new GUIContent("Gender"), new GUIContent("Female")); } else if (pkmn.MaleRatio == 100) { EditorGUILayout.LabelField(new GUIContent("Gender"), new GUIContent("Male")); } else { //if not a set gender ints_Prop.GetArrayElementAtIndex(2).intValue = EditorGUILayout.Popup(new GUIContent("Gender"), ints_Prop.GetArrayElementAtIndex(2).intValue, new GUIContent[] { new GUIContent("Male"), new GUIContent("Female"), new GUIContent("Calculate") }); } } else { EditorGUILayout.LabelField(new GUIContent("Gender")); } EditorGUILayout.PropertyField(bool0_Prop, new GUIContent("Is Shiny")); var stringsArrayElementAt1 = strings_Prop.GetArrayElementAtIndex(1); stringsArrayElementAt1.stringValue = EditorGUILayout.TextField(new GUIContent("Original Trainer"), stringsArrayElementAt1.stringValue); var stringsArrayElementAt2 = strings_Prop.GetArrayElementAtIndex(2); stringsArrayElementAt2.stringValue = EditorGUILayout.TextField(new GUIContent("Poké Ball"), stringsArrayElementAt2.stringValue); var stringsArrayElementAt3 = strings_Prop.GetArrayElementAtIndex(3); stringsArrayElementAt3.stringValue = EditorGUILayout.TextField(new GUIContent("Held Item"), stringsArrayElementAt3.stringValue); //Nature string[] natureNames = PokemonNatureHelper.GetAllNatureNames(); GUIContent[] natures = new GUIContent[natureNames.Length + 1]; natures[0] = new GUIContent("Random"); for (int i = 0, iMax = natures.Length - 1; i != iMax; ++i) { string text = string.Format("{0}{1}\t | {2}+ | {3}-", natureNames[i][0], natureNames[i].Substring(1, natureNames[i].Length - 1).ToLower(), PokemonNatureHelper.GetUpgradedStat(i), PokemonNatureHelper.GetDowngradedStat(i)); natures[i + 1] = new GUIContent(text); } var intsArrayElementAt3 = ints_Prop.GetArrayElementAtIndex(3); intsArrayElementAt3.intValue = EditorGUILayout.Popup( new GUIContent("Nature"), ints_Prop.GetArrayElementAtIndex(3).intValue, natures); //Ability //if (pkmn != null) //{ // var intsArrayElementAt4 = ints_Prop.GetArrayElementAtIndex(4); // intsArrayElementAt4.intValue = EditorGUILayout.Popup(new GUIContent("Ability"), // intsArrayElementAt4.intValue, new GUIContent[] // { // new GUIContent("1: " + pkmn.getAbility(0)), new GUIContent("2: " + pkd.getAbility(1)), // new GUIContent("(HA) " + pkmn.getAbility(2)) // }); //} //else //{ // EditorGUILayout.LabelField(new GUIContent("Ability")); //} EditorGUILayout.Space(); EditorGUILayout.LabelField(new GUIContent("Custom Moveset"), new GUIContent("(Blanks will be default)")); EditorGUILayout.BeginHorizontal(); strings_Prop.GetArrayElementAtIndex(4).stringValue = EditorGUILayout.TextField(strings_Prop.GetArrayElementAtIndex(4).stringValue); strings_Prop.GetArrayElementAtIndex(5).stringValue = EditorGUILayout.TextField(strings_Prop.GetArrayElementAtIndex(5).stringValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); strings_Prop.GetArrayElementAtIndex(6).stringValue = EditorGUILayout.TextField(strings_Prop.GetArrayElementAtIndex(6).stringValue); strings_Prop.GetArrayElementAtIndex(7).stringValue = EditorGUILayout.TextField(strings_Prop.GetArrayElementAtIndex(7).stringValue); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); string IVstring = (bool1_Prop.boolValue) ? "Using Custom IVs" : "Using Random IVs"; bool1_Prop.boolValue = EditorGUILayout.Foldout(bool1_Prop.boolValue, new GUIContent(IVstring)); if (bool1_Prop.boolValue) { ints_Prop.GetArrayElementAtIndex(5).intValue = EditorGUILayout.IntSlider(new GUIContent("HP"), ints_Prop.GetArrayElementAtIndex(5).intValue, 0, 31); ints_Prop.GetArrayElementAtIndex(6).intValue = EditorGUILayout.IntSlider(new GUIContent("ATK"), ints_Prop.GetArrayElementAtIndex(6).intValue, 0, 31); ints_Prop.GetArrayElementAtIndex(7).intValue = EditorGUILayout.IntSlider(new GUIContent("DEF"), ints_Prop.GetArrayElementAtIndex(7).intValue, 0, 31); ints_Prop.GetArrayElementAtIndex(8).intValue = EditorGUILayout.IntSlider(new GUIContent("SPA"), ints_Prop.GetArrayElementAtIndex(8).intValue, 0, 31); ints_Prop.GetArrayElementAtIndex(9).intValue = EditorGUILayout.IntSlider(new GUIContent("SPD"), ints_Prop.GetArrayElementAtIndex(9).intValue, 0, 31); ints_Prop.GetArrayElementAtIndex(10).intValue = EditorGUILayout.IntSlider(new GUIContent("SPE"), ints_Prop.GetArrayElementAtIndex(10).intValue, 0, 31); } break; case CustomEventDetails.CustomEventType.TrainerBattle: EditorGUILayout.PropertyField(object0_Prop, new GUIContent("Trainer Script")); EditorGUILayout.PropertyField(bool0_Prop, new GUIContent("Loss Allowed?")); if (bool0_Prop.boolValue) { int0_Prop.intValue = EditorGUILayout.IntField(new GUIContent("Jump To on Loss"), int0_Prop.intValue); } break; } /* Draw a line */ GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) }); EditorGUILayout.Space(); }
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); }