コード例 #1
0
ファイル: TileList.cs プロジェクト: sbkn/isometric_mono
        public TileList(Gmap gamemap, Unit ghost)
        {
            EntityList = new List<DepthSortedEntity>();

            DepthSortedEntity tmp = null;

            /*	Get the tiles (DIAMOND SHAPE !):	*/
            for (int i = 0; i < gamemap.height; i++)
            {
                for (int j = 0; j < i+1; j++)
                {
                    tmp = new DepthSortedEntity( j, i-j, gamemap.getHeight(j, i-j), gamemap.tileType(j, i-j), 0F );
                    EntityList.Add(tmp);
                }
            }
            for (int i = 1; i < gamemap.height+1; i++)
            {
                for (int j = 0; j < gamemap.width-i; j++)
                {
                    tmp = new DepthSortedEntity(i + j, gamemap.width - j - 1, gamemap.getHeight(i + j, gamemap.width - j - 1), gamemap.tileType(i + j, gamemap.width - j - 1), 0F);
                    EntityList.Add(tmp);
                }
            }

            /*	Add the ghost (HIS INDEX IS 7 FROM NOW ON !!!!):	*/
            tmp = new DepthSortedEntity(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix, gamemap.getHeight(ghost.pos.PosXMatrix, ghost.pos.PosYMatrix), 7, 0F);
            EntityList.Add(tmp);

            this.SortList();
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: sbkn/isometric_js
        /// <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 );
        }