本文整理汇总了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);
}
示例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);
}
示例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);
}
}