Skip to content

Commit

Permalink
이상현상 22 교탁의 restore 위치 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
seozzi committed Dec 17, 2024
1 parent 2b881ed commit 19074c4
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 9 deletions.
4 changes: 2 additions & 2 deletions 302/Assets/Scenes/DefaultGameScene.unity
Original file line number Diff line number Diff line change
Expand Up @@ -43759,9 +43759,9 @@ MonoBehaviour:
- {fileID: 5650449145146738954, guid: 11a50fb479ce40a4698c9b8f9816f567, type: 3}
- {fileID: 3233071982878084982, guid: 5156428cd2b781d4dabf6a30befa7685, type: 3}
- {fileID: 5605359256125054964, guid: 48c8f10abe45bef4098efae902701f34, type: 3}
checkSpecificAnomaly: 0
checkSpecificAnomaly: 1
checkIntersect: 0
SpecificAnomalyNum: 0
SpecificAnomalyNum: 22
currentAnomalyInstance: {fileID: 8678062959089499939, guid: 6aadfcd777444a24180cf51012c6e89c, type: 3}
--- !u!4 &1964216256
Transform:
Expand Down
30 changes: 23 additions & 7 deletions 302/Assets/Scripts/SpecificAnomalyManager/Anomaly22Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private IEnumerator TriggerRandomTileShakeAndFallWithInterval()
tileScript.shakeSound = shakeSound;
tileScript.TriggerShakeAndFall();
}
yield return new WaitForSeconds(0.5f);
yield return new WaitForSeconds(0.3f);
}
if (!isPlayerDead) // totalSeconds가 다 지날 때까지 생존 시
{
Expand All @@ -133,6 +133,7 @@ private IEnumerator RestoreAllTiles()
{
float duration = 1f; // Duration for the animation (1 second)
float elapsedTime = 0f;

// Store the original positions of all tiles
Dictionary<Transform, Vector3> originalPositions = new Dictionary<Transform, Vector3>();
foreach (var tile in floorTiles)
Expand All @@ -142,23 +143,38 @@ private IEnumerator RestoreAllTiles()
originalPositions[tile] = tile.position;
}
}
// Animate the tiles back to y = 0 over the duration

// Calculate reversed target positions
Dictionary<Transform, Vector3> reversedPositions = new Dictionary<Transform, Vector3>();
foreach (var tile in originalPositions.Keys)
{
float targetY = (tile == platformTile) ? -0.2f * (3f / 5f) : 0.21f * (3f / 5f);
reversedPositions[tile] = new Vector3(originalPositions[tile].x, targetY, originalPositions[tile].z);
}

// Animate the tiles back to reversed positions over the duration
while (elapsedTime < duration)
{
elapsedTime += Time.deltaTime;
float t = elapsedTime / duration; // Normalized time [0, 1]
float t = Mathf.Clamp01(elapsedTime / duration); // Normalize t between 0 and 1

foreach (var tile in originalPositions.Keys)
{
Vector3 startPos = originalPositions[tile];
Vector3 targetPos = new Vector3(startPos.x, 0f, startPos.z);
Vector3 targetPos = reversedPositions[tile];

tile.position = Vector3.Lerp(startPos, targetPos, t);
}

yield return null; // Wait for the next frame
}
// Ensure all tiles are precisely at y = 0 at the end of the animation
foreach (var tile in originalPositions.Keys)

// Snap tiles to their exact target Y positions
foreach (var tile in reversedPositions.Keys)
{
tile.position = new Vector3(tile.position.x, 0f, tile.position.z);
Vector3 finalPos = reversedPositions[tile];
tile.position = new Vector3(tile.position.x, finalPos.y, tile.position.z);

// Remove the Anomaly22_tile component if it exists
Anomaly22_tile tileScript = tile.GetComponent<Anomaly22_tile>();
if (tileScript != null)
Expand Down

0 comments on commit 19074c4

Please sign in to comment.