Ejemplo n.º 1
0
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            #region Resolution
            Resolution.Init(ref graphics);
#if WINDOWS
            Resolution.SetResolution(1280, 800, false);
            Resolution.SetVirtualResolution(1280, 800); // Don't change this anymore after this. Use SetResolution() instead.
#endif
#if XBOX
            Resolution.SetResolution(1280, 720, true);
            Resolution.SetVirtualResolution(1280, 720); // Don't change this anymore after this. Use SetResolution() instead.
#endif
            #endregion

            Engine.Instance.SpriteBatch         = spriteBatch;
            InputMgr.Instance                   = new InputMgr();
            InputMgr.Instance.Mouse             = new Mouse2("Mouse/mouse01");
            XNALib.Controls.ControlMgr.Instance = new XNALib.Controls.ControlMgr(spriteBatch);

            // Audio
            AudioMgrPooled.Instance = new AudioMgrPooled();
            AudioMgrPooled.Instance.AddSound(5, "sellBuy");
            AudioMgrPooled.Instance.AddSound(10, "buildingSelected");
            AudioMgrPooled.Instance.AddSound(10, "buildingUpgraded");
            AudioMgrPooled.Instance.AddSound(10, "mouseClick");
            AudioMgrPooled.Instance.AddSound(5, "error1");
            AudioMgrPooled.Instance.AddSound(5, "explosion01");
            AudioMgrPooled.Instance.AddSound(5, "explosion02");
            AudioMgrPooled.Instance.AddSound(5, "cannonShootFX1");

            // Settings
            SettingsMgr.Instance = new SettingsMgr();
            SettingsMgr.Instance.Load();

            // Data
            DataStructs.LoadDefenders();
            DataStructs.LoadTowers();
            DataStructs.LoadRunners();

            // Cache folder
            if (!Directory.Exists("Cache"))
            {
                Directory.CreateDirectory("Cache");
            }

            // First state
            Level.Instance = new Level();
            Level.Instance.Load("L001");
            Engine.Instance.ActiveState = Level.Instance;
        }
Ejemplo n.º 2
0
        public Level()
        {
            ControlMgr.Instance.Controls.Clear();
            WarningMessages.Instance = new WarningMessages();

            #region Buttons
            // Next Wave Button
            NextWaveButton = new Button(new Vector2(Engine.Instance.Width - 50, 50), "GUI/nextWave", "GUI/nextWaveHover", null);
            ControlMgr.Instance.Controls.Add(NextWaveButton);
            NextWaveButton.Click += new Button.OnClick(NextWaveButton_Click);

            // Menu Button
            MenuButton = new Button(Vector2.Zero, "GUI/btnMenu", "GUI/btnMenuDown", null);
            ControlMgr.Instance.Controls.Add(MenuButton);
            MenuButton.Click += new Button.OnClick(MenuButton_Click);

            //MM Button
            MMButton = new Button(new Vector2(MenuButton.AABB.Width, 0), "GUI/btnMM", "GUI/btnMMDown", null);
            ControlMgr.Instance.Controls.Add(MMButton);
            MMButton.Click += new Button.OnClick(MMButton_Click);

            // SellBtn
            SellBtn = new Button(new Vector2(Engine.Instance.Width - 150, 0), "GUI/btnRedEmpty", "GUI/btnRedEmptyHover", null)
            {
                OverlayTexture = Common.str2Tex("GUI/sell"), IsEntirelyDisabled = true
            };
            ControlMgr.Instance.Controls.Add(SellBtn);
            SellBtn.Click += new Button.OnClick(SellBtn_Click);
            #endregion

            Player = new Player();

            #region Categories
            // Tower categories
            DataStructs.LoadTowerCategories();

            #region Tower build category buttons
            Vector2 TowerCatBtnsLoc = TowerBuildBtnsLoc;
            foreach (TowerCategoryStruct tcs in DataStructs.TowerCategories)
            {
                Button newTCBtn = new Button(TowerCatBtnsLoc, "GUI/btnEmpty", "GUI/btnEmptyHover", null)
                {
                    OverlayTexture = tcs.Icon, Tag = tcs
                };
                if (tcs.TowersInThisCat.Count > 0)
                {
                    TowerCatBtnsLoc.X += 50;
                    CategoryButtons.Add(newTCBtn);
                    newTCBtn.Click += new Button.OnClick(newTCBtn_Click);
                    ControlMgr.Instance.Controls.Add(newTCBtn);
                }
            }
            #endregion
            #region Tower build tower buttons
            Vector2 towerBuildBtnsLoc = TowerBuildBtnsLoc;
            foreach (TowerStruct ts in DataStructs.Towers)
            {
                Button newTBBtn = new Button(towerBuildBtnsLoc, "GUI/btnEmpty", "GUI/btnEmptyHover", null)
                {
                    OverlayTexture = ts.Icon, Tag = ts, IsEntirelyDisabled = true
                };
                TowerBuildButtons.Add(newTBBtn);
                towerBuildBtnsLoc.X += 50;
                newTBBtn.Click      += new Button.OnClick(newTBBtn_Click);
                ControlMgr.Instance.Controls.Add(newTBBtn);
            }
            #endregion
            #endregion
        }