Пример #1
0
        private void CheckForCollision()
        {
            List <Gold>         listOfGold    = GoldSpawner.GetListOfGold();
            List <PlayerSprite> listOfPlayers = PlayerSprite.GetPlayerSprites();
            var player = listOfPlayers.First <PlayerSprite>();

            foreach (var gold in listOfGold)
            {
                if (gold.Bounds.IntersectsWith(player.Bounds) && gold.Visible)
                {
                    gold.Dispose();
                    gameWindow.Score += 1;
                }
            }
        }
Пример #2
0
        private void CheckForCollision()
        {
            var listOfEnemies = EnemySpawner.GetListOfEnemies();
            var listOfPlayers = PlayerSprite.GetPlayerSprites();
            var player        = listOfPlayers.First <PlayerSprite>();

            foreach (var enemyPicture in listOfEnemies)
            {
                if (enemyPicture.Bounds.IntersectsWith(player.Bounds) && enemyPicture.Visible)
                {
                    enemyPicture.Dispose();
                    Player.Health = Player.Health - 1;
                }
            }
        }
Пример #3
0
        public GameWindow()
        {
            InitializeComponent();
            var enemy       = new Enemy(this);
            var player      = new Player();
            var gold        = new Gold(this);
            var goldSpawner = new GoldSpawner(this, gold);

            this.MaximumSize     = new Size(900, 900);
            masterTimer.Interval = 1;
            masterTimer.Enabled  = true;
            var playerSprite = new PlayerSprite();

            Controls.Add(playerSprite);
            var PlayerController = new PlayerContoller(this, playerSprite);
            var enemyPicture     = new EnemyPicture(this);
            var enemySpawner     = new EnemySpawner(this, enemyPicture);
            var enemyController  = new EnemyController(this);

            masterTimer.Tick += (sender, e) => SetRandomNumberEveryTick();
            masterTimer.Tick += (sender, e) => CheckIfGameShouldRun();
        }