Ejemplo n.º 1
0
 void addTiles(MapExploration _mapExploration)
 {
     if (roomMemory.roomID[_mapExploration.xID, _mapExploration.yID] > 3)
     {
         tileList.Insert(Random.Range(0, tileList.Count), _mapExploration);
     }
 }
Ejemplo n.º 2
0
 void updateTile()
 {
     for (int i = 0; i < mapUI.mapWidth * mapUI.mapHeight; i++)
     {
         mapExploration = mapSpawn.transform.GetChild(i).gameObject.GetComponent <MapExploration>();
         mapExploration.updateNeeded = true;
     }
 }
Ejemplo n.º 3
0
 void uploadMap()  //actually puts stuff on the map
 {
     if (mapUI.mapLoaded == true)
     {
         if (mapUploaded == false)
         {
             mapUploaded = true;
             if (mapUI.mapWidth > mapUI.mapHeight)
             {
                 tileSize = new Vector2(450 / mapUI.mapWidth - 4, 450 / mapUI.mapWidth - 4);                                                //calculates appropriate tile size
                 gameObject.GetComponent <GridLayoutGroup>().cellSize        = new Vector2(450 / mapUI.mapWidth, 450 / mapUI.mapWidth);     //calculates appropriate border size
                 gameObject.GetComponent <GridLayoutGroup>().constraintCount = mapUI.mapHeight;                                             //reduces amount of rows on map
                 gameObject.GetComponent <GridLayoutGroup>().padding.bottom  = 50 + ((450 - (mapUI.mapHeight * 450 / mapUI.mapWidth)) / 2); //adjusts padding to center map
                 gameObject.GetComponent <GridLayoutGroup>().padding.top     = 50 + ((450 - (mapUI.mapHeight * 450 / mapUI.mapWidth)) / 2);
             }
             else
             {
                 tileSize = new Vector2(450 / mapUI.mapHeight - 4, 450 / mapUI.mapHeight - 4);
                 gameObject.GetComponent <GridLayoutGroup>().cellSize        = new Vector2(450 / mapUI.mapHeight, 450 / mapUI.mapHeight);
                 gameObject.GetComponent <GridLayoutGroup>().constraintCount = mapUI.mapHeight;
                 gameObject.GetComponent <GridLayoutGroup>().padding.left    = 50 + ((450 - (mapUI.mapWidth * 450 / mapUI.mapHeight)) / 2);
                 gameObject.GetComponent <GridLayoutGroup>().padding.right   = 50 + ((450 - (mapUI.mapWidth * 450 / mapUI.mapHeight)) / 2);
             }
             for (int i = 0; i < mapUI.mapWidth; i++)
             {
                 for (int j = 0; j < mapUI.mapHeight; j++)
                 {
                     GameObject border;
                     GameObject tile;
                     if (i == (-roomMemory.roomLeft) && j == (-roomMemory.roomDown))             //spawn room
                     {
                         roomMemory.playerRoom       = new Vector2(i, j);                        //identify location of player
                         roomMemory.roomLayOut[0, 0] = 13;                                       //updates roomMemory to include spawn (instead of 0)
                         mapUI.adjustedStorage[-roomMemory.roomLeft, -roomMemory.roomDown] = 13; //updates adjustedStorage to include spawn (instead of 0)
                         border                  = Instantiate(templates.Borders[13], new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                         mapExploration          = border.GetComponent <MapExploration>();
                         mapExploration.xPos     = i;
                         mapExploration.yPos     = j;
                         mapExploration.xID      = i + (roomMemory.roomLeft + 15);
                         mapExploration.yID      = j + (roomMemory.roomDown + 15);
                         mapExploration.explored = 1; //discovered
                         border.transform.SetParent(gameObject.transform);
                         border.transform.localScale = new Vector3(1, 1, 1);
                         tile = Instantiate(templates.Tiles[0], new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                         tile.transform.SetParent(border.transform);
                         tile.GetComponent <RectTransform>().sizeDelta = tileSize;
                         tile.transform.localScale = new Vector3(1, 1, 1);
                     }
                     else  //everything else
                     {
                         border              = Instantiate(templates.Borders[mapUI.adjustedStorage[i, j]], new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                         mapExploration      = border.GetComponent <MapExploration>();
                         mapExploration.xPos = i;
                         mapExploration.yPos = j;
                         mapExploration.xID  = i + (roomMemory.roomLeft + 15);
                         mapExploration.yID  = j + (roomMemory.roomDown + 15);
                         addTiles(mapExploration);
                         //roomMemory.roomID[i, j] = 1; //undiscovered empty room
                         border.transform.SetParent(gameObject.transform);
                         border.transform.localScale = new Vector3(0, 0, 0); //makes all rooms (other than spawn) invisible
                         if (mapUI.adjustedStorage[i, j] != 0)
                         {
                             //border.transform.localScale = new Vector3(1, 1, 1); //makes non empty rooms visible again (FOR DEBUG)
                             tile = Instantiate(templates.Tiles[1], new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
                             tile.transform.SetParent(border.transform);
                             tile.GetComponent <RectTransform>().sizeDelta = tileSize;
                             tile.transform.localScale = new Vector3(1, 1, 1);
                         }
                     }
                 }
             }
             //revealTiles();
         }
     }
 }