Files
WildRoot/Assets/Script/GameStep.cs
T
jongjae0305 8298b2559c [Update] 게임형식 및 오류수정
1. 게임형태 변경
  - Game스텝에서 기존 1단계, 2단계 수정(회전만 가능하게).
  - ShootButton을 만들어 플레이어도 총알을 쏠수 있도록 수정.
  - Bullet, BulletSpawner, PlayerController를 수정
  - SpawnZone을 생성하여 기존 고정이던 스포너를 랜덤으로 생성.

2. 오류 수정
 - 모바일 버전 시 플레이어가 한방향만 보던 형상 수정.
 - 펜스에서 플레이어 캐릭터가 닿으면 회전하던 형상 수정.
2026-04-29 09:22:08 +09:00

72 lines
1.5 KiB
C#

using UnityEngine;
public class NewMonoBehaviourScript : MonoBehaviour
{
public Rotator rotator;
private GameManager gameManager;
private int currentStep = 0;
private int lastMaxCount = 2;
private int lastStep = -1;
void Start()
{
gameManager = FindFirstObjectByType<GameManager>();
gameManager.UpdateMaxSpawnerCount(2);
UpdateStep(0);
}
void Update()
{
if (gameManager == null) return;
float currentTime = gameManager.GetSurviveTime();
int targetMax = 2;
if (currentTime > 10f)
{
targetMax = 2 + Mathf.FloorToInt((currentTime - 10f) / 4f);
}
if(targetMax != lastMaxCount)
{
lastMaxCount = targetMax;
gameManager.UpdateMaxSpawnerCount(targetMax);
}
int currentStep = (int)currentTime / 10;
if (currentStep != lastStep)
{
lastStep = currentStep;
UpdateStep(currentStep);
}
}
void UpdateStep(int step)
{
switch (step)
{
case 0:
case 1:
if (rotator != null) rotator.enabled = false;
break;
case 2:
if (rotator != null) rotator.enabled = false;
break;
case 3:
case 4:
if (rotator != null) rotator.enabled = true;
break;
default:
if (rotator != null) rotator.enabled = true;
break;
}
}
}