feat: map editor (#56)

This commit is contained in:
M VINCENT PETT
2025-04-28 16:52:13 +02:00
committed by GitHub
parent 5cd536be84
commit 02ef8cdf74
38 changed files with 8394 additions and 140 deletions

View File

@ -6,9 +6,11 @@ public class Player : MonoBehaviour
public Rigidbody2D RigidBody { get; private set; }
public Transform Transform { get; private set; }
public ParticleSystem Particle { get; private set; }
public LevelsLoader LevelsLoader { get; private set; }
public LevelsLoader LevelsLoader { get; set; }
public SpriteRenderer SpriteRenderer { get; private set; }
public bool IsColliding { get; set; } = true;
public bool HasStarted { get; set; } = false;
public bool CanJump { get; set; } = true;
public IGameMode CurrentGameMode { get; set; }
public float SpeedMultiplier = 1f;
@ -19,7 +21,12 @@ public class Player : MonoBehaviour
Transform = transform;
Particle = GetComponentInChildren<ParticleSystem>();
SpriteRenderer = GetComponentInChildren<SpriteRenderer>();
LevelsLoader = GameObject.FindGameObjectWithTag("LevelsLoader").GetComponent<LevelsLoader>();
GameObject loaderObj = GameObject.FindGameObjectWithTag("LevelsLoader");
if (loaderObj != null)
LevelsLoader = loaderObj.GetComponent<LevelsLoader>();
else
Debug.LogWarning("LevelsLoader introuvable : Progression désactivée pour ce niveau.");
}
public void Start()
@ -33,21 +40,24 @@ public class Player : MonoBehaviour
public void Update()
{
CurrentGameMode.Update(this);
LevelsLoader.CalculateCurrentProgressionPercent(transform.position);
if (CurrentGameMode != null)
CurrentGameMode.Update(this);
if (LevelsLoader != null)
LevelsLoader.CalculateCurrentProgressionPercent(transform.position);
}
public void OnCollisionEnter2D(Collision2D collision)
public virtual void OnCollisionEnter2D(Collision2D collision)
{
CurrentGameMode.OnCollisionEnter(this, collision);
CurrentGameMode?.OnCollisionEnter(this, collision);
}
public void OnCollisionExit2D(Collision2D collision)
{
CurrentGameMode.OnCollisionExit(this, collision);
CurrentGameMode?.OnCollisionExit(this, collision);
}
private void OnTriggerEnter2D(Collider2D collision)
public virtual void OnTriggerEnter2D(Collider2D collision)
{
if (collision.CompareTag("ShipPortal"))
{