public override void Update(CVGameTime gameTime)
        {
            Random r;

            if (_spawnedEnemy != null && _spawnedEnemy.Active == false)
            {
                _spawnedEnemy   = null;
                r               = new Random();
                _enemySpawnTime = r.Next(200, 2000);
            }
            if (!this.CurrentStage.Game.LaunchParameters.ContainsKey("DoNotSpawnEnemies"))
            {
                if (_spawnedEnemy == null && CurrentStage.ScreenCoordinates().Intersects(VirtualBox()) && VirtualBox().Right > CurrentStage.ScreenCoordinates().Right)
                {
                    _enemySpawnTime -= gameTime.ElapsedGameTime.TotalMilliseconds;

                    if (_enemySpawnTime < 0)
                    {
                        Vector2 spawnLocation =
                            new Vector2(this.VirtualBox().Left + (this.CurrentStage.ScreenCoordinates().Right - this.VirtualBox().Left),
                                        VirtualBox().Bottom);

                        CurrentStage.AddEnemy(_enemyType, spawnLocation);

                        r = new Random();
                        // TODO: rework this so that enemies spawn more similarly to classic Contra
                        _enemySpawnTime = Math.Sqrt(r.Next(50000, 4000000));
                    }

                    base.Update(gameTime);
                }
            }
        }
Exemple #2
0
 public override bool SpawnConditionsMet()
 {
     return(CurrentStage.ScreenCoordinates().Contains(BoundingBox()));
 }
Exemple #3
0
 public virtual bool SpawnConditionsMet()
 {
     return(this.BoundingBox().Intersects(CurrentStage.ScreenCoordinates()));
 }