Пример #1
0
        public BasicAi(EaiDifficulty difficulty, ref Director director, bool isTutorial = false)
        {
            Difficulty = difficulty;
            mDirector  = director;
            IsTutorial = isTutorial;

            mBoundsToDraw = new List <Rectangle>();

            mStructure = new List <Pair <Triple <CommandCenter, List <PlatformBlank>, List <Road> >, Rectangle> >();

            mBehavior = new AdvancedAiBehavior(this, ref director);
        }
Пример #2
0
 public void UpdateFromStatic()
 {
     EffectsVolume    = GlobalVariables.EffectsVolume;
     MusicVolume      = GlobalVariables.MusicVolume;
     UiVolume         = GlobalVariables.UiVolume;
     MasterVolume     = GlobalVariables.MasterVolume;
     FowEnabled       = GlobalVariables.FowEnabled;
     HealthBarEnabled = GlobalVariables.HealthBarEnabled;
     IsFullScreen     = GlobalVariables.IsFullScreen;
     ChosenResolution = GlobalVariables.ChosenResolution;
     AudioMute        = GlobalVariables.AudioMute;
     Difficulty       = GlobalVariables.Difficulty;
 }
Пример #3
0
        public AdvancedAiBehavior(IArtificalIntelligence ai, ref Director director)
        {
            mAi         = ai;
            mDirector   = director;
            mDifficulty = ai.Difficulty;
            mRandom     = new Random();

            mIsCurrentlyMoving = new Dictionary <EnemyUnit, bool>();

            mUnitToFlockingGroup = new Dictionary <EnemyUnit, FlockingGroup>();
            mCollidingRects      = new List <Rectangle>();
            mScoutingUnits       = new IntervalHeap <PrioritizableObject <EnemyUnit> >(new PrioritizableObjectAscendingComparer <EnemyUnit>());
            mAttackingUnits      = new IntervalHeap <PrioritizableObject <EnemyUnit> >(new PrioritizableObjectAscendingComparer <EnemyUnit>());
            mDefendingUnits      = new IntervalHeap <PrioritizableObject <EnemyUnit> >(new PrioritizableObjectAscendingComparer <EnemyUnit>());
            mAllUnits            = new List <PrioritizableObject <EnemyUnit> >();
        }
Пример #4
0
        private static Pair <Triple <CommandCenter, List <PlatformBlank>, List <Road> >, Rectangle> GetRandomStructureAtCenter(float x, float y, EaiDifficulty difficulty, ref Director director)
        {
            var rnd = new Random();

            // everything thats happening below here is to adjust the position of the taken structure to its new center.

            var index = rnd.Next(sAllStructures[difficulty].Length);

            var structure = sAllStructures[difficulty][index];

            // make sure to not take the same reference as in this sAllStructures dict. Otherwise the AI can't take the same structure more than once.
            // -> recreate every object and give that to the caller

            var tempOldPlatNewPlatMapping = new Dictionary <INode, PlatformBlank>();

            var commandCenter = (CommandCenter)PlatformFactory.Get(EStructureType.Command,
                                                                   ref director,
                                                                   structure.GetFirst().AbsolutePosition.X + x,
                                                                   structure.GetFirst().AbsolutePosition.Y + y, null, false, false);


            tempOldPlatNewPlatMapping[structure.GetFirst()] = commandCenter;

            var boundingRectangle = commandCenter.AbsBounds;

            var platformList = new List <PlatformBlank>();

            foreach (var platform in structure.GetSecond())
            {
                var platformToAdd = PlatformFactory.Get(platform.GetMyType(),
                                                        ref director,
                                                        platform.AbsolutePosition.X + x,
                                                        platform.AbsolutePosition.Y + y,
                                                        null,
                                                        false);

                boundingRectangle = UpdateRectangle(boundingRectangle, platformToAdd);

                tempOldPlatNewPlatMapping[platform] = platformToAdd;

                platformList.Add(platformToAdd);
            }

            var roadList = new List <Road>();

            foreach (var road in structure.GetThird())
            {
                var parent = road.GetParent();
                var child  = road.GetChild();

                var roadToAdd = new Road(tempOldPlatNewPlatMapping[parent], tempOldPlatNewPlatMapping[child], ref director);
                roadList.Add(roadToAdd);
            }

            return(new Pair <Triple <CommandCenter, List <PlatformBlank>, List <Road> >, Rectangle>(new Triple <CommandCenter, List <PlatformBlank>, List <Road> >(commandCenter, platformList, roadList), boundingRectangle));
        }
Пример #5
0
        public static Pair <Triple <CommandCenter, List <PlatformBlank>, List <Road> >, Rectangle> GetStructureOnMap(EaiDifficulty difficulty, ref Director director)
        {
            while (true)
            {
                var pos = Map.Map.GetRandomPositionOnMap();
                var possibleStructure = GetRandomStructureAtCenter(pos.X, pos.Y, difficulty, ref director);

                if (Map.Map.IsOnTop(possibleStructure.GetSecond()) &&
                    !director.GetStoryManager.Level.Map.IsInVision(possibleStructure.GetSecond()))
                {
                    //Only built the structure if its used afterwards!
                    possibleStructure.GetFirst().GetFirst().Built();
                    foreach (var platform in possibleStructure.GetFirst().GetSecond())
                    {
                        platform.Built();
                    }
                    return(possibleStructure);
                }
            }
        }