Esempio n. 1
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                Window.AllowUserResizing = true;
                //graphics.CreateDevice();
                graphics.PreferredBackBufferHeight = 704;
                graphics.PreferredBackBufferWidth = 1024;
                graphics.IsFullScreen = false;
             //   graphics.ToggleFullScreen();
                graphics.ApplyChanges();
            }
            catch
            {
            }
            // Create a new SpriteBatch, which can be used to draw textures.
            ClickTimer = 0;
            groupedUnits = new Dictionary<Keys, List<GameObject>>();
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // TODO: Add your initialization logic here
            defeatScreen = new Map("Content/defeatScreen.txt");
            mainScreen = new Map("Content/MainScreen.txt");
            levelSelect = new Map("Content/levelSelect.txt");
            castleDefense = new Map("Content/castleDefense.txt");
            riverDefense = new Map("Content/riverDefense.txt");
            castleSiege = new Map("Content/castleSiege.txt");
            victoryScreen = new Map("Content/victoryScreen.txt");
            mainScreenSelector = new Selector(new Rectangle(448, 0, 128, 64), mainScreen, levelSelect, true);
            castleDefenseSelector = new Selector(new Rectangle(96, 320, 192, 96), levelSelect, castleDefense, false);
            riverDefenseSelector = new Selector(new Rectangle(416, 320, 192, 96), levelSelect, riverDefense, false);
            castleSiegeSelector = new Selector(new Rectangle(736, 320, 192, 96), levelSelect, castleSiege, false);
            defeatScreenSelector = new Selector(new Rectangle(448, 256, 128, 64), defeatScreen, mainScreen, false);
            victoryScreenSelector = new Selector(new Rectangle(448, 288, 128, 64), victoryScreen, mainScreen, false);
            modMan = ModelManager.getInstance(ref mainScreen);
            loadMan = LoadManager.getInstance();
            projMan = ProjectileManager.getInstance();
            screenManager = ScreenManager.getInstance();
            // Add all maps to screenManager.allMaps
            screenManager.allMaps.Add(defeatScreen);
            screenManager.allMaps.Add(mainScreen);
            screenManager.allMaps.Add(levelSelect);
            screenManager.allMaps.Add(castleDefense);
            screenManager.allMaps.Add(riverDefense);
            screenManager.allMaps.Add(castleSiege);
            screenManager.allMaps.Add(victoryScreen);
            // Add all selectors to screenManager.allSelectors
            screenManager.allSelectors.Add(defeatScreenSelector);
            screenManager.allSelectors.Add(mainScreenSelector);
            screenManager.allSelectors.Add(castleDefenseSelector);
            screenManager.allSelectors.Add(riverDefenseSelector);
            screenManager.allSelectors.Add(castleSiegeSelector);
            screenManager.allSelectors.Add(victoryScreenSelector);
            // Set initial maps; These will always be defeatScreen, mainScreen and levelSelect,
            // since the user spawns on mainScreen
            screenManager.prevMap = defeatScreen;
            screenManager.currentMap = mainScreen;
            screenManager.nextMap = levelSelect;
            healthChecker = new HealthSystem(ModelManager.player, ModelManager.artificial);
            attackChecker = new AttackSystem(ref ModelManager.player, ref ModelManager.artificial);
            attackChecker.linkSystem(projMan);
            attackChecker.linkContent(Content);
            movementManager = MovementManager.getInstance();
            movementManager.setMap(mainScreen);
            inputManager = new InputManager(ref modMan);
            aiManager = AIManager.getInstance(ref mainScreen);
            mBar = new MoraleBar(ref modMan);
            gui = new GUIButtons(ref modMan);
            info = new InfoCard(ref modMan);
            inputManager.linkGUI(gui);
            MoraleBar.resourceVal(buildResources);
            mousePrev = Mouse.GetState();
            //Create Player's units
            //testInitialization();
           


            testCommander();
            base.Initialize();
            this.IsMouseVisible = true;
           
           
        }
Esempio n. 2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            try
            {
                Window.AllowUserResizing = true;
                //graphics.CreateDevice();
                graphics.PreferredBackBufferHeight = 704;
                graphics.PreferredBackBufferWidth  = 1024;
                graphics.IsFullScreen = false;
                //   graphics.ToggleFullScreen();
                graphics.ApplyChanges();
            }
            catch
            {
            }
            // Create a new SpriteBatch, which can be used to draw textures.
            ClickTimer   = 0;
            groupedUnits = new Dictionary <Keys, List <GameObject> >();
            spriteBatch  = new SpriteBatch(GraphicsDevice);
            // TODO: Add your initialization logic here
            defeatScreen          = new Map("Content/defeatScreen.txt");
            mainScreen            = new Map("Content/MainScreen.txt");
            levelSelect           = new Map("Content/levelSelect.txt");
            castleDefense         = new Map("Content/castleDefense.txt");
            riverDefense          = new Map("Content/riverDefense.txt");
            castleSiege           = new Map("Content/castleSiege.txt");
            victoryScreen         = new Map("Content/victoryScreen.txt");
            mainScreenSelector    = new Selector(new Rectangle(448, 0, 128, 64), mainScreen, levelSelect, true);
            castleDefenseSelector = new Selector(new Rectangle(96, 320, 192, 96), levelSelect, castleDefense, false);
            riverDefenseSelector  = new Selector(new Rectangle(416, 320, 192, 96), levelSelect, riverDefense, false);
            castleSiegeSelector   = new Selector(new Rectangle(736, 320, 192, 96), levelSelect, castleSiege, false);
            defeatScreenSelector  = new Selector(new Rectangle(448, 256, 128, 64), defeatScreen, mainScreen, false);
            victoryScreenSelector = new Selector(new Rectangle(448, 288, 128, 64), victoryScreen, mainScreen, false);
            modMan        = ModelManager.getInstance(ref mainScreen);
            loadMan       = LoadManager.getInstance();
            projMan       = ProjectileManager.getInstance();
            screenManager = ScreenManager.getInstance();
            // Add all maps to screenManager.allMaps
            screenManager.allMaps.Add(defeatScreen);
            screenManager.allMaps.Add(mainScreen);
            screenManager.allMaps.Add(levelSelect);
            screenManager.allMaps.Add(castleDefense);
            screenManager.allMaps.Add(riverDefense);
            screenManager.allMaps.Add(castleSiege);
            screenManager.allMaps.Add(victoryScreen);
            // Add all selectors to screenManager.allSelectors
            screenManager.allSelectors.Add(defeatScreenSelector);
            screenManager.allSelectors.Add(mainScreenSelector);
            screenManager.allSelectors.Add(castleDefenseSelector);
            screenManager.allSelectors.Add(riverDefenseSelector);
            screenManager.allSelectors.Add(castleSiegeSelector);
            screenManager.allSelectors.Add(victoryScreenSelector);
            // Set initial maps; These will always be defeatScreen, mainScreen and levelSelect,
            // since the user spawns on mainScreen
            screenManager.prevMap    = defeatScreen;
            screenManager.currentMap = mainScreen;
            screenManager.nextMap    = levelSelect;
            healthChecker            = new HealthSystem(ModelManager.player, ModelManager.artificial);
            attackChecker            = new AttackSystem(ref ModelManager.player, ref ModelManager.artificial);
            attackChecker.linkSystem(projMan);
            attackChecker.linkContent(Content);
            movementManager = MovementManager.getInstance();
            movementManager.setMap(mainScreen);
            inputManager = new InputManager(ref modMan);
            aiManager    = AIManager.getInstance(ref mainScreen);
            mBar         = new MoraleBar(ref modMan);
            gui          = new GUIButtons(ref modMan);
            info         = new InfoCard(ref modMan);
            inputManager.linkGUI(gui);
            MoraleBar.resourceVal(buildResources);
            mousePrev = Mouse.GetState();
            //Create Player's units
            //testInitialization();



            testCommander();
            base.Initialize();
            this.IsMouseVisible = true;
        }