예제 #1
0
파일: Bullet.cs 프로젝트: hekar/Asteroids
 /// <summary>
 /// Initializes a new instance of the <see cref="Bullet"/> class.
 /// </summary>
 /// <param name="entityManager">The entity manager.</param>
 /// <param name="position">The position.</param>
 /// <param name="speed">The speed.</param>
 /// <param name="rotation">The rotation.</param>
 public Bullet(EntityManager entityManager,
     Vector2 position, Vector2 speed, float rotation)
 {
     this.entityManager = entityManager;
     this.speed = speed;
     this.Rotation = rotation;
     this.origin = position;
     Position = position;
 }
예제 #2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnemyShip"/> class.
 /// </summary>
 /// <param name="entityManager">The entity manager.</param>
 /// <param name="position">The ship position.</param>
 /// <param name="speed">The ship speed.</param>
 /// <param name="size">The ship size.</param>
 /// <param name="player">The player.</param>
 public EnemyShip(EntityManager entityManager, Vector2 position, Vector2 speed, Sizes size, Player player)
 {
     this.entityManager = entityManager;
     random = new Random();
     Position = position;
     this.Size = size;
     this.speed = speed;
     this.player = player;
 }
예제 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GameManager"/> class.
        /// </summary>
        /// <param name="entityManager">The entity manager.</param>
        /// <param name="player">The player.</param>
        public GameManager(EntityManager entityManager, Player player)
        {
            this.entityManager = entityManager;
            this.player = player;

            random = new Random();

            /// Set the time keepers to zero
            lastAsteroidSpawnTime = TimeSpan.Zero;
        }
예제 #4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="EnemyBullet"/> class.
 /// </summary>
 /// <param name="entityManager">The entity manager.</param>
 /// <param name="ship">The ship.</param>
 /// <param name="position">The position.</param>
 /// <param name="speed">The speed.</param>
 /// <param name="rotation">The rotation.</param>
 public EnemyBullet(EntityManager entityManager, EnemyShip ship,
     Vector2 position, Vector2 speed, float rotation)
     : base(entityManager, position, speed, rotation)
 {
     this.ship = ship;
 }
예제 #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Explosion"/> class.
 /// </summary>
 /// <param name="entityManager">The entity manager.</param>
 /// <param name="explosionTextureName">Name of the explosion texture.</param>
 public Explosion(EntityManager entityManager, string explosionTextureName)
 {
     this.entityManager = entityManager;
     this.explosionTextureName = explosionTextureName;
 }
예제 #6
0
        /// <summary>
        /// Initialize the new game. Creates any entities that need to be created
        /// in order to run the game.
        /// </summary>
        private void NewGame()
        {
            if (entityManager == null)
            {
                /// Create a new entity manager.
                entityManager = new EntityManager(Content, GraphicsDevice);
            }
            else
            {
                entityManager.Clear();
            }

            if (inputManager == null)
            {
                inputManager = new InputManager();
            }
            /// Create a new player.
            player = new Player(entityManager);
            if (asteroidManager == null)
            {
                asteroidManager = new GameManager(entityManager, player);
            }
            else
            {
                asteroidManager.Clear();
            }
            if (titleScreen == null)
            {
                /// Create a new title screen
                titleScreen = new Titlescreen(player);
            }
            else
            {
                titleScreen.Player = player;
            }
            entityManager.Add(new Background());
            entityManager.Add(player);
            entityManager.Add(new ScoreDisplay(new List<Player>(new Player[] { player })));
        }
예제 #7
0
파일: Player.cs 프로젝트: hekar/Asteroids
 /// <summary>
 /// Initializes a new instance of the <see cref="Player"/> class.
 /// </summary>
 /// <param name="entityManager">The entity manager.</param>
 public Player(EntityManager entityManager)
 {
     this.entityManager = entityManager;
 }