Skip to content

Commit

Permalink
이상현상 22 refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
seozzi committed Dec 15, 2024
1 parent ba8f0fd commit c9ae1fa
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly22Controller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ public class Anomaly22Controller : AbstractAnomalyObject
private List<Transform> floorTiles = new List<Transform>();
private Transform platformTile;


void Start()
public override bool StartAnomaly()
{
gameManager = GameObject.Find("GameManager").GetComponent<GameManager>();
playerController = GameObject.Find("Player").GetComponent<PlayerController>();
Expand All @@ -33,14 +32,43 @@ void Start()
floorTiles = new List<Transform>(floorTilesArray);
platformTile = FindPlatformTile();

StartCoroutine(AddBoxColliders()); // 타일 각각에 Collider 추가
StartCoroutine(DestroyFloorBoxCollider()); // Floor Parent의 통일된 Collider 제거
StartCoroutine(StartWithDelay());

bool res = base.StartAnomaly();
return res;
}

private IEnumerator StartWithDelay()
{
yield return new WaitForSeconds(5f);

StartCoroutine(InitializeCollidersAndDestroyParentCollider());
StartCoroutine(CountSeconds());
StartCoroutine(TriggerPlatformFall());
StartCoroutine(TriggerRandomTileShakeAndFallWithInterval());
}


private IEnumerator InitializeCollidersAndDestroyParentCollider()
{
yield return StartCoroutine(AddBoxColliders());
yield return StartCoroutine(DestroyFloorBoxCollider());
}

// 이상현상을 초기화하는 메서드
public override bool ResetAnomaly()
{
RestoreAllTiles();

bool res = base.ResetAnomaly();
return res;
}

private void Start()
{
StartAnomaly();
}

private Transform FindPlatformTile()
{
foreach (var tile in floorTiles)
Expand Down Expand Up @@ -79,6 +107,7 @@ private IEnumerator DestroyFloorBoxCollider()
if (boxCollider != null)
{
Destroy(boxCollider);

}
yield return null;
}
Expand All @@ -100,7 +129,7 @@ private IEnumerator AddBoxColliders()
Vector3 originalCenter = tileCollider.center;

tileCollider.size = new Vector3(originalSize.x, originalSize.y, originalSize.z * 20); // Change Y value to 3
tileCollider.center = new Vector3(originalCenter.x, originalCenter.y, originalCenter.z - originalSize.z * 20); // Adjust center for correct positioning
tileCollider.center = new Vector3(originalCenter.x, originalCenter.y, originalCenter.z - originalSize.z * 10); // Adjust center for correct positioning
}
}
yield return null;
Expand All @@ -118,7 +147,7 @@ private IEnumerator CountSeconds()
void Update()
{
// 아래로 떨어졌는지 확인해서 Game Over 처리
if (playerController.transform.position.y < -1f && !isPlayerDead && false)
if (playerController.transform.position.y < -5f && !isPlayerDead)
{
playerController.Sleep();
isPlayerDead = true;
Expand Down

0 comments on commit c9ae1fa

Please sign in to comment.