Commit 4126afb6 authored by 18손재민's avatar 18손재민

타일맵 갈아끼우기 wip

parent 5796d2ec
...@@ -20,6 +20,7 @@ GameObject: ...@@ -20,6 +20,7 @@ GameObject:
m_Component: m_Component:
- component: {fileID: 4821016865928708} - component: {fileID: 4821016865928708}
- component: {fileID: 114144154128578016} - component: {fileID: 114144154128578016}
- component: {fileID: 114476419532778440}
m_Layer: 0 m_Layer: 0
m_Name: MapManager m_Name: MapManager
m_TagString: MapManager m_TagString: MapManager
...@@ -60,6 +61,7 @@ MonoBehaviour: ...@@ -60,6 +61,7 @@ MonoBehaviour:
tetriminoCreatedTime: 0 tetriminoCreatedTime: 0
collapseTime: 10 collapseTime: 10
spawnBossTetrimino: 0 spawnBossTetrimino: 0
tetriminoCost: 1
fog: {fileID: 1100171732424598, guid: b8ab69a93ba618c47b27cc04eb431b3f, type: 2} fog: {fileID: 1100171732424598, guid: b8ab69a93ba618c47b27cc04eb431b3f, type: 2}
clearedFog: {fileID: 1767033925555920, guid: df8687fe46befb34eaf9d4d63938d946, type: 2} clearedFog: {fileID: 1767033925555920, guid: df8687fe46befb34eaf9d4d63938d946, type: 2}
press: {fileID: 114990664041074520, guid: 8e750fd197a05d84c9fb8557eb95c666, type: 2} press: {fileID: 114990664041074520, guid: 8e750fd197a05d84c9fb8557eb95c666, type: 2}
...@@ -157,3 +159,22 @@ MonoBehaviour: ...@@ -157,3 +159,22 @@ MonoBehaviour:
- {fileID: 21300000, guid: 11a6aa89a6f22a1498c4854c839c66e2, type: 3} - {fileID: 21300000, guid: 11a6aa89a6f22a1498c4854c839c66e2, type: 3}
- {fileID: 21300000, guid: b335c0d893e3c6847a861fd71c0348cd, type: 3} - {fileID: 21300000, guid: b335c0d893e3c6847a861fd71c0348cd, type: 3}
- {fileID: 21300000, guid: 00ec1514415c08349b130dbd95b9d270, type: 3} - {fileID: 21300000, guid: 00ec1514415c08349b130dbd95b9d270, type: 3}
--- !u!114 &114476419532778440
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1519889983907966}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: adab373df646d5f4fb794a3b6ffdf2d7, type: 3}
m_Name:
m_EditorClassIdentifier:
tileFR: []
tileIT: []
tileWW: []
tileUT: []
map: {fileID: 0}
roomInGame: {fileID: 0}
fillLeftDoor: []
fillRightDoor: []
...@@ -9,7 +9,7 @@ MonoBehaviour: ...@@ -9,7 +9,7 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 1 m_EditorHideFlags: 1
m_Script: {fileID: 13312, guid: 0000000000000000e000000000000000, type: 0} m_Script: {fileID: 13312, guid: 0000000000000000e000000000000000, type: 0}
m_Name: AllPoint m_Name: 14abce
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Sprite: {fileID: 21300000, guid: 7f9b5ffe7aca49248ab1a0367718d0ba, type: 3} m_Sprite: {fileID: 21300000, guid: 7f9b5ffe7aca49248ab1a0367718d0ba, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
......
...@@ -9,7 +9,7 @@ MonoBehaviour: ...@@ -9,7 +9,7 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 1 m_EditorHideFlags: 1
m_Script: {fileID: 13312, guid: 0000000000000000e000000000000000, type: 0} m_Script: {fileID: 13312, guid: 0000000000000000e000000000000000, type: 0}
m_Name: AllBottom m_Name: 21abcw
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Sprite: {fileID: 21300000, guid: b0cc692d067a7db4f8125377ccce9831, type: 3} m_Sprite: {fileID: 21300000, guid: b0cc692d067a7db4f8125377ccce9831, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
......
...@@ -9,7 +9,7 @@ MonoBehaviour: ...@@ -9,7 +9,7 @@ MonoBehaviour:
m_Enabled: 1 m_Enabled: 1
m_EditorHideFlags: 1 m_EditorHideFlags: 1
m_Script: {fileID: 13312, guid: 0000000000000000e000000000000000, type: 0} m_Script: {fileID: 13312, guid: 0000000000000000e000000000000000, type: 0}
m_Name: All m_Name: 33abcd
m_EditorClassIdentifier: m_EditorClassIdentifier:
m_Sprite: {fileID: 21300000, guid: 8548d5f950fee914ab554c0421d72ea8, type: 3} m_Sprite: {fileID: 21300000, guid: 8548d5f950fee914ab554c0421d72ea8, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1} m_Color: {r: 1, g: 1, b: 1, a: 1}
......
...@@ -14,6 +14,7 @@ public class Room : MonoBehaviour ...@@ -14,6 +14,7 @@ public class Room : MonoBehaviour
/// Not related to real location. /// Not related to real location.
/// </summary> /// </summary>
public Vector3 mapCoord; public Vector3 mapCoord;
public bool[,] tileInfo = new bool[24, 24];
/// <summary> /// <summary>
/// Stage per rooms. /// Stage per rooms.
/// </summary> /// </summary>
......
...@@ -5,104 +5,119 @@ using UnityEngine.Tilemaps; ...@@ -5,104 +5,119 @@ using UnityEngine.Tilemaps;
public class TileManager : MonoBehaviour public class TileManager : MonoBehaviour
{ {
public TileBase[] tileFR;
public TileBase[] tileIT;
public TileBase[] tileWW;
public TileBase[] tileUT;
public Tilemap map; public Tilemap map;
public RoomInGame roomInGame; public RoomInGame roomInGame;
public TileBase[] fillLeftDoor; public TileBase[] fillLeftDoor;
public TileBase[] fillRightDoor; public TileBase[] fillRightDoor;
//기본 테마를 숲속 유적으로 하고 if(얼음신전) public TileBase[] tile11;
public void Init() public TileBase[] tile12;
{ public TileBase[] tile13;
for (int i = 0; i < tileFR.Length; i++) public TileBase[] tile14;
map.SwapTile(tileFR[i], tileIT[i]); public TileBase[] tile21;
} public TileBase[] tile22;
public TileBase[] tile23;
public TileBase[] tile24;
public TileBase[] tile31;
public TileBase[] tile32;
public TileBase[] tile33;
public TileBase[] tile34;
public TileBase[] tile41;
public TileBase[] tile42;
public TileBase[] tile43;
public TileBase[] tile44;
public TileBase[] tile51;
public TileBase[] tile52;
public TileBase[] tile53;
public TileBase[] tile54;
public TileBase[] allTiles;
/* Dictionary<string, TileBase>[,] tilesDistributed = new Dictionary<string, TileBase>[5, 4];
같은 방식으로
if(수로)
for(int i=0;i<tileFR.Length;i++)
map.SwapTile(tileFR[i], tileWW[i]);
if(나무아래) void Awake()
for(int i=0;i<tileFR.Length;i++)
map.SwapTile(tileFR[i], tileUT[i]);
*/
public void FillEmptyDoor(int leftDoorLocation, int rightDoorLocation)
{
Tilemap outerWallMap = roomInGame.transform.GetChild(4).GetComponent<Tilemap>();
int[] doorLocations = { 1, 9, 17 };
for (int i = 0; i < 3; i++)
{ {
//경우를 따지자 for (int i = 0; i < 5; i++)
/* for (int j = 0; j < 4; j++)
* 왼쪽의 경우 tiles[i, j] = new Dictionary<string, TileBase>();
* 문 위 타일 string tileName;
* 1. 오른쪽에 타일이 없음 -> [| |] 모양 넣기 0 for(int i = 0; i < allTiles.Length; i++)
* 2. 오른쪽에만 타일이 있음 -> [| .] 모양 넣기 2
* 3. 오른쪽이랑 오른쪽 대각선 위에 타일이 있음 -> [| ] 모양 넣기 1
*
* 문 아래 타일
* 1. 오른쪽 타일 없음 -> 문 위랑 동일
* 2. 오른족에만 타일 -> [| '] 모양 넣기 3
* 3. 오른족이랑 오른쪽 대각선 아래에 타일 -> [| ] 모양
*
* 오른쪽의 경우
* 문 위 타일
* 1. 왼쪽에 X -> [| |]
* 2. 왼쪽에만 -> [. |]
* 3. 왼쪽이랑 왼쪽 대각선 아래 -> [ |]
*
* 문 아래
* 1. 왼쪽에 X -> [| |]
* 2. 왼쪽에만 -> [' |]
* 3. 왼쪽이랑 왼쪽 대각선 위 -> [ |]
*/
if (i != leftDoorLocation)
{ {
outerWallMap.SetTile(new Vector3Int(0, doorLocations[i] + 1, 0), fillLeftDoor[0]); tileName = allTiles[i].name;
outerWallMap.SetTile(new Vector3Int(0, doorLocations[i], 0), fillLeftDoor[0]); tiles[int.Parse(tileName[0].ToString()) - 1, int.Parse(tileName[1].ToString()) - 1].Add(tileName.Substring(2), allTiles[i]);
}
}
if (outerWallMap.HasTile(new Vector3Int(1, doorLocations[i] + 2, 0)) && outerWallMap.HasTile(new Vector3Int(1, doorLocations[i] + 3, 0))) public void CheckAllTiles(Room room)
outerWallMap.SetTile(new Vector3Int(0, doorLocations[i] + 2, 0), fillLeftDoor[1]); {
else if (outerWallMap.HasTile(new Vector3Int(1, doorLocations[i] + 2, 0))) Tilemap roomTileMap = room.roomInGame.transform.GetChild(3).GetComponent<Tilemap>();
outerWallMap.SetTile(new Vector3Int(0, doorLocations[i] + 2, 0), fillLeftDoor[2]); for(int x = 0; x < 24; x++)
for(int y = 0; y < 24; y++)
{
if (roomTileMap.GetTile(new Vector3Int(x, y, 0)))
room.tileInfo[x, y] = true;
else else
outerWallMap.SetTile(new Vector3Int(0, doorLocations[i] + 2, 0), fillLeftDoor[0]); room.tileInfo[x, y] = false;
}
}
if (outerWallMap.HasTile(new Vector3Int(1, doorLocations[i] - 1, 0)) && outerWallMap.HasTile(new Vector3Int(1, doorLocations[i] - 2, 0))) public char CheckQuarterTile(Room room, Vector2Int originPos, Vector2Int checkPos)
outerWallMap.SetTile(new Vector3Int(0, doorLocations[i] - 1, 0), fillLeftDoor[1]); {
else if (outerWallMap.HasTile(new Vector3Int(1, doorLocations[i] - 1, 0))) int verticalTile = 0, horizontalTile = 0;
outerWallMap.SetTile(new Vector3Int(0, doorLocations[i] - 1, 0), fillLeftDoor[3]); bool[,] tileInfo = room.tileInfo;
if ((originPos.x == 0 && (originPos.y + checkPos.y == room.doorLocations[room.leftDoorLocation]
|| originPos.y + checkPos.y == room.doorLocations[room.leftDoorLocation] + 1))
|| (originPos.x == 23 && (originPos.y + checkPos.y == room.doorLocations[room.rightDoorLocation]
|| originPos.y + checkPos.y == room.doorLocations[room.rightDoorLocation] + 1)))
verticalTile = 3;
else if (!IsTileInRoom(originPos.x + checkPos.x))
horizontalTile = 2;
else if (tileInfo[originPos.x + checkPos.x, originPos.y])
horizontalTile = 1;
if ((originPos.y == 0 && (originPos.x == 11 || originPos.x == 12)) || (originPos.y == 23 && (originPos.x == 11 || originPos.x == 12)))
horizontalTile = 3;
else if (!IsTileInRoom(originPos.y + checkPos.y))
verticalTile = 2;
else if (tileInfo[originPos.x, originPos.y + checkPos.y])
verticalTile = 1;
if((verticalTile == 2 && horizontalTile == 2) || (verticalTile == 3 && horizontalTile == 2) || (verticalTile == 2 && horizontalTile == 3))
return 'B';
else if (verticalTile == 2)
return 'H';
else if (horizontalTile == 2)
return 'V';
else if (verticalTile == 1 && horizontalTile == 1)
{
if (tileInfo[originPos.x + checkPos.x, originPos.y + checkPos.y])
return 'o';
else else
outerWallMap.SetTile(new Vector3Int(0, doorLocations[i] - 1, 0), fillLeftDoor[0]); return 's';
} }
if (i != rightDoorLocation) else if (verticalTile == 1)
{ return 'v';
outerWallMap.SetTile(new Vector3Int(23, doorLocations[i] + 1, 0), fillRightDoor[0]); else if (horizontalTile == 1)
outerWallMap.SetTile(new Vector3Int(23, doorLocations[i], 0), fillRightDoor[0]); return 'h';
if (outerWallMap.HasTile(new Vector3Int(22, doorLocations[i] + 2, 0)) && outerWallMap.HasTile(new Vector3Int(22, doorLocations[i] + 3, 0)))
outerWallMap.SetTile(new Vector3Int(23, doorLocations[i] + 2, 0), fillRightDoor[1]);
else if (outerWallMap.HasTile(new Vector3Int(22, doorLocations[i] + 2, 0)))
outerWallMap.SetTile(new Vector3Int(23, doorLocations[i] + 2, 0), fillRightDoor[2]);
else else
outerWallMap.SetTile(new Vector3Int(23, doorLocations[i] + 2, 0), fillRightDoor[0]); return 'b';
}
if (outerWallMap.HasTile(new Vector3Int(22, doorLocations[i] - 1, 0)) && outerWallMap.HasTile(new Vector3Int(22, doorLocations[i] - 2, 0))) bool IsTileInRoom(int n)
outerWallMap.SetTile(new Vector3Int(23, doorLocations[i] - 1, 0), fillRightDoor[1]); {
else if (outerWallMap.HasTile(new Vector3Int(22, doorLocations[i] - 1, 0))) return n >= 0 && n < 24;
outerWallMap.SetTile(new Vector3Int(23, doorLocations[i] - 1, 0), fillRightDoor[3]);
else
outerWallMap.SetTile(new Vector3Int(23, doorLocations[i] - 1, 0), fillRightDoor[0]);
} }
public void ChangeTile(Room room)
{
int stage = MapManager.currentStage;
int concept = room.roomConcept;
Tilemap roomTileMap = room.roomInGame.transform.GetChild(3).GetComponent<Tilemap>();
CheckAllTiles(room);
for(int x = 0; x < 24; x++)
for(int y = 0; y < 24; y++)
{
string tileName = CheckQuarterTile(room, new Vector2Int(x, y), new Vector2Int(-1, 1)).ToString() +
CheckQuarterTile(room, new Vector2Int(x, y), new Vector2Int(1, 1)).ToString() +
CheckQuarterTile(room, new Vector2Int(x, y), new Vector2Int(-1, -1)).ToString() +
CheckQuarterTile(room, new Vector2Int(x, y), new Vector2Int(1, -1)).ToString();
roomTileMap.SetTile(new Vector3Int(x, y, 0), tilesDistributed[stage, concept][tileName]);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment