탑뷰 슈팅 게임 미니 프로젝트

This commit is contained in:
2026-01-24 01:14:28 +09:00
parent 6753e7f013
commit 22b17ebff9
442 changed files with 165828 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
using TMPro;
using UnityEngine;
public class GameManager : MonoBehaviour
{
public GameObject player;
public float spawnTerm = 5;
public float fasterEverySpawn = 0.05f;
public float minSpawnTerm = 1;
public TextMeshProUGUI scoreText;
float timeAfterLastSpawn;
private float score;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
timeAfterLastSpawn = 0;
score = 0;
}
// Update is called once per frame
void Update()
{
timeAfterLastSpawn += Time.deltaTime;
score += Time.deltaTime;
if (timeAfterLastSpawn > spawnTerm)
{
timeAfterLastSpawn -= spawnTerm;
SpawnEnemy();
spawnTerm -= fasterEverySpawn;
if (spawnTerm < minSpawnTerm)
{
spawnTerm = minSpawnTerm;
}
}
scoreText.text = ((int)score).ToString();
}
void SpawnEnemy()
{
float x = Random.Range(-12f, 12f);
float y = Random.Range(-7f, 8f);
GameObject obj = GetComponent<ObjectPool>().Get();
obj.transform.position = new Vector3(x, y, 0);
obj.GetComponent<EnemyController>().Spawn(player);
}
}