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,21 @@
using UnityEngine;
/// <summary>
/// RespawnPlane is a trigger zone that respawns the player or cube
/// when they enter the zone.
/// </summary>
public class RespawnPlane : MonoBehaviour
{
[Header("Configuration")]
public Spawnpoint spawnpoint;
private void OnTriggerEnter2D(Collider2D other) {
if (other.gameObject.CompareTag("Player")) {
spawnpoint.Respawn();
}
if (other.gameObject.CompareTag("Cube")) {
other.GetComponent<CubeController>().Respawn();
}
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: 7375580a7f6e8451d89987abc46838b3

View File

@@ -0,0 +1,44 @@
using UnityEngine;
/// <summary>
/// Spawnpoint marks the start location of the player and
/// is responsible for respawning the player when needed.
/// </summary>
public class Spawnpoint : MonoBehaviour
{
[Header("Configuration")]
public Vector2 offset = new (0f, 0.5f);
public int mapIdx;
private GameObject _player;
private void Start()
{
_player = GameObject.FindWithTag("Player");
Respawn();
}
private void Update()
{
if (!Input.GetKeyDown(KeyCode.R)) return;
Respawn();
}
public void Respawn()
{
_player.transform.position = new Vector3(
transform.position.x + offset.x,
transform.position.y + offset.y,
_player.transform.position.z
);
_player.GetComponent<Rigidbody2D>().linearVelocity = Vector2.zero;
GameManager gameManager = GameManager.Instance;
if (gameManager.currentMapIdx != mapIdx)
{
gameManager.currentMapIdx = mapIdx;
gameManager.SwitchMap(mapIdx);
}
gameManager.onRespawn.Invoke();
}
}

View File

@@ -0,0 +1,2 @@
fileFormatVersion: 2
guid: b02938f59b4be2cc0a4f04d24007bb2a