Esempio n. 1
0
        public void AutoMoving(Dictionary <Point, PictureBox> dic, string direction, PictureBox enemyRed, PictureBox enemyYellow, RandomBox box)
        {
            var playerX = PlayerPic.Location.X;
            var playerY = PlayerPic.Location.Y;

            if (PlayerPic.Location == enemyRed.Location)
            {
                Application.Exit();
            }
            if (PlayerPic.Location == enemyYellow.Location)
            {
                Application.Exit();
            }
            if (PlayerPic.Location == box.boxPic.Location)
            {
                box.Roulete();
            }
            switch (direction)
            {
            case "Right" when playerX + 50 == 750 && playerY == 400:
                CoinChanged?.Invoke(dic, playerX, playerY);
                PlayerPic.Location = new Point(0, 400);
                PlayerChanged?.Invoke("playerRightGIF.gif");
                break;

            case "Right" when CanMove(dic, playerX + 50, playerY):
                CoinChanged?.Invoke(dic, playerX, playerY);

                PlayerPic.Left += 50;
                break;

            case "Left" when playerX - 50 == -50 && playerY == 400:
                CoinChanged?.Invoke(dic, playerX, playerY);
                PlayerPic.Location = new Point(700, 400);
                PlayerChanged?.Invoke("playerLeftGIF.gif");
                break;

            case "Left" when CanMove(dic, playerX - 50, playerY):
                CoinChanged?.Invoke(dic, playerX, playerY);

                PlayerPic.Left -= 50;
                break;

            case "Up" when CanMove(dic, playerX, playerY - 50):
                CoinChanged?.Invoke(dic, playerX, playerY);

                PlayerPic.Top -= 50;
                break;

            case "Down" when CanMove(dic, playerX, playerY + 50):
                CoinChanged?.Invoke(dic, playerX, playerY);

                PlayerPic.Top += 50;
                break;
            }
        }
Esempio n. 2
0
 public void GainCoin()
 {
     coin++;
     CoinChanged?.Invoke(coin);
 }