예제 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.IsMouseVisible = true;
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("font");
            toolTipFont = Content.Load<SpriteFont>("tooltipfont");
            gridSize = 50;
            gameTimer = 0;
            placingTower = null;
            map = new Map("normal", 100, 1);

            towerTex = Content.Load<Texture2D>("Sprites\\Eiffel");
            backTex = Content.Load<Texture2D>("Sprites\\Blank");
            Enemy e = new Enemy(100, 10f, "basic", 10, new Rectangle(50, 900, 50, 50));
            e.Map = map;
            map.setStandardEnemy(e.Clone());
            map.Enemies.Add(e);
            map.PlaceCastle(new Castle(1000000000, new Rectangle(1500, 200, 40, 40)));
            this.menu = new Interface(this.graphics, this.spriteBatch, this.font);
            this.menu.Background = backTex;
            this.menu.TowerTex = towerTex;
            this.menu.ToolTipFont = toolTipFont;

            menus = new List<Menu>();
            this.main = new Menu("Main Menu", new Point(0, 0), backTex, font, spriteBatch);
            this.main.Interface = menu;
            main.AddSubOption("Back");

            this.options = new Menu("Options", new Point(300, 0), backTex, font, spriteBatch);
            this.options.Interface = menu;
            this.options.AddSubOption("Back");

            this.difficulty = new Menu("Difficulty", new Point(300, 300), backTex, font, spriteBatch);
            this.difficulty.Interface = menu;
            this.difficulty.AddSubOption("Raise Difficulty");
            this.difficulty.AddSubOption("Lower Difficulty");

            difficulty.Map = this.map;

            this.language = new Menu("Languages", new Point(600, 0), backTex, font, spriteBatch);
            this.language.Interface = menu;
            this.language.AddSubOption("Spanish");
            this.language.AddSubOption("English");
            this.language.AddSubOption("Back");

            options.AddSubMenu(difficulty);
            options.AddSubMenu(language);
            main.AddSubMenu(options);

            menus.Add(main);
            menus.Add(options);
            menus.Add(language);
            menus.Add(difficulty);

            // TODO: use this.Content to load your game content here
        }
예제 #2
0
파일: MainGame.cs 프로젝트: mellinja/TD2
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            this.IsMouseVisible = true;
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            font = Content.Load<SpriteFont>("font");
            toolTipFont = Content.Load<SpriteFont>("tooltipfont");
            bigFont = Content.Load<SpriteFont>("bigFont");
            gridSize = 50;
            gameTimer = 0;
            placingTower = null;
            map = new Map("normal", 100, 2);

            towerTex = Content.Load<Texture2D>("Sprites\\Eiffel");
            backTex = Content.Load<Texture2D>("Sprites\\Blank");
            Enemy e = new Enemy(100, 10f, "basic", 10, new Rectangle(50, 900, 50, 50));
            e.Map = map;
            map.setStandardEnemy(e.Clone());
            map.Enemies.Add(e);
            Castle c = new Castle(1000000000, new Rectangle(1500, 200, 40, 40));
            map.PlaceCastle(c);
            this.menu = new Interface(this.graphics, this.spriteBatch, this.font);
            this.menu.Background = backTex;
            this.menu.TowerTex = towerTex;
            this.menu.ToolTipFont = toolTipFont;

            menus = new List<Menu>();
            this.main = new Menu("Main Menu", new Point(0, 0), backTex, font, spriteBatch);
            this.main.Interface = menu;
            main.AddSubOption("Resume");
            main.AddSubOption("Exit Game");

            main.Game = this;
            this.options = new Menu("Options", new Point(0, 250), backTex, font, spriteBatch);
            this.options.Interface = menu;
            this.difficulty = new Menu("Difficulty", new Point(0, 500), backTex, font, spriteBatch);
            this.difficulty.Interface = menu;
            this.difficulty.AddSubOption("Raise Difficulty");
            this.difficulty.AddSubOption("Lower Difficulty");
            this.difficulty.AddSubOption("Back");

            difficulty.Map = this.map;

            this.language = new Menu("Languages", new Point(0, 750), backTex, font, spriteBatch);
            this.language.Interface = menu;
            this.language.AddSubOption("Spanish");
            this.language.AddSubOption("English");
            this.language.AddSubOption("Back");

            options.AddSubMenu(difficulty);
            options.AddSubMenu(language);

            this.options.AddSubOption("Back");

            main.AddSubMenu(options);

            menus.Add(main);
            menus.Add(options);
            menus.Add(language);
            menus.Add(difficulty);
            Enemy e2 = e.Clone();
            //Path creation using towers
            for (int i = 0; i <= Math.Abs(e2.Location.Y - c.Location.Y) / 50; i++)
            {
                Tower t = new Tower("path",10,0,0,1,new Rectangle(50, 900 - Math.Sign(e2.Location.Y - c.Location.Y) * i * 50, 50, 50));
                map.PlaceTower(t);
            }
            for (int i = 0; i < Math.Abs(e2.Location.X - c.Location.X) / 50; i++)
            {
                Tower t = new Tower("path", 10, 0, 0, 1, new Rectangle(50 - Math.Sign(e2.Location.X - c.Location.X) * i * 50,c.Location.Y, 50, 50));
                map.PlaceTower(t);
            }

            // TODO: use this.Content to load your game content here
        }