Ejemplo n.º 1
0
        public void CreateNewBase(GameTime gametime)
        {
            if ((int)gametime.TotalGameTime.TotalMilliseconds % 10000 != 0)
            {
                return;
            }

            var structure = StructureLayoutHolder.GetStructureOnMap(mAi.Difficulty, ref mDirector);

            mAi.AddStructureToGame(structure.GetFirst(), structure.GetSecond());
        }
Ejemplo n.º 2
0
        private void StandardInitialization(ContentManager content)
        {
            //Load stuff
            var platformConeTexture  = content.Load <Texture2D>("Cones");
            var platformCylTexture   = content.Load <Texture2D>("Cylinders");
            var platformBlankTexture = content.Load <Texture2D>("PlatformBasic");
            var platformDomeTexture  = content.Load <Texture2D>("Dome");
            var mapBackground        = content.Load <Texture2D>("backgroundGrid");
            var libSans12            = content.Load <SpriteFont>("LibSans12");

            PlatformFactory.Init(platformConeTexture, platformCylTexture, platformDomeTexture, platformBlankTexture, libSans12);
            StructureLayoutHolder.Initialize(ref mDirector);

            //Map related stuff
            Camera = new Camera(mGraphics.GraphicsDevice, ref mDirector);
            mFow   = new FogOfWar(Camera, mGraphics.GraphicsDevice);

            var map = new Map.Map(mapBackground, 60, 60, mFow, Camera, ref mDirector);

            Map = map;
            var milUnitSheet  = content.Load <Texture2D>("UnitSpriteSheet");
            var milGlowSheet  = content.Load <Texture2D>("UnitGlowSprite");
            var genUnitSprite = content.Load <Texture2D>("GenUnit");

            MilitaryUnit.mMilSheet      = milUnitSheet;
            MilitaryUnit.mGlowTexture   = milGlowSheet;
            GeneralUnit.mGenUnitTexture = genUnitSprite;

            mDirector.GetMilitaryManager.SetMap(ref map);

            //INITIALIZE SCREENS
            GameScreen = new GameScreen(mGraphics.GraphicsDevice, ref mDirector, Map, Camera, mFow);
            Ui         = new UserInterfaceScreen(ref mDirector, Map, Camera, mScreenManager);
            mDirector.GetUserInterfaceController.ControlledUserInterface = Ui; // the UI needs to be added to the controller

            // the input manager keeps this from not getting collected by the GC
            mDebugscreen = new DebugScreen((StackScreenManager)mScreenManager, Camera, Map, ref mDirector);

            mDirector.GetInputManager.FlagForAddition(this);

            if (Ai != null)
            {
                GameScreen.AddObject(Ai);
            }
        }
Ejemplo n.º 3
0
        public void ReloadContent(ContentManager content, GraphicsDeviceManager graphics, ref Director director, IScreenManager screenmanager)
        {
            mScreenManager = screenmanager;
            mGraphics      = graphics;
            //Load stuff
            var platformConeTexture  = content.Load <Texture2D>("Cones");
            var platformCylTexture   = content.Load <Texture2D>("Cylinders");
            var platformBlankTexture = content.Load <Texture2D>("PlatformBasic");
            var platformDomeTexture  = content.Load <Texture2D>("Dome");

            MilitaryUnit.mMilSheet    = content.Load <Texture2D>("UnitSpriteSheet");
            MilitaryUnit.mGlowTexture = content.Load <Texture2D>("UnitGlowSprite");
            var mapBackground = content.Load <Texture2D>("backgroundGrid");
            var libSans12     = content.Load <SpriteFont>("LibSans12");

            PlatformFactory.Init(platformConeTexture, platformCylTexture, platformDomeTexture, platformBlankTexture, libSans12);
            PlatformBlank.mLibSans12 = libSans12;
            director.ReloadContent(mDirector, Map.GetMeasurements(), content, mGraphics);
            mDirector = director;

            //Map related stuff
            Camera.ReloadContent(mGraphics, ref mDirector);
            mFow.ReloadContent(mGraphics, Camera);
            Ui = new UserInterfaceScreen(ref mDirector, Map, Camera, mScreenManager);
            Ui.LoadContent(content);
            Ui.Loaded = true;
            //This has to be after ui creation, because the ui graphid dictionary is updated in the structuremap.reloadcontent method
            Map.ReloadContent(mapBackground, Camera, mFow, ref mDirector, content, Ui);
            GameScreen.ReloadContent(content, graphics, Map, mFow, Camera, ref mDirector, Ui);
            mDirector.GetUserInterfaceController.ReloadContent(ref mDirector);
            mDirector.GetUserInterfaceController.ControlledUserInterface = Ui; // the UI needs to be added to the controller

            // Reload map for the military manager
            var map = Map;

            director.GetMilitaryManager.ReloadSetMap(ref map);
            // the input manager keeps this from not getting collected by the GC
            mDebugscreen = new DebugScreen((StackScreenManager)mScreenManager, Camera, Map, ref mDirector);
            mDirector.GetInputManager.FlagForAddition(this);

            //AI Stuff
            Ai?.ReloadContent(ref mDirector);
            StructureLayoutHolder.Initialize(ref mDirector);
        }
Ejemplo n.º 4
0
        public void CreateNewBase(GameTime gametime)
        {
            if (mBaseCount > 0 && !mActive)
            {
                // don't build any further bases when the AI isn't active.
                return;
            }

            if (!(mDirector.GetMilitaryManager.PlayerPlatformCount > PlatformCountNewBaseTrigger * mBaseCount ||
                  mDirector.GetMilitaryManager.PlayerDefensePlatformCount > DefensePlatformCountNewBaseTrigger * mBaseCount))
            {
                return;
            }

            var requestNewPlatform = false;

            Pair <Triple <CommandCenter, List <PlatformBlank>, List <Road> >, Rectangle> baseToAdd;

            do
            {
                baseToAdd = StructureLayoutHolder.GetStructureOnMap(mAi.Difficulty, ref mDirector);

                // make sure the base is atleast a certain distance away from the player at start
                if (Vector2.Distance(
                        mDirector.GetStoryManager.StructureMap.GetPlatformList().First().AbsolutePosition,
                        new Vector2(baseToAdd.GetSecond().Center.X, baseToAdd.GetSecond().Center.Y)) < FirstBaseDistance)
                {
                    requestNewPlatform = true;
                    continue;
                }

                // make sure the new structure doesn't overlap with an existing enemy structure
                if (mBaseCount <= 0)
                {
                    break;
                }

                foreach (var rect in mCollidingRects)
                {
                    if (!rect.Intersects(baseToAdd.GetSecond()))
                    {
                        continue;
                    }

                    requestNewPlatform = true;
                    break;
                }
            } while (requestNewPlatform);

            mAi.AddStructureToGame(baseToAdd.GetFirst(), baseToAdd.GetSecond());

            mCollidingRects.Add(baseToAdd.GetSecond());

            var spawners = mAi.GetSpawners();

            if (spawners.Count <= mBaseCount || spawners[mBaseCount].Count <= 0)
            {
                // we don't have any spawners available in the given structure thus not able to spawn any enemy units.
                mBaseCount++;
                return;
            }

            SpawnOneUnit(EEnemyType.Scout, mAi.GetSpawners()[mBaseCount][0]);

            // also generate some defending units, note that these don't move away from their base, but are more or less stationary defenders.
            SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]);
            SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]);
            SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]);
            SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]);
            SpawnOneUnit(EEnemyType.Defend, mAi.GetSpawners()[mBaseCount][0]);

            mBaseCount++;
        }