コード例 #1
0
ファイル: Collisions.cs プロジェクト: sigod/xna-invaders
        public static void BetweenInvadersAndPlayersBullets(Player player, List<Invader> invaders,
            List<Bullet> bullets)
        {
            for (int i = invaders.Count - 1; i >= 0; i--)
            {
                Rectangle invader = invaders[i].GetRectangle();

                for (int j = bullets.Count - 1; j >= 0; j--)
                {
                    if (invader.Intersects(bullets[j].GetRectangle()))
                    {
                        invaders[i].Health -= bullets[j].Damage;
                        bullets[j].Active = false;
                        bullets.RemoveAt(j);
                    }
                }

                if (invaders[i].Health <= 0)
                {
                    invaders[i].Active = false;
                    player.Score += invaders[i].ScoreValue;
                    invaders.RemoveAt(i);
                }
            }
        }
コード例 #2
0
ファイル: Collisions.cs プロジェクト: sigod/xna-invaders
        public static void BetweenPlayerAndInvaders(Player player,
            List<Invader> invaders)
        {
            Rectangle playerRec = player.GetRectangle();

            for (int i = invaders.Count - 1; i >= 0; i--)
            {
                if (playerRec.Intersects(invaders[i].GetRectangle()))
                {
                    player.Health -= invaders[i].Damage;
                    player.Score += invaders[i].ScoreValue;
                    invaders[i].Health = 0;
                    // Explosion?
                    invaders.RemoveAt(i);
                }
            }
        }
コード例 #3
0
ファイル: Collisions.cs プロジェクト: sigod/xna-invaders
        public static void BetweenPlayerAndInvadersBullets(Player player,
            List<Bullet> bullets)
        {
            Rectangle playerRec = player.GetRectangle();

            for (int i = bullets.Count - 1; i >= 0; i--)
            {
                if (playerRec.Intersects(bullets[i].GetRectangle()))
                {
                    player.Health -= bullets[i].Damage;
                    bullets[i].Active = false;
                    bullets.RemoveAt(i);
                }
            }
        }
コード例 #4
0
ファイル: InvadersGame.cs プロジェクト: sigod/xna-invaders
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            gameState = GameState.Menu1;
            UI = new UI();

            keyboardDInput = new KeyboardDelayableInput(200);

            ScreenSize.Viewport = GraphicsDevice.Viewport;

            playerBullets = new List<Bullet>();
            player = new Player(playerBullets);

            invadersBullets = new List<Bullet>();

            invaders = new List<Invader>();
            invadersSquad = new InvadersSquad();

            base.Initialize();
        }