I’m currently making a Pokémon clone for funsies
Now I went to declare pokemons, depedning on the pokedex number I set the name etc, now I want to set the Types, what is the best way to do this considering pokemon can have 1 or 2 types.
What I did(just want tips on how to improve):
my pokemon class:
using UnityEngine;
using System.Collections;
public class Pokemon {
/// <summary>
/// Name of the pokémon
/// </summary>
public string name = "";
/// <summary>
/// Nickname of the pokémon
/// </summary>
public string nickname = "";
/// <summary>
/// Pokédex entry number of the Pokémon
/// </summary>
public string pokedexEntry = "";
/// <summary>
/// Pokedex Number of the Pokémon
/// </summary>
public int pokedexNumber = 0;
/// <summary>
/// Nature of the Pokémon
/// </summary>
public int nature = 0;
/// <summary>
/// height of the pokemon (in centimeters)
/// </summary>
public float height = 0;
/// <summary>
/// Weight of the Pokémon in kilograms
/// </summary>
public float weight = 0;
/// <summary>
/// gender of the pokemon 0 = male, 1 = female.
/// </summary>
public int gender = 0;
/// <summary>
/// level of the pokemon
/// </summary>
public int level = 1;
/// <summary>
/// what item the pokmeon holds 0 = no item
/// </summary>
public int holdItem = 0;
/// <summary>
/// health stat of the pokemon
/// </summary>
public int hp = 1;
/// <summary>
/// static health stat of the pokemon
/// </summary>
public int statichp = 1;
/// <summary>
/// atk stat of the pokemon
/// </summary>
public int atk = 1;
/// <summary>
/// static atk stat of the pokemon
/// </summary>
public int staticatk = 1;
/// <summary>
/// def stat of the pokemon
/// </summary>
public int def = 1;
/// <summary>
/// static def stat of the pokemon
/// </summary>
public int staticdef = 1;
/// <summary>
/// special attack stat of the pokemon
/// </summary>
public int spatk = 1;
/// <summary>
/// static special attack stat of the pokemon
/// </summary>
public int staticspatk = 1;
/// <summary>
/// special defense stat of the pokemon
/// </summary>
public int spdef = 1;
/// <summary>
/// static special defense stat of the pokemon
/// </summary>
public int staticspdef = 1;
/// <summary>
/// speed stat of the pokemon
/// </summary>
public int speed = 1;
/// <summary>
/// static speed staf of the pokemon
/// </summary>
public int staticspeed = 1;
/// <summary>
/// evasiness of the pokmeon (abilijty to dodge)
/// </summary>
public int evasiness = 1;
/// <summary>
/// accuracy of the pokemon (ability to hit)
/// </summary>
public int accuracy = 1;
/// <summary>
/// Type of the pokemon
/// </summary>
public int type1 = 0;
/// <summary>
/// second type of the pokemon
/// </summary>
public int type2 = 0;
}
and for testing I have made this:
public Pokemon[] party = new Pokemon[5];
void Start()
{
audio = GetComponent<AudioSource>();
party[0] = new Pokemon();
party[0].level = 5;
party[0].nickname = "";
party[0].hp = 10;
party[0].pokedexNumber = 160;
party[0].name = Settings.pokemonNames[party[0].pokedexNumber];
}
The settings class has the following:
public static string[] pokemonNames =
{ "null",
"Bulbasaur",
"Ivysaur",
"Venusaur",
"Charmander",
etc…
Now do I do the same for the type or is there a way better way to create this type of thing?
My idea about the typing:
party[0].type1 = Settings.getType1(party[0].pokedexNumber);
party[0].type2 = Settings.getType2(party[0].pokedexNumber);
and where it gets it from:
public static int
EMPTY = 0,
NORMAL = 1, FIRE = 2, FIGHTING = 3, WATER = 4, FLYING = 5, GRASS = 6,
POISON = 7, ELECTRIC = 8, GROUND = 9, PSYCHIC = 10,
ROCK = 11, ICE = 12, BUG = 13, DRAGON = 14, GHOST = 15, DARK = 16, STEEL = 17, FAIRY = 18;
public static int getType1(int pokemon)
{
switch (pokemon)
{
case 0:
return NORMAL;
break;
case 1:
return GRASS;
break;
default:
return 0;
break;
}
}
public static int getType2(int pokemon)
{
switch (pokemon)
{
case 0:
return NORMAL;
break;
case 1:
return POISON;
break;
default:
return 0;
break;
}
}
Thanks for reading, looking forward to tips and tricks :)!