Exemple #1
0
 public A_Star(TileInfo[,] ColMap, int _hWeight)
 {
     hWeight = _hWeight;
     colMap = ColMap;
     Path = new List<Vector2>();
     Width = colMap.GetLength(0);
     Height = colMap.GetLength(1);
 }
Exemple #2
0
    public DungeonRoom(int _roomType, int _widthMin, int _widthMax, int _heightMin, int _heightMax)
    {
        roomType = _roomType;

        var tmpW = Random.Range(_widthMin, _widthMax);
        var tmpH = Random.Range(_heightMin, _heightMax);
        room = new Rect(0, 0, tmpW, tmpH);

        roomArray = new TileInfo[(int)room.width, (int)room.height];
    }
 public AreaInfo(int templateHash, Location loc)
 {
     this.templateHash = templateHash;
     discovered        = false;
     this.loc          = loc;
     map                    = new TileInfo[32, 32];
     entranceDic            = new Dictionary <Location, Location>();
     creatureSetHashDic     = new Dictionary <Location, int>();
     creatureSetRotTimesDic = new Dictionary <Location, int>();
     chests                 = new List <ChestEntity>();
 }
Exemple #4
0
 void GenerateTileData(int sizeX, int sizeY)
 {
     _tileProperties = new TileInfo[sizeY, sizeX];
     for (int y = 0; y < sizeY; y++)
     {
         for (int x = 0; x < sizeX; x++)
         {
             _tileProperties[y, x] = new TileInfo(new Vector2DInt(x, y), "empty", 0.0f);                 // set all tiles to start as deathtiles and set position according to coords
         }
     }
 }
        protected override void Awake()
        {
            base.Awake();

            m_logger = new Logger(this);

            m_tileInfos = new TileInfo[TileSpan, TileSpan];

            m_currMinX = -1;
            m_currMinY = -1;
        }
    ///*********


    void setObjectTileXY(int game, ref TileInfo[,] LevelInfo, ref ObjectInfo[] objList)
    {            //Justs some useful info to know.
        //ObjectItem currObj;
        for (short x = 0; x < 64; x++)
        {
            for (short y = 0; y < 64; y++)
            {
                if (LevelInfo[x, y].indexObjectList != 0)
                {
                    long nextObj = LevelInfo[x, y].indexObjectList;
                    while (nextObj != 0)
                    {
                        objList[nextObj].tileX     = x;
                        objList[nextObj].tileY     = y;
                        objList[nextObj].InUseFlag = 1;
                        if ((isContainer(objList[nextObj])) || (objectMasters[objList[nextObj].item_id].type == NPC_TYPE))
                        {
                            SetContainerInUse(game, ref LevelInfo, ref objList, objList[nextObj].index);
                        }
                        else if (objectMasters[objList[nextObj].item_id].type == A_CREATE_OBJECT_TRAP)
                        {
                            if (objList[nextObj].InUseFlag == 0)
                            {
                                objList[nextObj].tileX     = x;
                                objList[nextObj].tileY     = y;
                                objList[nextObj].InUseFlag = 1;
                            }
                            if (
                                (objectMasters[objList[objList[nextObj].link].item_id].type == NPC_TYPE)
                                &&
                                (objList[objList[nextObj].link].InUseFlag == 0)
                                )
                            {
                                SetContainerInUse(game, ref LevelInfo, ref objList, objList[objList[nextObj].link].index);
                            }
                        }

                        nextObj = objList[nextObj].next;
                    }
                }
            }

            for (int i = 0; i < 1024; i++)
            {                    //Make sure triggers and traps are created.
                if (objList[i].InUseFlag == 0)
                {
                    if ((isTrigger(objList[i])) || (isTrap(objList[i])))
                    {
                        objList[i].InUseFlag = 1;
                    }
                }
            }
        }
    }
Exemple #7
0
    /// <summary>
    /// NOTE : 방의 사이즈 랜덤 설정 생성자
    /// </summary>
    /// <param name="_roomNumber"></param>
    /// <param name="_roomSpriteType"></param>
    /// <param name="_widthMin"></param>
    /// <param name="_widthMax"></param>
    /// <param name="_heightMin"></param>
    /// <param name="_heightMax"></param>
    public DungeonRoom(int _roomNumber, int _roomSpriteType, int _widthMin, int _widthMax, int _heightMin, int _heightMax)
    {
        roomNumberOfList = _roomNumber;
        roomSpriteType   = _roomSpriteType;

        var tmpW = Random.Range(_widthMin, _widthMax);
        var tmpH = Random.Range(_heightMin, _heightMax);

        roomRect = new Rect(0, 0, tmpW, tmpH);

        roomTileArray = new TileInfo[(int)roomRect.width, (int)roomRect.height];
    }
Exemple #8
0
    // Start is called before the first frame update
    void Start()
    {
        mainCam = Camera.main;

        mainCam.GetComponent <CameraController>().CamBounds = new Vector3(WorldSize, WorldSize, 0);
        Tiles = new TileInfo[WorldSize, WorldSize];
        CreateGrid();

        CreateExternalConnection(new Vector3(-1, 4, 0), Vector3.left, 10);

        populationManager = GetComponent <PopulationManager>();
    }
Exemple #9
0
    public ChunkInfo(Vector2 chunkPos, GameObject chunkObj)
    {
        ChunkPos    = chunkPos;
        ChunkObject = chunkObj;

        m_data     = new TileInfo[Height, Width];
        m_entities = new List <Entity> [Height, Width];

        for (int i = 0; i < Enum.GetNames(typeof(Direction)).Length; i++)
        {
            m_neighbors.Add(null);
        }
    }
 private void Setup(int tileSize)
 {
     this.tileSize   = tileSize;
     tileBasedWidth  = this.Width / tileSize;
     tileBasedHeight = this.Height / tileSize;
     this.tiles      = new TileInfo[tileBasedWidth, tileBasedHeight];
     for (int x = 0; x < tileBasedWidth; x++)
     {
         for (int y = 0; y < tileBasedHeight; y++)
         {
             this.tiles[x, y] = null;
         }
     }
 }
 void SetBullFrog(ref TileInfo[,] LevelInfo, ref ObjectInfo[] objList, int LevelNo)
 {
     //Special UW1 case
     if (LevelNo == 3)
     {
         for (int x = 48; x < 56; x++)
         {
             for (int y = 48; y < 56; y++)
             {
                 LevelInfo[x, y].BullFrog = 1;
             }
         }
     }
 }
Exemple #12
0
    void SetMatrix()
    {
        //tileMap.animationFrameRate = 0;

        // SET THE MATRIX
        mapBounds = tileMap.cellBounds;
        mapMatrix = new TileInfo[mapBounds.size.x, mapBounds.size.y];
        TileBase[] allTiles = tileMap.GetTilesBlock(mapBounds);


        // Recupere les tiles et creer la matrice
        for (int x = 0; x < mapBounds.size.x; x++)
        {
            for (int y = 0; y < mapBounds.size.y; y++)

                TileBase tile = tileMap.GetTile<TileBase>(new Vector3Int(x,y,0));
                //TileBase tile = allTiles[x + y * mapBounds.size.x];
                if (tile != null)
                {
                    AnimatedTile animTile = tileMap.GetTile<AnimatedTile>(new Vector3Int(x, y, 0));
                    TileType tileType;
                    if (animTile != null && animTile.name.StartsWith("Path"))
                    {
                        tileType = TileType.Path;
                    }
                    else if (tileUnusableName.Contains(tile.name))
                    {
                        tileType = TileType.Unusable;
                    }
                    else
                    {
                        tileType = TileType.Ground;
                    }
                    mapMatrix[x, y] = new TileInfo(animTile, tileType, true);
                    if (animTile != null)
                    {
                        if (!(animTileAlreadySee.ContainsKey(animTile.name)))
                        {
                            animTilesVector3.Add(new Vector3Int(x, y, 0));
                            animTileAlreadySee.Add(animTile.name, true);
                        }
                        animTile.m_SpriteIndex = 0;
                    }
                }
                else
                {
                    mapMatrix[x, y] = new TileInfo(null, TileType.Unusable, true);
                }
            }
        }
Exemple #13
0
        public void Init()
        {
            //50每格子
            Width     = Height = 30;
            tileArray = new TileInfo[Width, Height];
            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    if ((i + j) % 5 == 1)
                    {
                        tileArray[i, j] = new TileInfo {
                            CId = 3
                        }
                    }
                    ;
                    else
                    {
                        tileArray[i, j] = new TileInfo {
                            CId = 4
                        }
                    };
                }
            }

            MapPixelWidth  = CellSize * Width;
            MapPixelHeight = CellSize * Height;
            cachedMap      = new Bitmap(MapPixelWidth, MapPixelHeight);
            Graphics g = Graphics.FromImage(cachedMap);

            for (int i = 0; i < Width; i++)
            {
                for (int j = 0; j < Height; j++)
                {
                    Rectangle destRect = new Rectangle(CellSize * i, CellSize * j, CellSize, CellSize);

                    var tileImg = TileBook.GetTileImage(tileArray[i, j].CId, CellSize, CellSize);
                    g.DrawImage(tileImg, destRect, 0, 0, CellSize, CellSize, GraphicsUnit.Pixel);
                }
            }

            Pen myPen = new Pen(Brushes.DarkGoldenrod, 6); //描一个金边

            g.DrawRectangle(myPen, 0 + 3, 0 + 3, MapPixelWidth - 6, MapPixelHeight - 6);
            myPen.Dispose();
            g.DrawRectangle(Pens.DarkRed, 0 + 5, 0 + 5, MapPixelWidth - 10, MapPixelHeight - 10);

            g.Dispose();
        }
Exemple #14
0
 public void Refresh()
 {
     if (!isFlooded)
     {
         TileInfo[,] terrainInfo = manager.GetTerrainInfo();
         foreach (Vector3Int neighbourLocation in GetNeighboursCoordinates())
         {
             if (ShallFlood())
             {
                 SetIsFlooded(true);
                 terrainInfo[neighbourLocation.x, neighbourLocation.y].Refresh();
             }
         }
     }
 }
Exemple #15
0
 private void Fall()
 {
     TileInfo[,] terrain = mapManager.GetComponent <MapManager>().GetTerrainInfo();
     for (int i = 0; i < terrain.GetLength(0); i++)
     {
         for (int j = 0; j < terrain.GetLength(1); j++)
         {
             if (terrain[i, j].GetHeight() == actualLayer ||
                 terrain[i, j].GetHeight() == actualLayer + 1)
             {
                 terrain[i, j].SetIsFlooded(false);
             }
         }
     }
 }
Exemple #16
0
        public TileMapRenderer(int _screenWidth, int _screenHeight)
        {
            m_screenWidth  = _screenWidth;
            m_screenHeight = _screenHeight;

            m_tilesInRow    = m_screenWidth / Constants.TILE_SIZE;
            m_tilesInColumn = _screenHeight / Constants.TILE_SIZE;
            m_tiles         = new TileInfo[m_tilesInRow, m_tilesInColumn];
            for (var i = 0; i < m_tilesInRow; i++)
            {
                for (var j = 0; j < m_tilesInColumn; j++)
                {
                    m_tiles[i, j] = new TileInfo(i, j, Constants.TILE_SIZE, Constants.TILE_SIZE);
                }
            }
        }
		public TileMapRenderer(int _screenWidth, int _screenHeight)
		{
			m_screenWidth = _screenWidth;
			m_screenHeight = _screenHeight;

			m_tilesInRow = m_screenWidth / Constants.TILE_SIZE;
			m_tilesInColumn = _screenHeight / Constants.TILE_SIZE;
			m_tiles = new TileInfo[m_tilesInRow, m_tilesInColumn];
			for (var i = 0; i < m_tilesInRow; i++)
			{
				for (var j = 0; j < m_tilesInColumn; j++)
				{
					m_tiles[i, j] = new TileInfo(i, j, Constants.TILE_SIZE, Constants.TILE_SIZE);
				}
			}
		}
Exemple #18
0
        public void Initialize()
        {
            Map = new TileInfo[MapWidth, MapHeight];

            _generator.GenerateMap(this);

            for (var x = 0; x < MapWidth; x++)
            {
                for (var y = 0; y < MapHeight; y++)
                {
                    RebuildTile(x, y);
                }
            }

            _applyCommand.Execute();
        }
Exemple #19
0
    void InitMap(int level)
    {
        switch(level)
        {
            case 1:
                width = UnityEngine.Random.Range(20, 40);
                height = UnityEngine.Random.Range(20, 40);
                break;
            default:
                Debug.Log(">Unknown level");
                break;
        }
		tiles = new GameObject[height, width];
		tileInfo = new TileInfo[height, width];
		GenMap(level);
		InstantiateMap();
	}
Exemple #20
0
    /// <summary>
    /// Calculate the tiles that are dry and without walls
    /// </summary>
    /// <returns>Tiles count</returns>
    public int CalculateAvailableTiles()
    {
        int dryCount = 0;

        TileInfo[,] terrainInfo = GameObject.FindGameObjectWithTag("Manager").GetComponent <MapManager>().GetTerrainInfo();
        for (int x = 0; x < terrainInfo.GetLength(0); x += 1)
        {
            for (int y = 0; y < terrainInfo.GetLength(1); y += 1)
            {
                if (!terrainInfo[x, y].GetIsFlooded() && terrainInfo[x, y].GetWallState() == TileInfo.WallState.NOTHING)
                {
                    dryCount++;
                }
            }
        }
        return(dryCount);
    }
Exemple #21
0
    public static IEnumerable <TileInfo> GetBorderTiles(TileInfo[,] board)
    {
        var result = new List <TileInfo>();

        for (int x = 0; x < board.GetLength(0); x++)
        {
            for (int y = 0; y < board.GetLength(1); y++)
            {
                if (x == 0 || x == board.GetLength(0) - 1 || y == 0 || y == board.GetLength(1) - 1)
                {
                    result.Add(board[x, y]);
                }
            }
        }

        return(result);
    }
Exemple #22
0
    public void RoomsToTileMap(TileMap tm, TileInfo[,] Tiles)
    {
        for (int x = 0; x <= 63; x++)
        {
            for (int y = 0; y <= 63; y++)
            {
                Tiles[x, y]                 = new TileInfo();
                Tiles[x, y].tileX           = (short)x;
                Tiles[x, y].tileY           = (short)y;
                Tiles[x, y].ceilingHeight   = 0;
                Tiles[x, y].indexObjectList = 0;
                Tiles[x, y].floorHeight     = 30;
                Tiles[x, y].tileType        = TileMap.TILE_SOLID;
                Tiles[x, y].doorBit         = 0;
                Tiles[x, y].DimX            = 1;
                Tiles[x, y].DimY            = 1;
                Tiles[x, y].Render          = true;
                Tiles[x, y].Grouped         = false;

                for (int v = 0; v < 6; v++)
                {
                    Tiles[x, y].VisibleFaces[v] = true;
                    Tiles[x, y].VisibleFaces[v] = true;
                }
                Tiles[x, y].floorTexture = 1; // (short)Random.Range(48, 57);
                Tiles[x, y].wallTexture  = 1; // (short)Random.Range(0, 48);
                Tiles[x, y].North        = Tiles[x, y].wallTexture;
                Tiles[x, y].South        = Tiles[x, y].wallTexture;
                Tiles[x, y].East         = Tiles[x, y].wallTexture;
                Tiles[x, y].West         = Tiles[x, y].wallTexture;
                Tiles[x, y].Top          = Tiles[x, y].floorTexture;
                Tiles[x, y].Bottom       = Tiles[x, y].floorTexture;
                Tiles[x, y].Diagonal     = Tiles[x, y].wallTexture;

                if (RoomMap[x, y] != 0)
                {
                    Tiles[x, y].tileType    = TileMap.TILE_OPEN;
                    Tiles[x, y].floorHeight = 15;
                    Tiles[x, y].VisibleFaces[TileMap.vBOTTOM] = false;
                    ////Floor textures are 49 to 56
                }
                // return;
            }
        }
        tm.SetTileMapWallFacesUW();
    }
Exemple #23
0
        public TetrisGame(GameScreen gameScreen)
        {
            _gameScreen = gameScreen;
            _gameScreen.Screen.Paint += pnlGameScreen_Paint;
            _tileInfos = new TileInfo[_gameScreen.Rows, _gameScreen.Columns];
            for (int i = 0; i < _tileInfos.GetLength(0); i++)
            {
                for (int j = 0; j < _tileInfos.GetLength(1); j++)
                {
                    _tileInfos[i, j] = new TileInfo(Brushes.Transparent, new Point(j, i));
                }
            }
            _currentTile = TileFactory.Instance().MakeTile(ETileType.LTILE, EDirection.LEFT);

            _timerMoveTileDown.Interval = 1500; // 1.5s
            _timerMoveTileDown.Tick    += timerMoveTileDown_Tick;
            _timerMoveTileDown.Enabled  = true;
        }
Exemple #24
0
    internal void initMap()
    {
        TileInfo currentTile = null;

        tiles = new TileInfo[SizeX, SizeZ];
        Debug.Log("Map size: (" + SizeX + "," + SizeZ + ")");
        for (int x = 0; x < SizeX; x++)
        {
            for (int z = 0; z < SizeZ; z++)
            {
                String s = x + "." + z;
                Vertex v = new Vertex(s);
                currentTile = new TileInfo(x, z, v);
                searchGraph.addVertex(v);
                tiles[x, z] = currentTile;
            }
        }
    }
Exemple #25
0
    /// <summary>
    /// NOTE : Tilemap 데이터 Tileinfo array로 변환 및 시작과 끝 높이 저장
    /// </summary>
    /// <param name="_prefab"></param>
    /// <returns></returns>
    private List <GeneratedTerrainData> SetTerrainList(Tilemap[] _prefab)
    {
        List <GeneratedTerrainData> tmpterrainlist = new List <GeneratedTerrainData>();

        foreach (var tilemapdata in _prefab)
        {
            //데이터를 저장할 맵 배열 생성
            TileInfo[,] tmptileinfoarray = AnalyzeTileMap(tilemapdata);

            //시작과 끝지점의 가장 아래지형의 바닥의 높이 저장
            int startHeight = -2;
            int endHeight   = -2;

            for (int j = 0; j < tilemapdata.cellBounds.yMax; j++)
            {
                //시작높이
                if (startHeight == -2 && tmptileinfoarray[0, j] == null)
                {
                    startHeight = j - 1;
                }
                //끝높이
                if (endHeight == -2 && tmptileinfoarray[tilemapdata.cellBounds.xMax - 1, j] == null)
                {
                    endHeight = j - 1;
                }

                //두개 모두 채워졌을경우 반복문 종료
                if (!startHeight.Equals(-2) && !endHeight.Equals(-2))
                {
                    break;
                }

                //마지막 횟수 일때에 모두다 값이 변경되지 않았을 경우 (null이 없이 모두 지형일 경우)
                if (j.Equals(tilemapdata.cellBounds.yMax - 1))
                {
                    startHeight = startHeight.Equals(-2) ? tilemapdata.cellBounds.yMax - 1 : startHeight;
                    endHeight   = endHeight.Equals(-2) ? tilemapdata.cellBounds.yMax - 1 : endHeight;
                }
            }
            tmpterrainlist.Add(new GeneratedTerrainData(tmptileinfoarray, tilemapdata.cellBounds, startHeight, endHeight));
        }

        return(tmpterrainlist);
    }
Exemple #26
0
        void Start()
        {
            MapView.TileDriver.RegisterRenderer(this);

            m_tileCountX = MapView.TileDriver.TileCountX; // +BoundaryTiles * 2;
            m_tileCountY = MapView.TileDriver.TileCountY; // +BoundaryTiles * 2;

            m_tileInfo = new TileInfo[m_tileCountX, m_tileCountY];

            for (int x = 0; x < m_tileCountX; x++)
            {
                for (int y = 0; y < m_tileCountY; y++)
                {
                    m_tileInfo[x, y] = new TileInfo();
                }
            }

            MapVisualizer.Initialize(this, MapboxAccess.Instance);
        }
    void setDoorBits(ref TileInfo[,] LevelInfo, ref ObjectInfo[] objList)
    {            //So I know if the tile contains a door.
        ObjectInfo currObj;

        for (short x = 0; x < 64; x++)
        {
            for (int y = 0; y < 64; y++)
            {
                if (LevelInfo[x, y].indexObjectList != 0)
                {
                    currObj = objList[LevelInfo[x, y].indexObjectList];
                    do
                    {
                        if ((objectMasters[objList[currObj.index].item_id].type == DOOR) ||
                            (objectMasters[objList[currObj.index].item_id].type == HIDDENDOOR) ||
                            (objectMasters[objList[currObj.index].item_id].type == PORTCULLIS))
                        {
                            //if (currObj.Angle1 >0)
                            //	{
                            //	//This door is a flat grating. I don't support that yet!
                            //	break;
                            //	}
                            //else
                            //	{
                            LevelInfo[x, y].isDoor    = 1;
                            LevelInfo[x, y].DoorIndex = currObj.index;
                            //	}
                            break;
                        }
                        else
                        {
                            if (objectMasters[objList[currObj.index].item_id].type == SHOCK_DOOR)
                            {
                                LevelInfo[x, y].shockDoor = 1;
                                LevelInfo[x, y].DoorIndex = currObj.index;
                            }
                        }
                        currObj = objList[currObj.next];
                    }while (currObj.index != 0);
                }
            }
        }
    }
    void setTerrainChangeBits(ref TileInfo[,] LevelInfo, ref ObjectInfo[] objList)
    {            //So I know that the tile terrains changes and I can later render both versions of the tile.
        ObjectInfo currObj;

        for (short x = 0; x < 64; x++)
        {
            for (short y = 0; y < 64; y++)
            {
                if (LevelInfo[x, y].indexObjectList != 0)
                {
                    currObj = objList[LevelInfo[x, y].indexObjectList];
                    do
                    {
                        if (objectMasters[objList[currObj.index].item_id].type == A_CHANGE_TERRAIN_TRAP)
                        {
                            LevelInfo[x, y].TerrainChange = 1;
                            //LevelInfo[x,y].TerrainChangeIndex = currObj.index;
                            //Need to flag the range of tiles affected. X/y of the object gives the dimensions
                            for (int j = x; j <= x + currObj.x; j++)
                            {
                                for (int k = y; k <= y + currObj.y; k++)
                                {
                                    LevelInfo[j, k].TerrainChange = 1;
                                    ///LevelInfo[j,k].TerrainChangeIndices[LevelInfo[j,k].TerrainChangeCount]=currObj.index;
                                    LevelInfo[j, k].TerrainChangeCount++;
                                    //LevelInfo[j,k].isWater  = 0;// turn off water in terrain change tiles
                                    if (LevelInfo[j, k].isDoor == 1)                                 //The tile contains a door. I need to make sure the door is created at the height of the tile.
                                    {
                                        objList[LevelInfo[j, k].DoorIndex].zpos = objList[currObj.index].zpos;
                                    }
                                }
                            }
                            currObj.tileX = x;
                            currObj.tileY = y;
                            //break;
                        }
                        currObj = objList[currObj.next];
                    }while (currObj.index != 0);
                }
            }
        }
    }
Exemple #29
0
    public void Flood()
    {
        terrainInfo = mapManager.GetComponent <MapManager>().GetTerrainInfo();
        List <TileInfo> tileDone     = new List <TileInfo>();
        List <TileInfo> tileModified = new List <TileInfo>();

        while (submergedTiles.Count() != 0)
        {
            TileInfo tile = submergedTiles[0];
            submergedTiles.RemoveAt(0);
            if (tile.GetCoordinates()[0] == 0 ||
                tile.GetCoordinates()[0] == terrainInfo.GetLength(0) - 1 ||
                tile.GetCoordinates()[1] == 0 ||
                tile.GetCoordinates()[1] == terrainInfo.GetLength(1) - 1)
            {
            }
            else
            {
                Vector3Int[] neighbours = tile.GetNeighboursCoordinates();
                foreach (Vector3Int neighbour in neighbours)
                {
                    TileInfo n = terrainInfo[neighbour.x, neighbour.y];
                    if (!tileDone.Contains(n))
                    {
                        tileDone.Add(n);
                        if (n.GetIsFlooded())
                        {
                            submergedTiles.Add(n);
                        }
                        else if (n.ShallFlood())
                        {
                            n.SetIsFlooded(true);
                            tileModified.Add(n);
                        }
                        n.DisplayWater();
                    }
                }
            }
        }
        submergedTiles = tileModified;
        Invoke("Flood", 0.5f);
    }
Exemple #30
0
    public void mapTheMap()
    {
        List <Transform> tiles = new List <Transform>();

        foreach (Transform child in transform)
        {
            if (child.GetComponent <TileInfo>())
            {
                tiles.Add(child);
            }
        }

        int maxX = (int)Math.Round(tiles.Max(go => go.position.x), 0);
        int maxY = (int)Math.Round(tiles.Max(go => go.position.y), 0);

        map = new TileInfo[maxX + 1, maxY + 1];

        foreach (Transform go in tiles)
        {
            map[(int)Math.Round(go.position.x, 0), (int)Math.Round(go.position.y, 0)] = go.GetComponent <TileInfo>();
        }
    }
 public void InitTileMap(char[] lev_ark, int address_pointer, int thisblock, long BlockAddress)
 {
     // if (game == 1)//uw1
     // {
     //OverlayBlock = TileMapBlock + 9;
     //TextureMapBlock = TileMapBlock + 18;
     //AutoMapBlock = TileMapBlock + 27;
     // }
     Tiles = new TileInfo[64, 64];
     for (short y = 0; y <= 63; y++)
     {
         for (short x = 0; x <= 63; x++)
         {
             int FirstTileInt  = (int)Util.getValAtAddress(lev_ark, (address_pointer + 0), 16);
             int SecondTileInt = (int)Util.getValAtAddress(lev_ark, (address_pointer + 2), 16);
             Tiles[x, y]             = BuildTileInfo(x, y, FirstTileInt, SecondTileInt, ceilingtexture);//TODO:Texturemappings
             Tiles[x, y].FileAddress = BlockAddress + address_pointer;
             Tiles[x, y].Render      = true;
             address_pointer         = address_pointer + 4;
         }
     }
     SetTileMapWallFacesUW();
     Cleanup();
 }
Exemple #32
0
    // Use this for initialization
    void Start()
    {
        tiles = new TileInfo[mapSizeX, mapSizeY];

        gridXLength = Vector3.Distance(tlCorner.transform.position, trCorner.transform.position) / mapSizeX;
        gridYLength = Vector3.Distance(tlCorner.transform.position, blCorner.transform.position) / mapSizeY;

        // Debug.Log(tlCorner.position.x + " " + tlCorner.position.z);

        for (int x = 0; x < mapSizeX; x++)
        {
            for (int y = 0; y < mapSizeY; y++)
            {
                tiles[x, y] = new TileInfo(
                    tlCorner.position.x + (gridXLength * x) + (gridXLength / 2),
                    tlCorner.position.z - ((gridYLength * y) + (gridYLength / 2))
                    );

                // Debug.Log(tiles[x,y].xPos + " " + tiles[x,y].yPos);
                // GameObject cube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                // cube.transform.position = new Vector3(tiles[x,y].xPos, 0, tiles[x,y].yPos);
            }
        }
    }
Exemple #33
0
 public TexGen(int w, int h)
 {
     width   = w; height = h;
     tileGen = new TileInfo[width, height];
 }
Exemple #34
0
    public void loadLevel(int stage)
    {
        if (IsThisFirstLoad)
        {
            IsThisFirstLoad = false;
            //Debug.Log("change Map");
        }
        else
        {
            Destroy(go_STAGE);
        }

        go_STAGE = new GameObject("STAGE");
        //go_STAGE.AddComponent()
        wallGroup = new GameObject("Wall");
        boardHolder = new GameObject("Board");
        entity = new GameObject("entity");
        item = new GameObject("item");
        trap = new GameObject("trap");
        something = new GameObject("something");

        boardHolder.transform.SetParent(go_STAGE.transform);
        wallGroup.transform.SetParent(go_STAGE.transform);
        entity.transform.SetParent(go_STAGE.transform);
        item.transform.SetParent(go_STAGE.transform);
        trap.transform.SetParent(go_STAGE.transform);
        something.transform.SetParent(go_STAGE.transform);

        this.tile = _Stage [stage].get_tileInfo ();
        this.gridPositions = _Stage [stage].getGridPositions ();

        GameObject toInstantiate;

        tileObj = new GameObject[rows, columns];
        wallObj = new GameObject[rows, columns];

        for (int x = 0; x < columns; x++) {
            for (int y = 0; y < rows; y++) {
                if (tile[y, x].tileType == TileInfo.FLOOR)
                {
                    toInstantiate = floorTiles[Random.Range(0, floorTiles.Length)];
                    tileObj[y, x] = Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
                    tileObj[y, x].transform.SetParent(boardHolder.transform);
                }
                else if (tile[y, x].tileType == TileInfo.OUTERWALL)
                {
                    toInstantiate = outerWallTiles[Random.Range(0, outerWallTiles.Length)];
                    wallObj[y, x] = Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
                    wallObj[y, x].transform.SetParent(wallGroup.transform);
                }
                else if (tile[y, x].tileType == TileInfo.WALL)
                {
                    toInstantiate = wallTiles[Random.Range(0, wallTiles.Length)];
                    wallObj[y, x] = Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
                    wallObj[y, x].transform.SetParent(wallGroup.transform);
                    wallObj[y, x].transform.FindChild("Roof").GetComponent<SpriteRenderer>().sortingOrder = 52 - y;
                }
                else if (tile[y, x].tileType == TileInfo.ROOM)
                {
                    toInstantiate = floorTiles[Random.Range(0, floorTiles.Length)];
                    tileObj[y, x] = Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
                    tileObj[y, x].transform.SetParent(boardHolder.transform);
                }
                else if (tile[y, x].tileType == TileInfo.ROAD)
                {
                    toInstantiate = floorTiles[Random.Range(0, floorTiles.Length)];
                    tileObj[y, x] = Instantiate(toInstantiate, new Vector3(x, y, 0f), Quaternion.identity) as GameObject;
                    tileObj[y, x].transform.SetParent(boardHolder.transform);
                }
                else
                {
                    ;//
                }
            }
        }
        Instantiate (exit, _Stage [stage].Exit, Quaternion.identity);
    }
Exemple #35
0
 public void SetColMap(TileInfo[,] colMap)
 {
     _colMap = colMap;
 }
Exemple #36
0
 public void setTileInfo(TileInfo[,] tile)
 {
     this.tile = tile;
 }
Exemple #37
0
        /// <summary>
        ///  Initializes the mapping using a target number pixels.
        /// </summary>
        /// <param name="xPixels">The width of the world in pixels.</param>
        /// <param name="yPixels">The height of the world in pixels.</param>
        /// <returns>An updated size that has been rounded up to the nearest world boundary.</returns>
        internal RECT CreateWorld(int xPixels, int yPixels)
        {
            RECT worldSize = new RECT();

            if (xPixels > 1 && xPixels % tileX == 0)
            {
                worldSize.Right = xPixels;
            }
            else
            {
                xPixels += tileX - (xPixels % tileX);
                worldSize.Right = xPixels;
            }

            if (yPixels > 1 && yPixels % tileY == 0)
            {
                worldSize.Bottom = yPixels;
            }
            else
            {
                yPixels += tileY - (yPixels % tileY);
                worldSize.Bottom = yPixels;
            }

            xMapTiles = (xPixels / tileY) + 1;
            yMapTiles = (yPixels / tileY) + 1;

            // Generate the world map
            worldMap = new int[xMapTiles, yMapTiles];
            new HeightMap(ref worldMap, xMapTiles, yMapTiles);

            // Based on the last worldMap, lets create the tileMap
            tileMap = new TileInfo[xMapTiles, yMapTiles];
            TileFilterPass();
            TileOffsetPass();
            MiniMapPass();

            return worldSize;
        }
Exemple #38
0
    private void setStage(int _x, int _y, int _roommin, int _roommax, int floor, int wall, int owall, int food, int enemy)
    {
        numOfEnemy = enemy;
        numOfFloor = floor;
        numOfFood = food;
        numOfWall = wall;
        numOfOwall = owall;
        roommin = _roommin;
        roommax = _roommax;
        this.rows = _x;
        this.columns = _y;
        tile = new TileInfo[rows, columns];

        for (int x = 0; x < columns; x++)
        {
            for (int y = 0; y < rows; y++)
            {
                tile[y, x] = new TileInfo(x, y);
            }
        }
        SetGeometry();
        SetPlayerSpawnAndExit();
        InitialiseList();
    }
Exemple #39
0
    private void setStage(int _x, int _y, int _roommin, int _roommax)
    {
        roommin = _roommin;
        roommax = _roommax;
        this.rows = _x;
        this.columns = _y;
        tile = new TileInfo[rows, columns];

        for (int x = 0; x < columns; x++)
        {
            for (int y = 0; y < rows; y++)
            {
                tile[y, x] = new TileInfo(x, y);
            }
        }
        SetGeometry();
        SetPlayerSpawnAndExit();
        InitialiseList();
    }