Ejemplo n.º 1
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]);
         }
     }
 }
Ejemplo n.º 2
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);
     }
 }