示例#1
0
        private EnemyModel CreateEnemyModel()
        {
            EnemyModel enemyModel = new EnemyModel();

            enemyModel.Front = new Point(0, -1);
            enemyModel.Mass  = .2f;
            enemyModel.Scale = Mathematics.Lerp(.4d, .8d, _rnd.NextDouble());

            enemyModel.MaxSpeed = (float)Mathematics.Lerp(_enemyMaxSpeedLowRange, _enemyMaxSpeedHighRange, _rnd.NextDouble());
            enemyModel.MaxForce = (float)Mathematics.Lerp(_enemyMaxForceLowRange, _enemyMaxForceHighRange, _rnd.NextDouble());

            int quadrant = _rnd.Next(1, 5);

            switch (quadrant)
            {
            case 1:
                enemyModel.Position = new Point(_rnd.NextDouble() * Width, -_enemyCreationBufferWidth);
                break;

            case 2:
                enemyModel.Position = new Point(Width + _enemyCreationBufferWidth, _rnd.NextDouble() * Height);
                break;

            case 3:
                enemyModel.Position = new Point(_rnd.NextDouble() * Width, Width + _enemyCreationBufferWidth);
                break;

            default:
                enemyModel.Position = new Point(-_enemyCreationBufferWidth, _rnd.NextDouble() * Height);
                break;
            }
            enemyModel.Initialize();
            return(enemyModel);
        }
示例#2
0
 public void SendEnemyWave(int n)
 {
     for (int i = 0; i < n; i++)
     {
         EnemyModel enemyModel = CreateEnemyModel();
         enemyModel.Add(new PursueAgentBehavior(_enemyAtBugThreshold, _enemyPredictionFactor, BugModel));
         enemyModel.Add(new SeperationBehavior(_enemySeperationFactor, _enemyList));
         _enemyList.Add(enemyModel);
         if (EnemyAdded != null)
         {
             EnemyAdded(this, new EnemyAddedEventArgs(enemyModel));
         }
     }
 }
示例#3
0
 public EnemyAddedEventArgs(EnemyModel enemyModel)
 {
     this.EnemyModel = enemyModel;
 }