Exemplo n.º 1
0
        public void OnFire(int playerIndex, Vector2 position, WalkingDirection walkingDirection)
        {
            var bullet = new BulletSprite(bulletTexture, position, walkingDirection, playerIndex);

            bullet.font = HUDFont;
            bulllets.Add(bullet);
        }
Exemplo n.º 2
0
        private void CheckColisionForPlayer(BulletSprite bullet, TankSprite player, TankSprite enemy)
        {
            if (bullet.shouldDraw && bullet.IsCollidingWith(player) && bullet.bulletOwner != player.playerNumber)
            {
                var explosion = new AnimatedSprite(explosionTexture,
                                                   new Vector2(player.position.X, player.position.Y) - new Vector2(explosionTexture.Width / 2 / 4, explosionTexture.Height / 2 / 4), 4, 4);

                player.position = player.startingPosition;
                enemy.score++;
                explosions.Add(explosion);
                bullet.shouldDraw = false;
                explosionSound.Play();
            }
        }