Esempio n. 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;
                }
            }
        }
Esempio n. 2
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();
        }