Example #1
0
        public void Display(GameFacade facade)
        {
            FileHandler fileHandler = FileHandler.Instance;

            fileHandler.Menu();

            if (SplashKit.MouseClicked(MouseButton.LeftButton))
            {
                // Clicks play button
                if (SplashKit.MousePosition().X > 150 && SplashKit.MousePosition().X < 550)
                {
                    if (SplashKit.MousePosition().Y > 450 && SplashKit.MousePosition().Y < 608)
                    {
                        facade.SetState(new GamePlayState());
                    }
                }
                // Clicks quit button
                if (SplashKit.MousePosition().X > 225 && SplashKit.MousePosition().X < 475)
                {
                    if (SplashKit.MousePosition().Y > 650 && SplashKit.MousePosition().Y < 748)
                    {
                        SplashKit.CloseCurrentWindow();
                    }
                }
            }
        }
Example #2
0
    private void CheckCollisions()
    {
        List <Robot> _removedRobots = new List <Robot>();


        foreach (Robot robot in _Robot)
        {
            if (_Player.CollidedWith(robot) || robot.Offscreen(_GameWindow))
            {
                _removedRobots.Add(robot);
            }

            if (_Player.CollidedWith(robot))
            {
                Lives = Lives - 1;

                if (Lives == 0)
                {
                    SplashKit.CloseCurrentWindow();
                }
            }
        }

        foreach (Robot robot in _removedRobots)
        {
            _Robot.Remove(robot);
        }
    }
Example #3
0
        void checkHit(Player player)
        {
            bool playerHit = false;

            int lifeGone;

            //Console.WriteLine("Inside Hit");
            for (int i = 0; i < _enemyList.Count; i++)
            {
                foreach (var item in _enemyList[i]._bulletList)
                {
                    if (item.CollidedWith(_player, item))
                    {
                        playerHit = true;
                        break;
                    }
                }
            }
            //
            if (playerHit)
            {
                playerHit = false;
                counter++;
                if (counter > 4)
                {
                    lifeGone = _player._life--;
                    counter  = 0;
                    if (lifeGone <= 0)
                    {
                        SplashKit.CloseCurrentWindow();
                    }
                    else
                    {
                        _player.RemoveLife(lifeGone);
                    }
                }
            }
            //Console.WriteLine("Hit out");
        }