コード例 #1
0
 public TacticSallyOutHitAndRun(Team team)
     : base(team)
 {
     this._archerFormations       = new List <Formation>();
     this._cavalryFormations      = new List <Formation>();
     this._teamAISallyOutAttacker = team.TeamAI as TeamAISallyOutAttacker;
     this._state = TacticSallyOutHitAndRun.TacticState.HeadingOutFromCastle;
     this._destructibleEnemySiegeWeapons = Mission.Current.ActiveMissionObjects.FindAllWithType <SiegeWeapon>().Where <SiegeWeapon>((Func <SiegeWeapon, bool>)(sw => sw.Side != team.Side && sw.IsDestructible)).ToList <SiegeWeapon>();
     this.ManageFormationCounts();
     this._AIControlledFormationCount = this.Formations.Count <Formation>((Func <Formation, bool>)(f => f.IsAIControlled));
     this.HeadOutFromTheCastle();
 }
コード例 #2
0
        private void CheckAndChangeState()
        {
            switch (this._state)
            {
            case TacticSallyOutHitAndRun.TacticState.HeadingOutFromCastle:
                if (!this._cavalryFormations.All <Formation>((Func <Formation, bool>)(cf => !TeamAISiegeComponent.IsFormationInsideCastle(cf, false))))
                {
                    break;
                }
                this._state = TacticSallyOutHitAndRun.TacticState.DestroyingSiegeWeapons;
                this.DestroySiegeWeapons();
                break;

            case TacticSallyOutHitAndRun.TacticState.DestroyingSiegeWeapons:
                if (!this._destructibleEnemySiegeWeapons.All <SiegeWeapon>((Func <SiegeWeapon, bool>)(desw => desw.IsDestroyed)) && !this._cavalryFormations.All <Formation>((Func <Formation, bool>)(cf =>
                {
                    if (!(cf.AI.ActiveBehavior is BehaviorDestroySiegeWeapons) || cf.MovementOrder == (object)MovementOrder.MovementOrderRetreat)
                    {
                        return(true);
                    }
                    if ((cf.AI.ActiveBehavior as BehaviorDestroySiegeWeapons).LastTargetWeapon == null)
                    {
                        return(false);
                    }
                    Vec3 globalPosition = (cf.AI.ActiveBehavior as BehaviorDestroySiegeWeapons).LastTargetWeapon.GameEntity.GlobalPosition;
                    return((double)this.team.QuerySystem.GetLocalEnemyPower(globalPosition.AsVec2) > (double)this.team.QuerySystem.GetLocalAllyPower(globalPosition.AsVec2) + (double)cf.QuerySystem.FormationPower);
                })))
                {
                    break;
                }
                this._state = TacticSallyOutHitAndRun.TacticState.CavalryRetreating;
                this.CavalryRetreat();
                break;

            case TacticSallyOutHitAndRun.TacticState.CavalryRetreating:
                if (!this._cavalryFormations.IsEmpty <Formation>() && !TeamAISiegeComponent.IsFormationGroupInsideCastle((IEnumerable <Formation>) this._cavalryFormations, false))
                {
                    break;
                }
                this._state = TacticSallyOutHitAndRun.TacticState.InfantryRetreating;
                this.InfantryRetreat();
                break;
            }
        }