Esempio n. 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()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            Texture2D grass  = Content.Load <Texture2D>("Block/grass");  //0
            Texture2D path   = Content.Load <Texture2D>("Block/path");   //1
            Texture2D pathLT = Content.Load <Texture2D>("Block/pathLT"); //2
            Texture2D pathT  = Content.Load <Texture2D>("Block/pathT");  //3
            Texture2D pathRT = Content.Load <Texture2D>("Block/pathRT"); //4
            Texture2D pathL  = Content.Load <Texture2D>("Block/pathL");  //5
            Texture2D pathR  = Content.Load <Texture2D>("Block/pathR");  //6
            Texture2D pathLD = Content.Load <Texture2D>("Block/pathLD"); //7
            Texture2D pathD  = Content.Load <Texture2D>("Block/pathD");  //8
            Texture2D pathRD = Content.Load <Texture2D>("Block/pathRD"); //9

            level.AddTexture(grass);                                     // Add Block GPU
            level.AddTexture(path);
            level.AddTexture(pathLT);
            level.AddTexture(pathT);
            level.AddTexture(pathRT);
            level.AddTexture(pathL);
            level.AddTexture(pathR);
            level.AddTexture(pathLD);
            level.AddTexture(pathD);
            level.AddTexture(pathRD);
            //Texture2D back = Content.Load<Texture2D>("Block/background");
            //background.AddTexture(back);
            Texture2D[] enemyTexture = new Texture2D[]
            {
                Content.Load <Texture2D>("Enemy/Elf1"),
                Content.Load <Texture2D>("Enemy/Elf2"),
                Content.Load <Texture2D>("Enemy/Elf3"),
                Content.Load <Texture2D>("Enemy/Elf4"),
                Content.Load <Texture2D>("Enemy/Elf5")
            };
            //enemy1 = new Enemy(enemyTexture, Vector2.Zero, 100, 10, 1f);// change speed;
            //enemy1.SetWaypoints(level.Waypoints);


            Texture2D[] towerTextures = new Texture2D[]
            {
                Content.Load <Texture2D>("Tower/tower"),
                Content.Load <Texture2D>("Tower/Slow"),
                Content.Load <Texture2D>("Tower/Snipe")
            };
            Texture2D bulletTexture = Content.Load <Texture2D>("Tower/bullet");

            player = new Player(level, towerTextures, bulletTexture);
            Texture2D healthTexture = Content.Load <Texture2D>("HP");

            waveManeger = new WaveManeger(player, level, 16, enemyTexture, healthTexture);// set wave
            Texture2D  topBar = Content.Load <Texture2D>("toolbar");
            SpriteFont font   = Content.Load <SpriteFont>("Arial");

            toolBar = new Toolbar(topBar, font, new Vector2(0, level.Height * 50));

            // The "Normal" texture for the arrow button.
            Texture2D arrowNormal = Content.Load <Texture2D>("Tower/tower");
            // The "MouseOver" texture for the arrow button.
            Texture2D arrowHover = Content.Load <Texture2D>("Tower/tower");
            // The "Pressed" texture for the arrow button.
            Texture2D arrowPressed = Content.Load <Texture2D>("Tower/tower");
            // The "Normal" texture for the spike button.
            Texture2D slowNormal = Content.Load <Texture2D>("Tower/Slow");
            // The "MouseOver" texture for the spike button.
            Texture2D slowHover = Content.Load <Texture2D>("Tower/Slow");
            // The "Pressed" texture for the spike button.
            Texture2D  slowPressed  = Content.Load <Texture2D>("Tower/Slow");
            Texture2D  snipeNormal  = Content.Load <Texture2D>("Tower/Snipe");
            Texture2D  snipeHover   = Content.Load <Texture2D>("Tower/Snipe");
            Texture2D  snipePressed = Content.Load <Texture2D>("Tower/Snipe");
            SpriteFont font2        = Content.Load <SpriteFont>("Descrip");

            // Initialize the arrow button.
            arrowButton          = new Button(arrowNormal, arrowHover, arrowPressed, new Vector2(40, level.Height * 50 + 20), font2);
            arrowButton.Clicked += new EventHandler(arrowButton_Clicked);
            // Initialize the spike button.
            slowButton          = new Button(slowNormal, slowHover, slowPressed, new Vector2(120, level.Height * 50 + 20), font2);
            slowButton.Clicked += new EventHandler(slowButton_Clicked);

            snipeButton          = new Button(snipeNormal, snipeHover, snipePressed, new Vector2(200, level.Height * 50 + 20), font2);
            snipeButton.Clicked += new EventHandler(snipeButton_Clicked);

            arrowButton.OnPress += new EventHandler(arrowButton_OnPress);
            slowButton.OnPress  += new EventHandler(slowButton_OnPress);
            snipeButton.OnPress += new EventHandler(snipeButton_OnPress);
        }