private void timerLoading_Tick(object sender, EventArgs e)
        {
            points = (points + 1) % 4;
            labelLoading.Text = "Loading";
            for (int i = 1; i <= points; ++i) labelLoading.Text += ".";

            if (Resources.resourcesDone)
            {
                timerLoading.Stop();

                applicationIsRunning = true;

                if(newGame) new FormCharacterCreation().Show();
                else
                {
                    StreamReader sr = new StreamReader(Application.StartupPath + "\\game.sav");

                    string line;
                    string[] words;

                    line = sr.ReadLine();
                    words = line.Split();

                    Character player = new Character(words[0]);
                    player.money = Convert.ToInt32(words[1]);
                    player.badges = Convert.ToInt32(words[2]);
                    player.healingcenter = Convert.ToInt32(words[3]);
                    player.food = Convert.ToInt32(words[4]);

                    line = sr.ReadLine();
                    words = line.Split();
                    int pokeCount = Convert.ToInt32(words[0]);
                    for(int i=0;i<pokeCount;++i)
                    {
                        line = sr.ReadLine();
                        words = line.Split();
                        Pokemons pokemon = new Pokemons(Convert.ToInt32(words[0]), 1);
                        pokemon.level = Convert.ToInt32(words[1]);

                        pokemon.gender = Convert.ToInt32(words[2]);
                        pokemon.name = words[3] + "";
                        pokemon.lovebase = (float)Convert.ToDouble(words[4]);
                        pokemon.EarnLove((float)Convert.ToDouble(words[5]), (float)Convert.ToDouble(words[6]), (float)Convert.ToDouble(words[7]));

                        pokemon.hp = (float)Convert.ToDouble(words[8]);
                        pokemon.hpmax = (float)Convert.ToDouble(words[9]);
                        pokemon.atk = (float)Convert.ToDouble(words[10]);
                        pokemon.def = (float)Convert.ToDouble(words[11]);
                        pokemon.spatk = (float)Convert.ToDouble(words[12]);
                        pokemon.spdef = (float)Convert.ToDouble(words[13]);
                        pokemon.speed = (float)Convert.ToDouble(words[14]);

                        pokemon.xp = Convert.ToInt32(words[15]);

                        line = sr.ReadLine();
                        words = line.Split();
                        pokemon.moves = new List<Attack>();
                        int moveCount = Convert.ToInt32(words[0]);
                        for (int j = 0; j < moveCount; ++j)
                        {
                            Attack move = new Attack(Convert.ToInt32(words[1 + j * 2]));
                            move.PP = Convert.ToInt32(words[2 + j * 2]);
                            pokemon.LearnMove(move);
                        }

                        player.AddPokemon(pokemon);
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int pokeLabCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < pokeLabCount; ++i)
                    {
                        line = sr.ReadLine();
                        words = line.Split();
                        Pokemons pokemon = new Pokemons(Convert.ToInt32(words[0]), 1);
                        pokemon.level = Convert.ToInt32(words[1]);

                        pokemon.gender = Convert.ToInt32(words[2]);
                        pokemon.name = words[3] + "";
                        pokemon.lovebase = (float)Convert.ToDouble(words[4]);
                        pokemon.EarnLove((float)Convert.ToDouble(words[5]), (float)Convert.ToDouble(words[6]), (float)Convert.ToDouble(words[7]));

                        pokemon.hp = (float)Convert.ToDouble(words[8]);
                        pokemon.hpmax = (float)Convert.ToDouble(words[9]);
                        pokemon.atk = (float)Convert.ToDouble(words[10]);
                        pokemon.def = (float)Convert.ToDouble(words[11]);
                        pokemon.spatk = (float)Convert.ToDouble(words[12]);
                        pokemon.spdef = (float)Convert.ToDouble(words[13]);
                        pokemon.speed = (float)Convert.ToDouble(words[14]);

                        pokemon.xp = Convert.ToInt32(words[15]);

                        line = sr.ReadLine();
                        words = line.Split();
                        pokemon.moves = new List<Attack>();
                        int moveCount = Convert.ToInt32(words[0]);
                        for (int j = 0; j < moveCount; ++j)
                        {
                            Attack move = new Attack(Convert.ToInt32(words[1 + j * 2]));
                            move.PP = Convert.ToInt32(words[2 + j * 2]);
                            pokemon.LearnMove(move);
                        }

                        player.pokemonsLab.Add(pokemon);
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int pokeballCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < pokeballCount;++i )
                    {
                        Pokeball ball = new Pokeball(Convert.ToInt32(words[1 + i * 2]));
                        ball.number = Convert.ToInt32(words[2 + i * 2]);
                        player.pokeballs.Add(ball);
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int potionCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < potionCount; ++i)
                    {
                        Potion pot = new Potion(Convert.ToInt32(words[1 + i * 2]));
                        pot.number = Convert.ToInt32(words[2 + i * 2]);
                        player.potions.Add(pot);
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int TMCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < TMCount; ++i)
                    {
                        player.TMs.Add(new Attack(Convert.ToInt32(words[1 + i])));
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    int EvolutionItemsCount = Convert.ToInt32(words[0]);
                    for (int i = 0; i < EvolutionItemsCount; ++i)
                    {
                        player.evolutionItems.Add(new EvolutionItem(Convert.ToInt32(words[1 + i])));
                    }

                    FormGame formGame = new FormGame(player);

                    line = sr.ReadLine();
                    words = line.Split();
                    FormGame.map = new Map(Convert.ToInt32(words[0]), Convert.ToInt32(words[1]), Convert.ToInt32(words[2]));
                    FormGame.gameTime = Convert.ToInt32(words[3]);
                    Map.lastTimeGym = Convert.ToInt32(words[4]);

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 0; i < 200;++i )
                    {
                        if (Convert.ToInt32(words[i]) == 1) Map.trainerDefeated[i] = true;
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 1; i < 494; ++i)
                    {
                        if (Convert.ToInt32(words[i - 1]) == 1) Map.pokemonDefeated[i] = true;
                    }

                    line = sr.ReadLine();
                    words = line.Split();
                    FormPokedex.seen = Convert.ToInt32(words[0]);
                    FormPokedex.owned = Convert.ToInt32(words[1]);

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 1; i < 494; ++i)
                        if (Convert.ToInt32(words[i - 1]) == 1)
                            FormPokedex.inPokedex[i] = true;

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 1; i < 494; ++i)
                        if (Convert.ToInt32(words[i - 1]) == 1)
                            FormPokedex.ownedPokemon[i] = true;

                    line = sr.ReadLine();
                    words = line.Split();
                    for (int i = 1; i < 494; ++i)
                    {
                        string nameString = words[i - 1] + "";
                        if (nameString != "-")
                            FormPokedex.names[i] = nameString;
                    }

                    formGame.Show();

                    sr.Close();
                }

                this.Close();
            }
        }
        private void buttonStartGame_Click(object sender, EventArgs e)
        {
            if (selectedNr < 0)
            {
                labelError.Text = "Select a starter pokemon";
                labelError.Show();
                return;
            }

            if (tbName.Text == "")
            {
                labelError.Text = "Select a name for your trainer";
                labelError.Show();
                return;
            }

            string[] words = tbName.Text.Split();
            if(words[0] != tbName.Text)
            {
                labelError.Text = "Your name can not contain spaces";
                labelError.Show();
                return;
            }

            applicationIsRunning = true;

            Character player = new Character(tbName.Text);

            int pokeNr;

            switch (selectedNr)
            {
                case 0: pokeNr = 1; break;
                case 1: pokeNr = 4; break;
                case 2: pokeNr = 7; break;
                case 3: pokeNr = 152; break;
                case 4: pokeNr = 155; break;
                case 5: pokeNr = 158; break;
                case 6: pokeNr = 252; break;
                case 7: pokeNr = 255; break;
                case 8: pokeNr = 258; break;
                case 9: pokeNr = 387; break;
                case 10: pokeNr = 390; break;
                default: pokeNr = 393; break;
            }

            Pokemons pokemon = new Pokemons(pokeNr, 5);

            FormPokedex.SeePokemon(pokeNr);
            FormPokedex.OwnPokemon(pokeNr);

            // starting pokemon
            pokemon.lovebase = 50;
            pokemon.EarnLove(100, 20, 30);
            player.AddPokemon(pokemon);

            // starting items
            Pokeball pball = new Pokeball(1);
            pball.number = 5;
            player.pokeballs.Add(pball);

            // starting money
            player.money = 1000;

            // starting food
            player.food = 10;

            new FormGame(player).Show();

            this.Close();
        }
        private void YourPokemonDies(Pokemons poke)
        {
            poke.hp = 0;
            ChangeHealth();

            poke.EarnLove(-5, 0, 0);

            // remove from not fainted list
            notFaintedPokemons.Remove(poke);

            bool found = false;

            // check if another pokemon is still alive
            for (int i = 0; i < player.pokemons.Count; ++i)
                if (player.pokemons[i].hp > 0)
                {
                    found = true;
                    firstChangeCrtPokemon = true;
                    ChangeCrtPokemon(i);
                    break;
                }

            // you lose
            if (!found)
            {
                waitTime = true;

                tbHistory.Text = "You lost the battle!\n" + tbHistory.Text;

                EndBattle(false);
            }
        }