当前位置: 首页>>代码示例>>C#>>正文


C# Enemy.LoadContent方法代码示例

本文整理汇总了C#中Enemy.LoadContent方法的典型用法代码示例。如果您正苦于以下问题:C# Enemy.LoadContent方法的具体用法?C# Enemy.LoadContent怎么用?C# Enemy.LoadContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Enemy的用法示例。


在下文中一共展示了Enemy.LoadContent方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Update

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
                this.Exit();

            // TODO: Add your update logic here
            timer += gameTime.ElapsedGameTime.TotalSeconds;

            player.Update(gameTime);

            scrollingBackground.Update();

            if (timer > 99.0)
            {
                timer = 0.0;
                Enemy newEnemy = new Enemy();
                newEnemy.LoadContent(Content, GraphicsDevice);
                newEnemy.recEnemyPositionAndDimension.X = randomGenerator.Next(0, GraphicsDevice.Viewport.Width - newEnemy.recEnemyPositionAndDimension.Width);
                enemyList.Add(newEnemy);
            }

            Matrix matEnemy;
            enemy2DeleteList.Clear();
            bullet2DeleteList.Clear();

            foreach (Enemy enemy in enemyList)
            {
                if (enemy.isActive)
                {
                    enemy.Update();
                    matEnemy = Matrix.CreateScale(enemy.scaleEnemy) * Matrix.CreateTranslation(enemy.recEnemyPositionAndDimension.X, enemy.recEnemyPositionAndDimension.Y, 0);
                    if (player.CheckCollision(enemy.recEnemyPositionAndDimension, colorArrayEnemy, matEnemy))
                    //if (player.CheckCollision(enemy.recEnemyPositionAndDimension, enemy.colArrayEnemy, matEnemy))
                    //if (player.CheckCollision(enemy.colArrayEnemy, matEnemy))
                    //if (player.CheckCollision(enemy.recEnemyPositionAndDimension))
                    {
                        Exit();
                    }

                    foreach (Bullet bullet in player.bulletList)
                    {
                        if (!bullet.IsActive)
                        {
                            bullet2DeleteList.Add(bullet);
                        }
                        else
                        {
                            //Prüfen ob Kugel was getroffen hat
                        }
                    }

                }
                else
                {
                    enemy2DeleteList.Add(enemy);
                }
            }

            foreach (Enemy enemy in enemy2DeleteList)
            {
                enemyList.Remove(enemy);
            }
            foreach (Bullet bullet in bullet2DeleteList)
            {
                player.bulletList.Remove(bullet);
            }

            base.Update(gameTime);
        }
开发者ID:anderl1969,项目名称:XNA,代码行数:77,代码来源:Game1.cs

示例2: LoadContent

        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            //dummy Enemy laden um Color-Array zu erstellen
            Enemy dummyEnemy = new Enemy();
            dummyEnemy.LoadContent(Content, GraphicsDevice);
            colorArrayEnemy = dummyEnemy.TextureTo2DArray(dummyEnemy.texEnemy, dummyEnemy.getCountHorAnimPics(), dummyEnemy.getCountVerAnimPics(), 0);

            scrollingBackground.LoadContent(Content, GraphicsDevice);
            soundBackground = Content.Load<SoundEffect>("Sound\\Fire_Birds");
            soundBackground.Play();
            player.LoadContent(Content, GraphicsDevice);
        }
开发者ID:anderl1969,项目名称:XNA,代码行数:20,代码来源:Game1.cs

示例3: SpawnEnemy

 private void SpawnEnemy(GameTime gameTime)
 {
     if (((totalForSpawnElapsed += gameTime.ElapsedGameTime) > minForSpawn) && enemies.Count < 5)
     {
         Enemy a = new Enemy(graphics);
         a.LoadContent(this.Content);
         totalForSpawnElapsed = TimeSpan.Zero;
         enemies.Add(a);
     }
 }
开发者ID:andrewderryfarrell,项目名称:idea-game,代码行数:10,代码来源:Game1.cs


注:本文中的Enemy.LoadContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。