Ejemplo n.º 1
0
    public void autoGenerateLobbyTile(List <LobbyConnection> lobbyList)
    {
        //clear all
        for (int r = -(config.mapSizeRow - 1) / 2; r <= (config.mapSizeRow - 1) / 2; r++)
        {
            for (int c = (config.mapSizeColumn - 1) / 2; c >= -(config.mapSizeColumn - 1) / 2; c--)
            {
                tileUtility.changeToReplaceTile(lobbyTilemap, new Vector3Int(r, c, 0), null);
            }
        }
        foreach (var lobby in lobbyList)
        {
            int lobbyPositionX = 0;
            int lobbyPositionY = 0;

            lobbyPositionY = (config.mapSizeColumn - 1) / 2 - lobby.lobbyR * (Mathf.FloorToInt(config.roomScale / 2) + 1);
            if (lobby.lobbyR % 2 == 1)
            {
                lobbyPositionX = -(config.mapSizeRow - 1) / 2 + lobby.lobbyC * (config.roomScale + 1);
            }
            else
            {
                lobbyPositionX = -(config.mapSizeRow - 1) / 2 + lobby.lobbyC * (config.roomScale + 1) - (Mathf.FloorToInt(config.roomScale / 2) + 1);
            }

            Vector3Int lobbyPosition = new Vector3Int(lobbyPositionX, lobbyPositionY, 0);
            tileUtility.changeToReplaceTile(lobbyTilemap, lobbyPosition, lobbyTile, true);
            tileUtility.changeToReplaceTile(wallTilemap, lobbyPosition, null, true);
        }
    }
Ejemplo n.º 2
0
 private void OnTriggerExit2D(Collider2D collider)
 {
     if (tag == "servant" && collider.tag == "doorTile" && playerController.attatchTo != gameObject && tileUtility.getAvatarPosInTilemap(transform.position) != RoomPos)
     {
         Debug.Log("close door");
         var doorTileMap = collider.gameObject.GetComponent <Tilemap>();
         if (doorTileMap.GetTile(RoomPos) == passTile_verti)
         {
             if (tileUtility.changeToReplaceTile(doorTileMap, RoomPos, unpassTile_verti))
             {
                 collider.gameObject.GetComponent <CompositeCollider2D>().isTrigger = false;
             }
         }
         if (doorTileMap.GetTile(RoomPos) == passTile_hori)
         {
             if (tileUtility.changeToReplaceTile(doorTileMap, RoomPos, unpassTile_hori))
             {
                 collider.gameObject.GetComponent <CompositeCollider2D>().isTrigger = false;
             }
         }
     }
 }