protected override void RenderMap()
        {
            // first render the floor for all the rooms
            List <Region> rooms = Map.GetRegions().Where(r => r is Room).ToList();

            foreach (Room room in rooms)
            {
                if (room is SquareRoom)
                {
                    // first calculate the floor size we need
                    SquareRoom sroom             = room as SquareRoom;
                    int        maxPossibleWidth  = sroom.Width;
                    int        maxPossibleHeight = sroom.Height;
                    int        areaToCover       = sroom.Width * sroom.Height;
                    Vector3    floorPlacement    = new Vector3(sroom.X, 0, sroom.Y);

                    FloorComponent floor = Floors.Where(f => f.WidthInTiles == sroom.Width && f.DepthInTiles == sroom.Height).FirstOrDefault();

                    if (floor == null)
                    {
                        throw new Exception("We failed to find a floor for the room " + sroom.Width + " X " + sroom.Height);
                    }

                    FloorComponent renderedComponent = Instantiate(floor, floorPlacement, Quaternion.identity);
                    MapRender.Add(renderedComponent.gameObject);
                }
                else
                {
                    throw new NotImplementedException("We don't know how to render " + room.GetType());
                }
            }
        }
Пример #2
0
        protected override void RenderMap()
        {
            for (int x = 0; x < Map.MapSize.x; x++)
            {
                for (int y = 0; y < Map.MapSize.y; y++)
                {
                    Tile    tile   = Map.GetTile(x, y);
                    Vector3 mapLoc = ConvertMapToScreen(new Vector3(x, tile.Z, y));

                    if (tile.IsFloor())
                    {
                        GameObject floor = Instantiate(FloorTile, mapLoc, Quaternion.identity);
                        floor.layer = 8; // render to minimap
                        MapRender.Add(floor);
                        if (CeilingTile != null)
                        {
                            MapRender.Add(Instantiate(CeilingTile, mapLoc + Vector3.up * 4, Quaternion.identity));
                        }
                    }
                    else if (tile.IsWall())
                    {
                        GameObject firstWall = Instantiate(WallTile, mapLoc + Vector3.up, Quaternion.identity);
                        firstWall.layer = 8; // render to minimap
                        MapRender.Add(firstWall);
                    }
                    else if (tile.Type == ETileType.DOOR)
                    {
                        GameObject door = Instantiate(CeilingTile, mapLoc, Quaternion.identity);
                        door.layer = 8; // render to minimap
                        MapRender.Add(door);
                        if (CeilingTile != null)
                        {
                            MapRender.Add(Instantiate(CeilingTile, mapLoc + Vector3.up * 4, Quaternion.identity));
                        }
                    }

                    if (tile.DebugMark)
                    {
                        MapRender.Add(Instantiate(MarkerTile, mapLoc, Quaternion.identity));
                    }

                    PlacePlayer();
                }
            }
        }