Esempio n. 1
0
        public override void Start()
        {
            base.Start();
            DifficultyLvl = info.Difficulty;
            _selfRace     = info.GetPlayerRace() == Races.MEN ? Races.ELVES : Races.MEN;

            //Init lists
            EnemyUnits     = new List <Unit>();
            EnemyBuildings = new List <IGameEntity>();
            OwnResources   = new List <Resource>();
            OwnBarracks    = new List <Barrack>();
            modules        = new List <AIModule>();
            Army           = new List <Unit>();
            Workers        = new List <Unit>();

            Battle.PlayerInformation me = info.GetBattle().GetPlayerInformationList()[playerId - 1];
            SetInitialResources(me.GetResources().Wood, me.GetResources().Food, me.GetResources().Metal, me.GetResources().Gold);
            Battle.PlayableEntity.EntityPosition pos = me.GetBuildings()[0].position;
            rootBasePosition = new Vector3(pos.X, 80, pos.Y);
            buildPosition    = rootBasePosition;
            Macro            = new MacroManager(this);
            StoryMode        = Macro.architect.constructionGrid.mode != AIMode.BATTLE;
            Micro            = new MicroManager(this);
            modules.Add(new AIModule(Macro.MacroHigh, !StoryMode ? (39 - DifficultyLvl * 3) : 1));
            modules.Add(new AIModule(Macro.MacroLow, 8 - DifficultyLvl));
            modules.Add(new AIModule(Micro.Micro, 4 - DifficultyLvl));
            timers        = new float[modules.Count];
            hasStronghold = true;
            for (int i = 0; i < modules.Count; i++)
            {
                timers[i] = 0;
            }

            InstantiateBuildings(me.GetBuildings());
            InstantiateUnits(me.GetUnits());

            ActorSelector selector = new ActorSelector()
            {
                registerCondition = gameObject => gameObject.GetComponent <FOWEntity>().IsOwnedByPlayer,
                fireCondition     = gameObject => true
            };

            Subscriber <FOWEntity.Actions, FOWEntity> .get.registerForAll(FOWEntity.Actions.DISCOVERED, OnEntityFound, selector);

            Subscriber <FOWEntity.Actions, FOWEntity> .get.registerForAll(FOWEntity.Actions.HIDDEN, OnEntityLost, selector);

            if (AI_DEBUG_ENABLED)
            {
                aiDebug = AIDebugSystem.CreateComponent(gameObject, this);
            }

            missionStatus = new MissionStatus(playerId);
        }
Esempio n. 2
0
        public override void Start()
        {
            base.Start();
            DifficultyLvl = info.Difficulty;
            _selfRace = info.GetPlayerRace() == Races.MEN ? Races.ELVES : Races.MEN;

            //Init lists
            EnemyUnits = new List<Unit>();
            EnemyBuildings = new List<IGameEntity>();
            OwnResources = new List<Resource>();
            OwnBarracks = new List<Barrack>();
            modules = new List<AIModule>();
            Army = new List<Unit>();
            Workers = new List<Unit>();

            Battle.PlayerInformation me = info.GetBattle().GetPlayerInformationList()[playerId - 1];
            SetInitialResources(me.GetResources().Wood, me.GetResources().Food, me.GetResources().Metal, me.GetResources().Gold);
            Battle.PlayableEntity.EntityPosition pos = me.GetBuildings()[0].position;
            rootBasePosition = new Vector3(pos.X, 80, pos.Y);
            buildPosition = rootBasePosition;
            Macro = new MacroManager(this);
            StoryMode = Macro.architect.constructionGrid.mode != AIMode.BATTLE;
            Micro = new MicroManager(this);
            modules.Add(new AIModule(Macro.MacroHigh, !StoryMode ? (39 - DifficultyLvl*3) : 1));
            modules.Add(new AIModule(Macro.MacroLow, 8 - DifficultyLvl));
            modules.Add(new AIModule(Micro.Micro,  4 - DifficultyLvl));
            timers = new float[modules.Count];
            hasStronghold = true;
            for (int i = 0; i < modules.Count; i++)
                timers[i] = 0;

            InstantiateBuildings(me.GetBuildings());
            InstantiateUnits(me.GetUnits());

            ActorSelector selector = new ActorSelector()
            {
                registerCondition = gameObject => gameObject.GetComponent<FOWEntity>().IsOwnedByPlayer,
                fireCondition = gameObject => true
            };
            Subscriber<FOWEntity.Actions, FOWEntity>.get.registerForAll(FOWEntity.Actions.DISCOVERED, OnEntityFound, selector);
            Subscriber<FOWEntity.Actions, FOWEntity>.get.registerForAll(FOWEntity.Actions.HIDDEN, OnEntityLost, selector);

            if (AI_DEBUG_ENABLED)
            {
                aiDebug = AIDebugSystem.CreateComponent(gameObject, this);
            }

            missionStatus = new MissionStatus(playerId);
        }