init: version 1

This commit is contained in:
Job
2025-07-17 17:16:02 +02:00
commit a76c0f6445
519 changed files with 202925 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
using System.Collections;
using UnityEngine;
/// <summary>
/// SpawnerController manages the spawning of cubes in the game.
/// </summary>
[RequireComponent(typeof(Animator))]
public class SpawnerController : Activateable
{
[Header("Configuration")]
public GameObject prefabCube;
public Vector3 spawnOffset = new (0, -.8f, 0);
private bool _isSpawning;
private CubeController _cube;
private Animator _animator;
private void Awake()
{
_animator = GetComponent<Animator>();
}
protected override void OnActivation()
{
if (_cube != null)
{
_cube.Respawn();
_cube = null;
}
else SpawnCube();
}
protected override void OnDeactivation()
{
}
public void SpawnCube()
{
if (isActive && !_isSpawning) StartCoroutine(SpawnCubeCoroutine());
}
private IEnumerator SpawnCubeCoroutine()
{
_isSpawning = true;
yield return new WaitForSeconds(.5f);
_animator.SetTrigger("Spawn");
yield return new WaitForSeconds(.3f);
GameObject gameObject = Instantiate(prefabCube, transform.position + spawnOffset, Quaternion.identity);
_cube = gameObject.GetComponent<CubeController>();
_cube.spawnerController = this;
_isSpawning = false;
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 017617ac6c7f3282d831314925a2a469