Example #1
0
        public SquadCA(IBot bot, SquadManagerBotModuleCA squadManager, SquadTypeCA type, Actor target)
        {
            Bot               = bot;
            SquadManager      = squadManager;
            World             = bot.Player.PlayerActor.World;
            Random            = World.LocalRandom;
            Type              = type;
            Target            = Target.FromActor(target);
            FuzzyStateMachine = new StateMachineCA();

            switch (type)
            {
            case SquadTypeCA.Assault:
            case SquadTypeCA.Rush:
                FuzzyStateMachine.ChangeState(this, new GroundUnitsIdleState(), true);
                break;

            case SquadTypeCA.Air:
                FuzzyStateMachine.ChangeState(this, new AirIdleState(), true);
                break;

            case SquadTypeCA.Protection:
                FuzzyStateMachine.ChangeState(this, new UnitsForProtectionIdleState(), true);
                break;

            case SquadTypeCA.Naval:
                FuzzyStateMachine.ChangeState(this, new NavyUnitsIdleState(), true);
                break;
            }
        }
Example #2
0
        public static SquadCA Deserialize(IBot bot, SquadManagerBotModuleCA squadManager, MiniYaml yaml)
        {
            var   type        = SquadTypeCA.Rush;
            Actor targetActor = null;

            var typeNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Type");

            if (typeNode != null)
            {
                type = FieldLoader.GetValue <SquadTypeCA>("Type", typeNode.Value.Value);
            }

            var targetNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Target");

            if (targetNode != null)
            {
                targetActor = squadManager.World.GetActorById(FieldLoader.GetValue <uint>("ActiveUnits", targetNode.Value.Value));
            }

            var squad = new SquadCA(bot, squadManager, type, targetActor);

            var unitsNode = yaml.Nodes.FirstOrDefault(n => n.Key == "Units");

            if (unitsNode != null)
            {
                squad.Units.AddRange(FieldLoader.GetValue <uint[]>("Units", unitsNode.Value.Value)
                                     .Select(a => squadManager.World.GetActorById(a)));
            }

            return(squad);
        }
Example #3
0
 public SquadCA(IBot bot, SquadManagerBotModuleCA squadManager, SquadTypeCA type)
     : this(bot, squadManager, type, null)
 {
 }