コード例 #1
0
        /// <summary>
        /// Clear the Map that is passed in
        /// </summary>
        /// <param name="complete"></param>
        /// <param name="theMap"></param>
        // public void clearMap(bool complete, Tilemap theMap) {
        public void clearMap(bool complete)
        {
            topMap.ClearAllTiles();
            botMap.ClearAllTiles();

            if (complete)
            {
                terrainMap = null;
            }
        }
コード例 #2
0
 static int ClearAllTiles(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         UnityEngine.Tilemaps.Tilemap obj = (UnityEngine.Tilemaps.Tilemap)ToLua.CheckObject(L, 1, typeof(UnityEngine.Tilemaps.Tilemap));
         obj.ClearAllTiles();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
コード例 #3
0
 //Render our map to the tilemap.
 //cycle through the width and height of the map, only placing tiles if the array has a 1 at the location we are checking.
 public static void RenderMap(int[,] map, Tilemap tilemap, TileBase tile)
 {
     //Clear the map (ensures we dont overlap)
     tilemap.ClearAllTiles();
     //Loop through the width of the map
     for (int x = 0; x < map.GetUpperBound(0); x++)
     {
         //Loop through the height of the map
         for (int y = 0; y < map.GetUpperBound(1); y++)
         {
             // 1 = tile, 0 = no tile
             if (map[x, y] == 1)
             {
                 tilemap.SetTile(new Vector3Int(x, y, 0), tile);
             }
         }
     }
 }
コード例 #4
0
 public void ClearTilemap()
 {
     tilemap.ClearAllTiles();
 }
コード例 #5
0
    private IEnumerator CheckDungeonConnection()
    {
        bool mapSuccess = false;

        while (!mapSuccess)
        {
            foreach (GameObject item in m_itemsOnFloor)
            {
                m_pooler.ReturnToPool(item);
            }
            m_itemsOnFloor.Clear();

            m_allRooms.Clear();
            m_hallwayPoints.Clear();
            m_wallTiles.ClearAllTiles();
            m_floorTiles.ClearAllTiles();
            m_miniMapTiles.ClearAllTiles();



            m_allRooms = m_dungeonTheme.CreateNewFloor(this, m_dungeonNav);
            m_currentEnemyTypesInDungeon = m_dungeonTheme.AiInDungeon();

            yield return(new WaitForEndOfFrame());

            m_dungeonNav.m_gridWorldSize = new Vector2(m_dungeonTheme.m_generationTypes[m_dungeonGenTypeIndex].m_cellSize.x * m_dungeonTheme.m_generationTypes[m_dungeonGenTypeIndex].m_cellsInDungeon.x, m_dungeonTheme.m_generationTypes[m_dungeonGenTypeIndex].m_cellSize.y * m_dungeonTheme.m_generationTypes[m_dungeonGenTypeIndex].m_cellsInDungeon.y);
            m_dungeonNav.m_gridOrigin    = m_dungeonNav.m_gridWorldSize / 2;
            m_dungeonNav.CreateGrid();
            Vector3 startPoint = m_allRooms[0].m_worldPos;
            bool    roomFailed = false;
            for (int i = 1; i < m_allRooms.Count; i++)
            {
                List <Node> path = m_gridTestAgent.CreatePath(startPoint, m_allRooms[i].m_worldPos);
                if (path == null)
                {
                    roomFailed = true;
                }
            }
            mapSuccess = !roomFailed;

            /*TODO
             * /// Currently, the path is drawn first, to create all the physical colliders, generate the navigation grid, and uses a* to determine if the path is possible.<br/>
             * /// But maybe its more efficient to utilize cell types isntead, so there are no physics and art parts to that.
             */


            /*if (roomFailed)
             * {
             *  m_floorTiles.color = Color.red;
             *  yield return new WaitForSeconds(.25f);
             * }
             * yield return new WaitForSeconds(.1f);
             * m_floorTiles.color = Color.white;*/
            //mapSuccess = false;
        }
        List <int> removeIndex = new List <int>();

        for (int i = 0; i < m_hallwayPoints.Count; i++)
        {
            if (m_hallwayPoints[i].m_connectedTo.Count == 0)
            {
                Debug.LogWarning("Hallway point: " + m_hallwayPoints[i].m_worldPos + " is not connected to anything. Removing");
                removeIndex.Add(i);
            }
        }
        removeIndex.Reverse();
        foreach (int i in removeIndex)
        {
            m_hallwayPoints.RemoveAt(i);
        }
        m_occupiedSpaces.Clear();

        Vector2 randomPos = RandomSpawnPosition(m_allRooms);

        m_playerObject.transform.position = randomPos;
        m_occupiedSpaces.Add(randomPos);

        randomPos = RandomSpawnPosition(m_allRooms);
        m_staircase.transform.position = randomPos;
        m_occupiedSpaces.Add(randomPos);

        m_playerInput.m_canPerform = true;
    }