Exemple #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);

            /*	LOAD THE FONT:	*/
            font = Content.Load <SpriteFont>(@"8bit_font");

            /*	CREATE GRID:	*/
            grid = new Sprite(Content.Load <Texture2D>("iso_grid_spooky"), 0, 0, 64, 64, 1, false);
            grid.set_pos_x(0);
            grid.set_pos_y(0);

            /*	CREATE OBSTACLE:	*/
            obstacle = new Sprite(Content.Load <Texture2D>("iso_obstacle_spooky_box_closed"), 0, 0, 64, 96, 1, false);
            obstacle.set_pos_x(0);
            obstacle.set_pos_y(0);

            /*	CREATE OBSTACLE BLUEPRINT:	*/
            obstacle_blueprint = new Sprite(Content.Load <Texture2D>("iso_obstacle_spooky_box_closed_blueprint"), 0, 0, 64, 96, 1, false);
            obstacle_blueprint.set_pos_x(0);
            obstacle_blueprint.set_pos_y(0);

            /*	CREATE GHOST:	*/
            ghost = new Unit();
            //ghost.movement_speed_x = -1;
            //ghost.movement_speed_y = 1;
            ghost.calc_pos_px(0, 0, TILE_WIDTH, TILE_HEIGHT);
            ghost.route.start  = new Node(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix);
            ghost.route.finish = new Node(15, 14);
            Astar       astarGhost = new Astar(ghost.route, _gamemap);
            ThreadStart TAstar     = new ThreadStart(astarGhost.find_path);
            Thread      thread     = new Thread(TAstar);

            thread.Start();
            //pathfinder.find_path(ghost.route, gamemap);
            if (ghost.route.routeActive)
            {
                ghost.calc_dest_pos_px(ghost.route.Steps[0].pos_x, ghost.route.Steps[0].pos_y, TILE_WIDTH, TILE_HEIGHT);
                ghost.route.Steps.RemoveAt(0);
            }
            //ghost.pos.calc_pos_matrix(0, 512, TILE_WIDTH, TILE_HEIGHT);
            ghost.Texture = new Sprite(Content.Load <Texture2D>("ghost_2"), 0, 0, 64, 64, 6, true);

            /*	CREATE HIGHLIGHTED GRID:	*/
            highlighted_grid = new Sprite(Content.Load <Texture2D>("iso_highlighted_grid"), 0, 0, 64, 32, 0, false);
            highlighted_grid.set_pos_x(0);
            highlighted_grid.set_pos_y(0);


            _sfxBuildObstacle = Content.Load <SoundEffect>("build_obstacle");

            /*	INIT THE LIST:	*/
            _theList = new TileList(_gamemap, ghost);
        }
Exemple #2
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);

            /*	LOAD THE FONT:	*/
            font = Content.Load<SpriteFont>(@"8bit_font");

            /*	CREATE GRID:	*/
            grid = new Sprite(Content.Load<Texture2D>("iso_grid_spooky"), 0, 0, 64, 64, 1, false);
            grid.set_pos_x(0);
            grid.set_pos_y(0);

            /*	CREATE OBSTACLE:	*/
            obstacle = new Sprite(Content.Load<Texture2D>("iso_obstacle_spooky_box_closed"), 0, 0, 64, 96, 1, false);
            obstacle.set_pos_x(0);
            obstacle.set_pos_y(0);

            /*	CREATE OBSTACLE BLUEPRINT:	*/
            obstacle_blueprint = new Sprite(Content.Load<Texture2D>("iso_obstacle_spooky_box_closed_blueprint"), 0, 0, 64, 96, 1, false);
            obstacle_blueprint.set_pos_x(0);
            obstacle_blueprint.set_pos_y(0);

            /*	CREATE GHOST:	*/
            ghost = new Unit();
            //ghost.movement_speed_x = -1;
            //ghost.movement_speed_y = 1;
            ghost.calc_pos_px(0, 0, TILE_WIDTH, TILE_HEIGHT);
            ghost.route.start = new Node(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix);
            ghost.route.finish = new Node(15, 14);
            Astar astarGhost = new Astar(ghost.route, _gamemap);
            ThreadStart TAstar = new ThreadStart(astarGhost.find_path);
            Thread thread = new Thread(TAstar);
            thread.Start();
            //pathfinder.find_path(ghost.route, gamemap);
            if (ghost.route.routeActive)
            {
                ghost.calc_dest_pos_px(ghost.route.Steps[0].pos_x, ghost.route.Steps[0].pos_y, TILE_WIDTH, TILE_HEIGHT);
                ghost.route.Steps.RemoveAt(0);
            }
            //ghost.pos.calc_pos_matrix(0, 512, TILE_WIDTH, TILE_HEIGHT);
            ghost.Texture = new Sprite(Content.Load<Texture2D>("ghost_2"), 0, 0, 64, 64, 6, true);

            /*	CREATE HIGHLIGHTED GRID:	*/
            highlighted_grid = new Sprite(Content.Load<Texture2D>("iso_highlighted_grid"), 0, 0, 64, 32, 0, false);
            highlighted_grid.set_pos_x(0);
            highlighted_grid.set_pos_y(0);

            _sfxBuildObstacle = Content.Load<SoundEffect>("build_obstacle");

            /*	INIT THE LIST:	*/
            _theList = new TileList( _gamemap, ghost );
        }