added gamescreen UI and simple start menu

This commit is contained in:
Mausham
2026-01-04 16:41:13 -08:00
parent dcf3bead16
commit 589260292c
508 changed files with 247792 additions and 516 deletions

View File

@@ -4,6 +4,7 @@ using System;
using System.Collections;
using UnityEngine;
using UnityEngine.Animations.Rigging;
using UnityEngine.SceneManagement;
using VContainer;
namespace Darkmatter.Presentation
@@ -21,6 +22,8 @@ namespace Darkmatter.Presentation
private float verticalVelocity;
public bool isGrounded => IsOnGround();
public float Health { get; set; } = 100;
[Header("GroundCheckSensorSetting")]
public float groundOffset;
public float groundCheckRadius;
@@ -29,6 +32,13 @@ namespace Darkmatter.Presentation
[Header("TurnSetting")]
public float turnSpeed = 5f;
[Inject] private PlayerConfigSO playerConfig;
[Inject] private IPlayerAnim PlayerAnim;
[Inject] private IGameScreenController gameScreenController;
[Inject] private IInputReader inputReader;
public event Action<float> OnHealthDecreased;
private bool isDead=false;
private void Start()
{
@@ -81,6 +91,40 @@ namespace Darkmatter.Presentation
Vector3 groundPos = transform.position + Vector3.down * groundOffset;
Gizmos.DrawWireSphere(groundPos, groundCheckRadius);
}
float damageCooldown = 1f;
float lastHitTime;
private void OnTriggerEnter(Collider other)
{
if(other.CompareTag("Enemy")&& !isDead)
{
TakeDamage(10);
}
}
public void TakeDamage(float damage)
{
Health-=damage;
if(Health<=0)
{
Die();
}
gameScreenController.ShowPlayerHealth((int)Health);
}
public void Die()
{
isDead = true;
PlayerAnim.PlayDeadAnim();
inputReader.DisableInput();
Invoke("GameOver", 4f);
}
private void GameOver()
{
gameScreenController.ShowGameOverText();
}
}