Пример #1
0
 public void AssignVolunteers(int needed)
 {
     Debug.Assert(mParent.mCurrentIdleUnits.Count >= needed);
     if (needed <= 0) return;
     for (int i = 0; i < needed; i++)
     {
         Crusading exercise = new Crusading(mParent, mCrusade);
         IMovable warrior = mParent.mCurrentIdleUnits[mParent.mCurrentIdleUnits.Count - 1];
         Debug.Assert(mParent.mUnitToServant[warrior] == null);
         mCrusade.mWarriors.Add(warrior);
         mParent.AddExercise(warrior, exercise);
         Debug.Assert(!mParent.mCurrentIdleUnits.Contains(warrior));
         Debug.Assert(mParent.mUnitToServant[warrior] != null);
     }
     mCrusade.NoteRecalculate();
 }
Пример #2
0
 // depends on mCrusadeFeasibilities
 private void FillUpOrReleaseCrusades()
 {
     for (int i = mCrusades.Count-1; i >= 0; i--)
     {
         int needed = mCrusadeFeasibilities[mCrusades[i]];
         if (needed > 0 && mCurrentIdleUnits.Count > 0 &&
             GlobalValues.GetInstance().mAiFillUpCrusades)
         {
             int assign = Math.Min(needed, mCurrentIdleUnits.Count);
             Crusading exercise = new Crusading(this, mCrusades[i]);
             exercise.AssignVolunteers(assign);
             exercise.AddUrgency(-assign);
         }
         else if (needed > 0 && mCurrentIdleUnits.Count == 0)
         {
             ReleaseCrusade(mCrusades[i]);
         }
     }
 }
Пример #3
0
 private void AttackSector(int sectorX, int sectorY, int needed)
 {
     // TODO
     foreach(Crusade c in mCrusades) {
         Debug.Assert(c.mSectorX != sectorX || c.mSectorY != sectorY, "AI cannot attack same sector twice!");
     }
     Debug.Assert(needed > 0);
     //Debug.WriteLine("AI: Crusade against sector "+sectorX+", "+sectorY+" with "+needed+" ships started.");
     Crusade crusade = new Crusade(this, sectorX, sectorY);
     mCrusades.Add(crusade);
     Crusading crusading = new Crusading(this, crusade);
     crusading.AssignVolunteers(needed);
     foreach (IMovable warrior in crusade.mWarriors)
     {
         Debug.Assert(!mCurrentIdleUnits.Contains(warrior));
         Debug.Assert(mUnitToServant.ContainsKey(warrior));
         Crusading c = (Crusading)((Servant) mUnitToServant[warrior]).mExercise;
         Debug.Assert(c != null);
         Debug.Assert(c.mCrusade == crusade);
     }
 }