Esempio n. 1
0
 public void Collision()
 {
     foreach (AI ai in _ai)
     {
         if (ai.ColliedWith(_player))
         {
             if (SplashKit.BitmapName(ai.CarBitmap) == "Reward1")
             {
                 if (!_reward1)
                 {
                     _doubleSpeedTime = _timer.Ticks + 10000;
                 }
                 else
                 {
                     _doubleSpeedTime += 10000;
                 }
             }
             else
             {
                 SplashKit.DisplayDialog("GameOver", $"Your Score is: {_score} m", SplashKit.FontNamed("FontC"), 20);
                 Restart = true;
             }
         }
     }
 }
Esempio n. 2
0
 public void Collision()
 {
     if (_ai.ColliedWith(_player))
     {
         SplashKit.DisplayDialog("GameOver", "GameOver", SplashKit.FontNamed("FontC"), 20);
         Restart = true;
     }
 }
Esempio n. 3
0
        private void CheckCollisions()
        {
            List <Fish> fishToRemoveList = new List <Fish>();


            //check for collisions with the fish in the list
            foreach (var fish in _fishes)
            {
                if (fish.IsOffScreen(_GameWindow))
                {
                    fishToRemoveList.Add(fish);
                }

                if (_Player.CollideWith(fish) && _Player.CheckScale() >= fish._FishBitmap.CellHeight)
                {
                    _fishEaten.Add(fish);
                    _score.Add(fish);
                    fishToRemoveList.Add(fish);
                    var biteSound = new SoundEffect("bite", "./resources/sounds/bite.wav");
                    SplashKit.LoadSoundEffect("bite", "./resources/sounds/bite.wav");

                    SplashKit.PlaySoundEffect("bite");

                    switch (_fishEaten.Count)
                    {
                    case 1:
                        _Player._PlayerBitmap = new Bitmap("playerMedium", "./Resources/images/Small/Guppy Medium Sick right.png");    //

                        SplashKit.DrawBitmap("playerMedium", _Player.X, _Player.Y);
                        break;

                    case 5:
                        _Player._PlayerBitmap = new Bitmap("playerLarge", "./Resources/images/Small/Guppy Large Sick right.png");    //

                        SplashKit.DrawBitmap("playerLarge", _Player.X, _Player.Y);
                        break;

                    case 7:
                        _Player._PlayerBitmap = new Bitmap("playerMedium2", "./Resources/images/Large/Guppy Small Sick right.png");    //

                        SplashKit.DrawBitmap("playerMedium2", _Player.X, _Player.Y);
                        break;

                    case 10:
                        _Player._PlayerBitmap = new Bitmap("playerMedium3", "./Resources/images/Large/Guppy Medium Sick right.png");

                        SplashKit.DrawBitmap("playerMedium3", _Player.X, _Player.Y);
                        break;

                    case 12:
                        _Player._PlayerBitmap = new Bitmap("playerMedium4", "./Resources/images/Large/Guppy Large Sick right.png");

                        SplashKit.DrawBitmap("playerMedium4", _Player.X, _Player.Y);
                        break;

                    case 18:
                        _Player._PlayerBitmap = new Bitmap("playerPredator", "./Resources/images/Large/Predator Sick right.png");

                        SplashKit.DrawBitmap("playerPredator", _Player.X, _Player.Y);
                        break;
                    }
                }

                if (_Player.CollideWith(fish) && _Player.CheckScale() < fish._FishBitmap.CellHeight)
                {
                    int remove = Math.Min(_fishEaten.Count, 2);
                    _fishEaten.RemoveRange(0, remove);



                    if (_fishEaten.Count == 0)
                    {
                        _Player._PlayerBitmap = new Bitmap("DeadFish", "./Resources/images/Large/Guppy Small Dead.png");

                        SplashKit.DrawBitmap("DeadFish", _Player.X, _Player.Y);
                        SplashKit.LoadMusic("endMusic", "./resources/sounds/endmusic.mp3");

                        var font = SplashKit.LoadFont("Hand Scribble Sketch Times",
                                                      "./resources/fonts/Hand Scribble Sketch Times.otf");

                        SplashKit.PlayMusic("endMusic");
                        SplashKit.DisplayDialog("gameover", ($"Game Over Your Score is {_score.Count}"), font, 25);

                        _Player.Quit = true;
                    }
                    else
                    {
                        _Player._PlayerBitmap = new Bitmap("Small", "./Resources/images/Small/Guppy Small Sick right.png");

                        SplashKit.DrawBitmap("Small", _Player.X, _Player.Y);
                    }
                }
            }

            foreach (var fish in fishToRemoveList)
            {
                _fishes.Remove(fish);
            }
        }
Esempio n. 4
0
        public void HandleInput()
        {
            const int SPEED = 20;

            if (SplashKit.KeyDown(KeyCode.DownKey))
            {
                Y += SPEED;
            }
            if (SplashKit.KeyDown(KeyCode.UpKey))
            {
                Y -= SPEED;
            }

            if (SplashKit.KeyDown(KeyCode.RightKey))
            {
                switch (CurrentBitmapSize())
                {
                case 30:
                    _PlayerBitmap = new Bitmap("playerRight", "./Resources/images/Small/Guppy Small Sick right.png");
                    break;

                case 40:
                    _PlayerBitmap = new Bitmap("playerMediumRight", "./Resources/images/Small/Guppy Medium Sick right.png");
                    break;

                case 54:
                    _PlayerBitmap = new Bitmap("playerLargeRight", "./Resources/images/Small/Guppy Large Sick right.png");
                    break;

                case 73:
                    _PlayerBitmap = new Bitmap("playerXLRight", "./Resources/images/Large/Guppy Small Sick right.png");
                    break;

                case 98:
                    _PlayerBitmap = new Bitmap("playerMLRight", "./Resources/images/Large/Guppy Medium Sick right.png");
                    break;

                case 132:
                    _PlayerBitmap = new Bitmap("playerXXLargeRight", "./Resources/images/Large/Guppy large Sick right.png");
                    break;

                case 162:
                    _PlayerBitmap = new Bitmap("playerPredatorRight", "./Resources/images/Large/Predator Sick right.png");
                    break;

                default:
                    _PlayerBitmap = new Bitmap("playerRight", "./Resources/images/Small/Guppy Small Sick right.png");
                    break;
                }



                X += SPEED;
            }
            if (SplashKit.KeyDown(KeyCode.LeftKey))
            {
                switch (CurrentBitmapSize())
                {
                case 30:
                    _PlayerBitmap = new Bitmap("playerLeft", "./Resources/images/Small/Guppy Small Sick left.png");
                    break;

                case 40:
                    _PlayerBitmap = new Bitmap("playerMediumLeft", "./Resources/images/Small/Guppy Medium Sick left.png");
                    break;

                case 54:
                    _PlayerBitmap = new Bitmap("playerLargeLeft", "./Resources/images/Small/Guppy Large Sick left.png");
                    break;

                case 73:
                    _PlayerBitmap = new Bitmap("playerXLLeft", "./Resources/images/Large/Guppy small Sick left.png");
                    break;

                case 98:
                    _PlayerBitmap = new Bitmap("playerMLLeft", "./Resources/images/Large/Guppy Medium Sick left.png");
                    break;

                case 132:
                    _PlayerBitmap = new Bitmap("playerXXLargeLeft", "./Resources/images/Large/Guppy large Sick left.png");
                    break;

                case 162:
                    _PlayerBitmap = new Bitmap("playerPredatorleft", "./Resources/images/Large/Predator Sick left.png");
                    break;

                default:
                    _PlayerBitmap = new Bitmap("playerLeft", "./Resources/images/Small/Guppy Small Sick left.png");
                    break;
                }
                X -= SPEED;
            }
            if (SplashKit.KeyDown(KeyCode.SpaceKey))
            {
            }
            if (SplashKit.KeyDown(KeyCode.EscapeKey))
            {
                var font = SplashKit.LoadFont("Hand Scribble Sketch Times",
                                              "./resources/fonts/Hand Scribble Sketch Times.otf");

                SplashKit.DisplayDialog("gameover", "Are you sure you want to Quit", font, 25);

                Quit = true;
            }
        }