Beispiel #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);
            SpriteFont  = Content.Load <SpriteFont>("font");

            shotManager = new ShotManager(StaticMap);

            tankTextures = new Texture2D[5];

            tankTextures[0] = Content.Load <Texture2D>("tank_blue");
            tankTextures[1] = Content.Load <Texture2D>("tank_red");
            tankTextures[2] = Content.Load <Texture2D>("tank_green");
            tankTextures[3] = Content.Load <Texture2D>("tank_dark");
            tankTextures[4] = Content.Load <Texture2D>("tank_sand");

            backgroundTextures    = new Texture2D[2];
            backgroundTextures[0] = Content.Load <Texture2D>("tileGrass1");
            backgroundTextures[1] = Content.Load <Texture2D>("tileGrass2");

            sandTexture    = Content.Load <Texture2D>("tileSand1");
            sandBagTexture = Content.Load <Texture2D>("barricadeWood");
            fenceTexture   = Content.Load <Texture2D>("fenceYellow");

            StaticMap = new StaticMap(sandTexture, sandBagTexture, fenceTexture);

            StaticMap.AddRectangle(300, 100, 50, 150);
            StaticMap.AddRectangle(300, 250, 200, 200);
            StaticMap.AddRectangle(900, 150, 50, 350);
            StaticMap.AddRectangle(200, 580, 300, 40);
            StaticMap.AddRectangle(700, 580, 300, 40);
            StaticMap.AddRectangle(250, 700, 50, 350);
            StaticMap.AddRectangle(700, 750, 200, 200);
            StaticMap.AddRectangle(850, 950, 50, 150);

            StaticMap.GetNodes();

            //bot1 = new Bot(1, new Vector2(150, 600), StaticMap);
            bot1 = new Bot(Team.Blue, new Vector2(10, 10), StaticMap, shotManager, tankTextures[0]);
            bot2 = new Bot(Team.Red, new Vector2(600, 600), StaticMap, shotManager, tankTextures[1]);

            bot2.Enemy = bot1;
            bot1.Enemy = bot2;

            bot1.SetState(new Wander());
            bot2.SetState(new Seek());

            allBots.Add(bot1);
            allBots.Add(bot2);
            selectedBot = allBots[0];

            toggleActions.Add(new ToggleAction(Keys.N, DrawAllPaths));
            toggleActions.Add(new ToggleAction(Keys.M, DrawAllNodes));

            backgroundMap = CreateBackgroundTextureMap();

            //shotManager.AddShot(bot1.GetPosition(), bot2.GetPosition());
        }
Beispiel #2
0
        public Bot(Team team, Vector2 position, StaticMap map, ShotManager sManager, Texture2D texture)
        {
            teamColour = team == Team.Red ? Color.Red : Color.Aqua;

            circle       = new Circle(position, 5f, teamColour);
            random       = new Random();
            Team         = team;
            fireCooldown = 0;
            health       = 100;
            respawnTimer = 1;

            target = new Vector2(random.Next(200, 1000), random.Next(200, 1000));

            staticMap    = map;
            shotManager  = sManager;
            this.texture = texture;
        }