Add travel map flow and update docs

This commit is contained in:
jongjae0305
2026-06-24 15:34:09 +09:00
parent 8561fab0a2
commit af26dd4311
37 changed files with 3114 additions and 165 deletions
+85
View File
@@ -3,9 +3,18 @@ using UnityEngine;
// 슬라이딩 장애물 패턴이 켜질 때마다 매달린 장애물 위치를 섞는다.
public class SlideObstaclePattern : MonoBehaviour
{
public enum SlideLayout {
Random,
LeftPair,
CenterPair,
RightPair,
WidePair
}
public Transform[] obstacles; // 위치를 바꿀 고공 장애물들
public float[] xPositions = { -1.65f, -0.55f, 0.55f, 1.65f }; // 선택 가능한 로컬 x 위치
public float minSpacing = 1.5f; // 두 장애물 사이의 최소 간격
public SlideLayout layout = SlideLayout.Random; // 패턴 스포너가 지정하는 슬라이딩 장애물 배치
private void OnEnable()
{
@@ -14,6 +23,12 @@ public class SlideObstaclePattern : MonoBehaviour
return;
}
if(layout != SlideLayout.Random)
{
PlaceLayout(layout);
return;
}
int firstIndex = Random.Range(0, xPositions.Length);
if(obstacles.Length == 1 || xPositions.Length == 1)
@@ -38,6 +53,76 @@ public class SlideObstaclePattern : MonoBehaviour
PlaceObstacle(obstacles[1], rightX);
}
public void ConfigureLayout(SlideLayout nextLayout)
{
layout = nextLayout;
}
private void PlaceLayout(SlideLayout fixedLayout)
{
if(obstacles.Length == 1)
{
PlaceObstacle(obstacles[0], PickSingleX(fixedLayout));
return;
}
float leftX;
float rightX;
switch(fixedLayout)
{
case SlideLayout.LeftPair:
leftX = xPositions[0];
rightX = xPositions[Mathf.Min(2, xPositions.Length - 1)];
break;
case SlideLayout.CenterPair:
leftX = xPositions[Mathf.Min(1, xPositions.Length - 1)];
rightX = xPositions[Mathf.Min(2, xPositions.Length - 1)];
break;
case SlideLayout.RightPair:
leftX = xPositions[Mathf.Max(0, xPositions.Length - 3)];
rightX = xPositions[xPositions.Length - 1];
break;
case SlideLayout.WidePair:
default:
leftX = xPositions[0];
rightX = xPositions[xPositions.Length - 1];
break;
}
if(Mathf.Approximately(leftX, rightX) && xPositions.Length > 1)
{
leftX = xPositions[0];
rightX = xPositions[xPositions.Length - 1];
}
if(leftX > rightX)
{
float temp = leftX;
leftX = rightX;
rightX = temp;
}
PlaceObstacle(obstacles[0], leftX);
PlaceObstacle(obstacles[1], rightX);
}
private float PickSingleX(SlideLayout fixedLayout)
{
switch(fixedLayout)
{
case SlideLayout.LeftPair:
return xPositions[0];
case SlideLayout.CenterPair:
return xPositions[Mathf.Min(1, xPositions.Length - 1)];
case SlideLayout.RightPair:
return xPositions[xPositions.Length - 1];
case SlideLayout.WidePair:
default:
return xPositions[Mathf.Min(2, xPositions.Length - 1)];
}
}
private int PickSecondIndex(int firstIndex)
{
for(int i = 0; i < 12; i++)