Ejemplo n.º 1
0
        public static void OpenCatchScreen(string PokemonName)
        {
            TypingGameScreen game = new TypingGameScreen();

            game.PokemonName    = PokemonName;
            game.pokemon.Source = new BitmapImage(new Uri(@"pack://application:,,,/media/pokemon/" + PokemonName.ToLower() + ".png"));
        }
        private void characterMove(object sender, KeyEventArgs e)
        {
            pkmGenerator.stepsToEncounter++;
            if (pkmGenerator.wildPokemon != "")
            {
                TypingGameScreen.OpenCatchScreen(pkmGenerator.wildPokemon);
            }

            Point forestCoordinate = forest.TranslatePoint(new Point(0, 0), container);
            Point playerCoordinate = player.TranslatePoint(new Point(0, 0), forest);
            Point bagCoordinate    = bagButton.TranslatePoint(new Point(0, 0), forest);

            //Point moneyCoordinate = moneyLabel.TranslatePoint(new Point(0, 0), forest);
            //Point expCoordinate = expLabel.TranslatePoint(new Point(0, 0), forest);
            x.PositionRecording(playerCoordinate.X, playerCoordinate.Y);
            if (e.Key == Key.Left)
            {
                player.Fill = new ImageBrush(new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/media/right" + (characterMoveImageIndex / 2 + 1) + ".png")));
                characterMoveImageIndex++;
                if (characterMoveImageIndex == 8)
                {
                    characterMoveImageIndex = 1;
                }
                if (playerCoordinate.X <= 260)
                {
                    Canvas.SetLeft(player, playerCoordinate.X + 3);
                    x.x_pos += 3;
                }
                else if (forestCoordinate.X <= -123)
                {
                    if (playerCoordinate.X <= 1432)
                    {
                        Canvas.SetLeft(player, playerCoordinate.X + 3);
                        x.x_pos += 3;
                    }
                }
                else
                {
                    Canvas.SetLeft(player, playerCoordinate.X + 3);
                    Canvas.SetLeft(bagButton, bagCoordinate.X + 3);
                    //Canvas.SetLeft(moneyLabel, moneyCoordinate.X + 3);
                    //Canvas.SetLeft(expLabel, expCoordinate.X + 3);
                    Canvas.SetLeft(forest, forestCoordinate.X - 3);
                }
            }
            if (e.Key == Key.Up)
            {
                player.Fill = new ImageBrush(new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/media/down" + (characterMoveImageIndex / 2 + 1) + ".png")));
                characterMoveImageIndex++;
                if (characterMoveImageIndex == 8)
                {
                    characterMoveImageIndex = 1;
                }
                if (playerCoordinate.Y <= 211)
                {
                    Canvas.SetTop(player, playerCoordinate.Y + 3);
                }
                else if (forestCoordinate.Y <= -8)
                {
                    if (playerCoordinate.Y <= 988)
                    {
                        Canvas.SetTop(player, playerCoordinate.Y + 3);
                    }
                }
                else
                {
                    Canvas.SetTop(player, playerCoordinate.Y + 3);
                    Canvas.SetTop(bagButton, bagCoordinate.Y + 3);
                    //Canvas.SetTop(moneyLabel, moneyCoordinate.Y + 3);
                    //Canvas.SetTop(expLabel, expCoordinate.Y + 3);
                    Canvas.SetTop(forest, forestCoordinate.Y - 3);
                }
            }

            Rect playerRec = new Rect(Canvas.GetLeft(player), Canvas.GetTop(player), player.Width, player.Height);
            Rect gymRec    = new Rect(Canvas.GetLeft(gymArea), Canvas.GetTop(gymArea), gymArea.Width, gymArea.Height);

            if (playerRec.IntersectsWith(gymRec))
            {
                if (battled == false)
                {
                    on_Gym_encounter();
                }
                battled = true;
            }
        }