Ejemplo n.º 1
0
        private void buttonBuy_Click(object sender, EventArgs e)
        {
            bool newItem = true;
            int j = 0;

            if (lastListBox == listBoxPokeballs)
            {
                Pokeball aux = new Pokeball(lastListBox.SelectedIndex + 1);

                if (FormGame.player.money >= aux.price)
                    FormGame.player.money -= aux.price;
                else return;

                List<Pokeball> tmp = FormGame.player.pokeballs;
                for (int i = 0; i < tmp.Count; ++i)
                    if (tmp[i].type == lastListBox.SelectedIndex + 1)
                    {
                        j = i;
                        newItem = false;
                        break;
                    }

                if (newItem)
                {
                    tmp.Add(new Pokeball(lastListBox.SelectedIndex + 1));
                    tmp[tmp.Count - 1].number = 1;
                }
                else tmp[j].number += 1;
            }
            if(lastListBox == listBoxPotions)
            {
                Potion aux = new Potion(lastListBox.SelectedIndex + 1);

                if (FormGame.player.money >= aux.price)
                    FormGame.player.money -= aux.price;
                else return;

                List<Potion> tmp = FormGame.player.potions;
                for (int i = 0; i < tmp.Count; ++i)
                    if (tmp[i].type == lastListBox.SelectedIndex + 1)
                    {
                        j = i;
                        newItem = false;
                        break;
                    }

                if (newItem)
                {
                    tmp.Add(new Potion(lastListBox.SelectedIndex + 1));
                    tmp[tmp.Count - 1].number = 1;
                }
                else tmp[j].number += 1;
            }

            ChangeMoney();
        }
        public FormPokemons(Potion pot)
        {
            if (lastForm != null) lastForm.Close();
            lastForm = this;

            potion = pot;

            InitializeComponent();
            Initialize();
        }
Ejemplo n.º 3
0
        public void NewGame()
        {
            string path = @"C:\Users\Erdem\source\repos\Pokemon\Pokemon\pokemonDB.csv";

            x.RetrievePokemons(path, Program.pokemons);
            Console.WriteLine("Please, enter your trainer's name: ");
            trainer.Name = Console.ReadLine();

            Potion   potion   = new Potion();
            Pokeball pokeball = new Pokeball();

            for (int i = 0; i < 3; i++)
            {
                trainer.Bag.addPotion(potion);
                trainer.Bag.addPokeball(pokeball);
            }

            Console.WriteLine("Please, choose a Pokemon (1 - Bulbasaur, 2 - Charmander, 3 - Squirtle): ");
            int index = int.Parse(Console.ReadLine()) - 1;

            trainer.Bag.addPokemon(Program.pokemons[index], index);
            Console.WriteLine("You've caught a " + trainer.Bag.Pokemons[0].Name + "!");
            trainer.Journey();
        }
Ejemplo n.º 4
0
        public static void Shop()
        {
            while (true)
            {
                Console.WriteLine($"\nYou've got {Game.trainer.Gold}G!");
                Console.WriteLine("\nWhat do you wanna buy?");
                Console.WriteLine("1 - Potions");
                Console.WriteLine("2 - Pokeballs");
                Console.WriteLine("3 - PC");
                Console.WriteLine("4 - Go back to the PokeCenter");

                string choice = Console.ReadLine();
                if (choice.Equals("1"))
                {
                    Console.WriteLine("\nBuy 1 Potion for 25G? (1 - Yes, 2 - Cancel)");
                    if (Console.ReadLine().Equals("1"))
                    {
                        if (Game.trainer.Gold >= 25)
                        {
                            Game.trainer.Gold -= 25;
                            Potion potion = new Potion();
                            Game.trainer.Bag.addPotion(potion);
                        }
                        else
                        {
                            Console.WriteLine("You don't have enough gold!");
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                else if (choice.Equals("2"))
                {
                    Console.WriteLine("\nBuy 1 Pokeball for 25G? (1 - Yes, 2 - Cancel)");
                    if (Console.ReadLine().Equals("1"))
                    {
                        if (Game.trainer.Gold >= 25)
                        {
                            Game.trainer.Gold -= 25;
                            Pokeball pokeball = new Pokeball();
                            Game.trainer.Bag.addPokeball(pokeball);
                        }
                        else
                        {
                            Console.WriteLine("You don't have enough gold!");
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                else if (choice.Equals("3"))
                {
                    Console.WriteLine("\nChoose the pokemon that you would like to get: ");
                    Console.WriteLine("____________________________________________");
                    for (int i = 0; i < StoredPokemons.Count; i++)
                    {
                        Console.WriteLine($"{i + 1} - {StoredPokemons[i].Name}");
                    }
                    int change1 = int.Parse(Console.ReadLine()) - 1;
                    Console.WriteLine("\nChoose the Pokemon that you would like to change: ");
                    Console.WriteLine("_____________________________________________");
                    for (int i = 0; i < Game.trainer.Bag.Pokemons.Count; i++)
                    {
                        Console.WriteLine($"{i + 1} - {Game.trainer.Bag.Pokemons[i].Name}");
                    }
                    int change2 = int.Parse(Console.ReadLine()) - 1;
                    StoredPokemons.Add(Game.trainer.Bag.Pokemons[change2]);
                    Game.trainer.Bag.Pokemons.RemoveAt(change2);
                    Game.trainer.Bag.Pokemons.Add(StoredPokemons[change1]);
                    StoredPokemons.RemoveAt(change1);
                }
                else
                {
                    break;
                }
            }
            Enter();
        }
        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();
            }
        }
Ejemplo n.º 6
0
        private void listBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            ListBox lb = (ListBox)sender;
            if (lb.SelectedIndex > lb.Items.Count || lb.SelectedIndex < 0) return;

            if (lb == listBoxPokeballs)
            {
                listBoxPotions.ClearSelected();
                listBoxOthers.ClearSelected();

                Pokeball tmp = new Pokeball(lb.SelectedIndex + 1);
                tbDescription.Text = tmp.description;
            }
            if (lb == listBoxPotions)
            {
                listBoxPokeballs.ClearSelected();
                listBoxOthers.ClearSelected();

                Potion tmp = new Potion(lb.SelectedIndex + 1);
                tbDescription.Text = tmp.description;
            }

            lastListBox = lb;
        }
Ejemplo n.º 7
0
        public void UsePotion(Potion pot)
        {
            if (player.pokemons[crtPokemon].canUseItems)
            {
                // Heal Block
                if (pot.heal > 0 && player.pokemons[crtPokemon].HealBlock > 0) return;

                pot.UsePotion(player.pokemons[crtPokemon]);

                ChangeMoves();

                battleScreen.Invalidate();

                // AI Turn
                justChangeCrtPokemon = true;
                AI_Turn();
            }
            else
            {
                tbHistory.Text = "You can not use items on " + player.pokemons[crtPokemon].name + "!\n" + tbHistory.Text;
            }
        }