Example #1
0
        private bool IsValidUnitItem(
            BasicCharacterObject o,
            BasicCultureObject culture,
            ArmyCompositionGroup.TroopType troopType)
        {
            if (o == null || culture != o.Culture)
            {
                return(false);
            }
            switch (troopType)
            {
            case ArmyCompositionGroup.TroopType.MeleeInfantry:
                return /*(int) o.CurrentFormationClass == null ||*/ ((int)o.CurrentFormationClass == 5);

            case ArmyCompositionGroup.TroopType.RangedInfantry:
                return((int)o.CurrentFormationClass == 1);

            case ArmyCompositionGroup.TroopType.MeleeCavalry:
                return((int)o.CurrentFormationClass == 2 || (int)o.CurrentFormationClass == 7 || (int)o.CurrentFormationClass == 6);

            case ArmyCompositionGroup.TroopType.RangedCavalry:
                return((int)o.CurrentFormationClass == 3);

            default:
                return(false);
            }
        }
        private bool IsValidUnitItem(
            BasicCharacterObject o,
            BasicCultureObject culture,
            ArmyCompositionGroup.TroopType troopType)
        {
            if (o == null || culture != o.Culture)
            {
                return(false);
            }
            switch (troopType)
            {
            case ArmyCompositionGroup.TroopType.MeleeInfantry:
                return(o.CurrentFormationClass == FormationClass.Infantry || o.CurrentFormationClass == FormationClass.HeavyInfantry);

            case ArmyCompositionGroup.TroopType.RangedInfantry:
                return(o.CurrentFormationClass == FormationClass.Ranged);

            case ArmyCompositionGroup.TroopType.MeleeCavalry:
                return(o.CurrentFormationClass == FormationClass.Cavalry || o.CurrentFormationClass == FormationClass.HeavyCavalry || o.CurrentFormationClass == FormationClass.LightCavalry);

            case ArmyCompositionGroup.TroopType.RangedCavalry:
                return(o.CurrentFormationClass == FormationClass.HorseArcher);

            default:
                return(false);
            }
        }
Example #3
0
 private void PopulateTroopTypeList(
     ArmyCompositionGroup.TroopType troopType,
     BasicCultureObject cultureOfTroops)
 {
     if (troopType == ArmyCompositionGroup.TroopType.MeleeInfantry)
     {
         this._meleeInfantryTypes.Clear();
         this._meleeInfantryTypes.AddRange(((IEnumerable <BasicCharacterObject>) this._allCharacterObjects).Where <BasicCharacterObject>((Func <BasicCharacterObject, bool>)(o => this.IsValidUnitItem(o, cultureOfTroops, troopType))));
         this.SelectedMeleeInfantryTypes.Clear();
         this.SelectedMeleeInfantryTypes.Add(CustomBattleState.Helper.GetDefaultTroopOfFormationForFaction(cultureOfTroops, (FormationClass)0));
     }
     else if (troopType == ArmyCompositionGroup.TroopType.RangedInfantry)
     {
         this._rangedInfantryTypes.Clear();
         this._rangedInfantryTypes.AddRange(((IEnumerable <BasicCharacterObject>) this._allCharacterObjects).Where <BasicCharacterObject>((Func <BasicCharacterObject, bool>)(o => this.IsValidUnitItem(o, cultureOfTroops, troopType))));
         this.SelectedRangedInfantryTypes.Clear();
         this.SelectedRangedInfantryTypes.Add(CustomBattleState.Helper.GetDefaultTroopOfFormationForFaction(cultureOfTroops, (FormationClass)1));
     }
     else if (troopType == ArmyCompositionGroup.TroopType.MeleeCavalry)
     {
         this._meleeCavalryTypes.Clear();
         this._meleeCavalryTypes.AddRange(((IEnumerable <BasicCharacterObject>) this._allCharacterObjects).Where <BasicCharacterObject>((Func <BasicCharacterObject, bool>)(o => this.IsValidUnitItem(o, cultureOfTroops, troopType))));
         this.SelectedMeleeCavalryTypes.Clear();
         this.SelectedMeleeCavalryTypes.Add(CustomBattleState.Helper.GetDefaultTroopOfFormationForFaction(cultureOfTroops, (FormationClass)2));
     }
     else
     {
         if (troopType != ArmyCompositionGroup.TroopType.RangedCavalry)
         {
             return;
         }
         this._rangedCavalryTypes.Clear();
         this._rangedCavalryTypes.AddRange(((IEnumerable <BasicCharacterObject>) this._allCharacterObjects).Where <BasicCharacterObject>((Func <BasicCharacterObject, bool>)(o => this.IsValidUnitItem(o, cultureOfTroops, troopType))));
         this.SelectedRangedCavalryTypes.Clear();
         this.SelectedRangedCavalryTypes.Add(CustomBattleState.Helper.GetDefaultTroopOfFormationForFaction(cultureOfTroops, (FormationClass)3));
     }
 }