コード例 #1
0
 private void InitialiseActiveUnitTypes()
 {
     foreach (UnitType unitType in Enum.GetValues(typeof(UnitType)).Cast <UnitType>())
     {
         if (activeUnitNumbers.GetNumber(unitType) > 0)
         {
             activeUnitTypes.Add(unitType);
         }
     }
 }
コード例 #2
0
    // Returns a unit map containing the units required to be equal to the other map (assuming the other map can be reached from the current state)
    public UnitMap UnitsRequiredToBecome(UnitMap otherMap)
    {
        UnitMap comparisonResult = new UnitMap();

        foreach (UnitType type in units.Keys)
        {
            int numUnits = otherMap.GetNumber(type) - GetNumber(type);
            comparisonResult.AddMultiple(type, numUnits);
        }

        return(comparisonResult);
    }
コード例 #3
0
    public void UpdateAIUnitViews(ActiveUnits aiUnits)
    {
        UnitMap ai_startingUnits = aiUnits.GetStartingUnits();
        UnitMap ai_casualties    = aiUnits.GetUnitLosses();

        foreach (KeyValuePair <UnitType, UnitCombatResultView> entry in aiUnitViews)
        {
            int startingNum = ai_startingUnits.GetNumber(entry.Key);
            int casualties  = ai_casualties.GetNumber(entry.Key);

            entry.Value.UpdateNumUnits(startingNum, casualties);
        }
    }
コード例 #4
0
    public void UpdateArmy(UnitMap casualties)
    {
        foreach (UnitType type in Enum.GetValues(typeof(UnitType)).Cast <UnitType>())
        {
            int numDeaths = casualties.GetNumber(type);

            for (int i = 0; i < numDeaths; i++)
            {
                army.RemoveUnit(type);
            }
            //update views
            UpdateSupplyView();
            UpdateUnitView(type);
        }
    }