Files

72 lines
1.5 KiB
C#
Raw Permalink Normal View History

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