Exemplo n.º 1
0
 public static void Init(string file)
 {
     using (var reader = new StreamReader(file))
     {
         var firstline = reader.ReadLine();
         while (!reader.EndOfStream)
         {
             var         line   = reader.ReadLine();
             var         values = line.Split(',', (char)StringSplitOptions.None);
             PokemonType p1     = new PokemonType(int.Parse(values[1]), values[0], float.Parse(values[2]), float.Parse(values[3]), float.Parse(values[4]), float.Parse(values[5]), int.Parse(values[6]), int.Parse(values[7]), values[8], int.Parse(values[9]), values[10], int.Parse(values[11]), values[12], int.Parse(values[13]));
             if (p1.Rarity == 1)
             {
                 common.Add(p1);
             }
             else if (p1.Rarity == 2)
             {
                 rare.Add(p1);
             }
             else
             {
                 ultrarare.Add(p1);
             }
         }
     }
 }
Exemplo n.º 2
0
 public CaptureGame(PokemonType x)
 {
     pkm          = x;
     rand         = new Random();
     Acceleration = rand.Next(1, 31) / (double)10;
     Orgwidth     = rand.Next(350, 520);
     currentWidth = Orgwidth;
     targetWidth  = 180;
     countelapsed = 0;
     result       = 0;
 }
        private int status; //1: playing, 2: win, 3: lose
        public Capture(Player p, PokemonType x)
        {
            InitializeComponent();
            EllipseX.SetCenter(objective, 384, 224);
            EllipseX.SetCenter(moving, 384, 224);
            p1                 = p;
            pkm                = x;
            game               = new CaptureGame(x);
            status             = 1;
            balltimer.Tick    += ballTimer_Tick;
            balltimer.Interval = TimeSpan.FromSeconds(0.1);
            gametimer.Tick    += gameTimer_Tick;
            gametimer.Interval = TimeSpan.FromSeconds(0.02);
            switch (pkm.Name)
            {
            case "Bulbasaur":
                Bulbasaur.Visibility = Visibility.Visible;
                break;

            case "Squirtle":
                Squirtle.Visibility = Visibility.Visible;
                break;

            case "Charmander":
                Charmander.Visibility = Visibility.Visible;
                break;

            case "Pikachu":
                Pikachu.Visibility = Visibility.Visible;
                break;

            case "Snorlax":
                Snorlax.Visibility = Visibility.Visible;
                break;

            case "Lapras":
                Lapras.Visibility = Visibility.Visible;
                break;
            }
            ballcount.Text = p1.Pokeball_count.ToString();
            if (p1.Pokeball_count > 0)
            {
                CountdownTimer();
            }
            else
            {
                PokeballExhaust();
            }
        }
Exemplo n.º 4
0
        public Pokemon(int pId, PokemonType x)
        {
            id        = pId;
            rand      = new Random();
            name      = x.Name;
            typeName  = x.Name;
            moveslist = new AttackMoves[3];
            int i = 0;

            foreach (AttackMoves c in x.AtkMovesList)
            {
                moveslist[i] = new AttackMoves(c.name, c.attackPoints);
                i++;
            }
            weight      = rand.Next((int)(x.LowerWeight * 10), (int)(x.UpperWeight * 10 + 1)) / (float)10;
            height      = rand.Next((int)(x.LowerHeight * 10), (int)(x.UpperHeight * 10 + 1)) / (float)10;
            CP          = x.InitialCP;
            maxHP       = x.InitialHP;
            evolvestate = 1;
            HP          = maxHP;
        }
        private void pokemontimer_Tick(object sender, EventArgs e)
        {
            if (Program.status == 1)
            {
                return;
            }
            int decideRarity = rand.Next(0, 100);

            if (decideRarity < 97 && PokemonLoc.Count <= 5)
            {
                int         chosen        = rand.Next(0, Program.common.Count);
                int         i             = 0;
                PokemonType chosenPokemon = null;
                foreach (PokemonType x in Program.common)
                {
                    if (i == chosen)
                    {
                        chosenPokemon = x;
                        break;
                    }
                    i++;
                }
                Image       pkm1   = new Image();
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri("Images/pokemon/" + chosenPokemon.Name + ".gif", UriKind.Relative);
                bitmap.EndInit();
                pkm1.Source = bitmap;
                ImageBehavior.SetAnimatedSource(pkm1, bitmap);
                ImageBehavior.SetRepeatBehavior(pkm1, System.Windows.Media.Animation.RepeatBehavior.Forever);
                NavigationCanvas.Children.Add(pkm1);
                pkm1.Width = 32;

                int index = rand.Next(WalkableLocation.Count);
                int top   = (int)WalkableLocation[index].top;
                int left  = (int)WalkableLocation[index].left;

                while ((top >= 0 && top <= 139 && left >= 80 && left <= 240) || (top >= 235 && top <= 304 && left >= 288 && left <= 400) || exists(top, left))//exclude battle gym and home
                {
                    index = rand.Next(WalkableLocation.Count);
                    top   = (int)WalkableLocation[index].top;
                    left  = (int)WalkableLocation[index].left;
                }
                Canvas.SetTop(pkm1, top);
                Canvas.SetLeft(pkm1, left);
                pkm1.Visibility = Visibility.Hidden;
                PokemonLoc.Add(new Location(left, top), new WildPokemon(pkm1, chosenPokemon));
            }
            else if (PokemonLoc.Count <= 5)
            {
                int         chosen        = rand.Next(0, Program.rare.Count);
                int         i             = 0;
                PokemonType chosenPokemon = null;
                foreach (PokemonType x in Program.rare)
                {
                    if (i == chosen)
                    {
                        chosenPokemon = x;
                        break;
                    }
                    i++;
                }
                Image       pkm1   = new Image();
                BitmapImage bitmap = new BitmapImage();
                bitmap.BeginInit();
                bitmap.UriSource = new Uri("Images/pokemon/" + chosenPokemon.Name + ".gif", UriKind.Relative);
                bitmap.EndInit();
                pkm1.Source = bitmap;
                ImageBehavior.SetAnimatedSource(pkm1, bitmap);
                ImageBehavior.SetRepeatBehavior(pkm1, System.Windows.Media.Animation.RepeatBehavior.Forever);
                NavigationCanvas.Children.Add(pkm1);
                pkm1.Width = 32;

                int index = rand.Next(WalkableLocation.Count);
                int top   = (int)WalkableLocation[index].top;
                int left  = (int)WalkableLocation[index].left;

                while ((top >= 0 && top <= 139 && left >= 80 && left <= 240) || (top >= 235 && top <= 304 && left >= 288 && left <= 400) || exists(top, left))//exclude battle gym and home
                {
                    index = rand.Next(WalkableLocation.Count);
                    top   = (int)WalkableLocation[index].top;
                    left  = (int)WalkableLocation[index].left;
                }
                Canvas.SetTop(pkm1, top);
                Canvas.SetLeft(pkm1, left);
                pkm1.Visibility = Visibility.Hidden;
                PokemonLoc.Add(new Location(left, top), new WildPokemon(pkm1, chosenPokemon));
            }
        }
Exemplo n.º 6
0
        private Pokemon generateRandomBoss()
        {
            int         decider           = rand.Next(0, 100);
            PokemonType chosenPokemonType = null;
            int         i = 0;

            if (p1.PokemonCount() > 20)
            {
                if (decider < 40)
                {
                    int decider2 = rand.Next(0, Program.common.Count);
                    foreach (PokemonType x in Program.common)
                    {
                        if (i == decider2)
                        {
                            chosenPokemonType = x;
                            break;
                        }
                        i++;
                    }
                }
                else if (decider < 97)
                {
                    int decider2 = rand.Next(0, Program.rare.Count);
                    foreach (PokemonType x in Program.rare)
                    {
                        if (i == decider2)
                        {
                            chosenPokemonType = x;
                            break;
                        }
                        i++;
                    }
                }
                else
                {
                    int decider2 = rand.Next(0, Program.ultrarare.Count);
                    foreach (PokemonType x in Program.ultrarare)
                    {
                        if (i == decider2)
                        {
                            chosenPokemonType = x;
                            break;
                        }
                        i++;
                    }
                }
            }
            else
            {
                if (decider < 40)
                {
                    int decider2 = rand.Next(0, Program.common.Count);
                    foreach (PokemonType x in Program.common)
                    {
                        if (i == decider2)
                        {
                            chosenPokemonType = x;
                            break;
                        }
                        i++;
                    }
                }
                else
                {
                    int decider2 = rand.Next(0, Program.rare.Count);
                    foreach (PokemonType x in Program.rare)
                    {
                        if (i == decider2)
                        {
                            chosenPokemonType = x;
                            break;
                        }
                        i++;
                    }
                }
            }
            Pokemon Opponent = new Pokemon(9999, chosenPokemonType);

            decider = rand.Next(0, 10); // what evolve state the pokemon is in?
            if (decider >= 5)
            {
                Opponent.Evolve();
            }
            if (decider == 9)
            {
                Opponent.Evolve();
            }
            decider = rand.Next(0, 4); // How strong the pokemon is? (Powerup how many times?)
            for (int j = 0; j < decider; j++)
            {
                Opponent.PowerUP();
            }
            return(Opponent);
        }
Exemplo n.º 7
0
 public WildPokemon(Image x, PokemonType y)
 {
     pokemonImage = x;
     pokemonStat  = y;
 }