added gamescreen UI and simple start menu
This commit is contained in:
@@ -15,6 +15,7 @@ namespace Darkmatter.Presentation
|
||||
protected readonly int moveXhash = Animator.StringToHash("MoveX");
|
||||
protected readonly int moveYhash = Animator.StringToHash("MoveY");
|
||||
private readonly int reloadHash = Animator.StringToHash("Reload");
|
||||
private readonly int deadHash = Animator.StringToHash("Dead");
|
||||
public TwoBoneIKConstraint HandOnGunIK; //for gunHand Ik
|
||||
private Coroutine reloadCoroutine;
|
||||
|
||||
@@ -71,5 +72,10 @@ namespace Darkmatter.Presentation
|
||||
{
|
||||
Debug.Log("player Shoot");
|
||||
}
|
||||
|
||||
public void PlayDeadAnim()
|
||||
{
|
||||
animator.SetTrigger(deadHash);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ namespace Darkmatter.Presentation
|
||||
public class EnemiesSpawnner : MonoBehaviour
|
||||
{
|
||||
[Inject] IEnemyFactory _enemyFactory;
|
||||
[Inject] IGameScreenController gameScreenController;
|
||||
public int baseEnemyCount =2;
|
||||
private ObjectPool<IEnemyPawn> _enemyPool;
|
||||
|
||||
@@ -49,6 +50,8 @@ namespace Darkmatter.Presentation
|
||||
|
||||
private void SpawnWave(int multiplier)
|
||||
{
|
||||
gameScreenController.UpdateTotalZombiesCount(baseEnemyCount*multiplier);
|
||||
gameScreenController.UpdateRemainingZombiesCount(baseEnemyCount*multiplier);
|
||||
for (int i = 0; i < baseEnemyCount*multiplier; i++)
|
||||
{
|
||||
IEnemyPawn enemy = _enemyPool.Get();
|
||||
@@ -62,6 +65,7 @@ namespace Darkmatter.Presentation
|
||||
enemy.Reset();
|
||||
_enemyPool.Release(enemy);
|
||||
killedEnemies++;
|
||||
gameScreenController.UpdateRemainingZombiesCount(baseEnemyCount*enemiesMultiplier - killedEnemies);
|
||||
if(killedEnemies == baseEnemyCount*enemiesMultiplier)
|
||||
{
|
||||
killedEnemies = 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Darkmatter.Presentation
|
||||
if(isDead) return;
|
||||
isDead = true;
|
||||
enemyAI.enabled = false;
|
||||
Invoke(nameof(Hide), 8f);
|
||||
Invoke(nameof(Hide), 5f);
|
||||
}
|
||||
|
||||
private void Hide()
|
||||
|
||||
@@ -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();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
"GUID:23f9a018fbd2e1242a0525718cc761d6",
|
||||
"GUID:b0214a6008ed146ff8f122a6a9c2f6cc",
|
||||
"GUID:4307f53044263cf4b835bd812fc161a4",
|
||||
"GUID:7f7d1af65c2641843945d409d28f2e20"
|
||||
"GUID:7f7d1af65c2641843945d409d28f2e20",
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using Darkmatter.Core;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class GameScreenController : IGameScreenController
|
||||
{
|
||||
GameScreenView gameScreenView;
|
||||
|
||||
public GameScreenController(GameScreenView gameScreenView)
|
||||
{
|
||||
this.gameScreenView = gameScreenView;
|
||||
}
|
||||
public void UpdateFireableBulletCount(int bulletCount)
|
||||
{
|
||||
gameScreenView.UpdateBulletText(bulletCount);
|
||||
}
|
||||
|
||||
public void UpdateRemainingZombiesCount(int zombiesCount)
|
||||
{
|
||||
gameScreenView.UpdateRemainingZombiesCountText(zombiesCount);
|
||||
}
|
||||
|
||||
public void UpdateTotalZombiesCount(int totalZombiesCount)
|
||||
{
|
||||
gameScreenView.UpdateTotalZombiesCount(totalZombiesCount);
|
||||
}
|
||||
|
||||
public void ShowGameOverText()
|
||||
{
|
||||
gameScreenView.ShowGameOver();
|
||||
|
||||
}
|
||||
|
||||
public void ShowPlayerHealth(int health)
|
||||
{
|
||||
gameScreenView.ShowPlayerHealth(health);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7143025033c7d9840a214fb5c4bfefb9
|
||||
45
Assets/Darkmatter/Code/Presentation/UI/GameScreenView.cs
Normal file
45
Assets/Darkmatter/Code/Presentation/UI/GameScreenView.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Darkmatter.Presentation
|
||||
{
|
||||
public class GameScreenView : MonoBehaviour
|
||||
{
|
||||
public TextMeshProUGUI fireableBulletText;
|
||||
public TextMeshProUGUI remainingZombiesCountText;
|
||||
public TextMeshProUGUI totalZombiesCountText;
|
||||
public TextMeshProUGUI playerHealthText;
|
||||
public GameObject GameOverObject;
|
||||
|
||||
public void UpdateBulletText(int bulletCount)
|
||||
{
|
||||
fireableBulletText.text = bulletCount.ToString();
|
||||
}
|
||||
|
||||
public void UpdateRemainingZombiesCountText(int zombiesCount)
|
||||
{
|
||||
remainingZombiesCountText.text = zombiesCount.ToString();
|
||||
}
|
||||
|
||||
public void UpdateTotalZombiesCount(int totalZombies)
|
||||
{
|
||||
totalZombiesCountText.text = totalZombies.ToString();
|
||||
}
|
||||
public void ShowPlayerHealth(int health)
|
||||
{
|
||||
playerHealthText.text = health.ToString();
|
||||
}
|
||||
public void ShowGameOver()
|
||||
{
|
||||
GameOverObject.SetActive(true);
|
||||
Invoke("ChangeScene", 2f);
|
||||
}
|
||||
|
||||
void ChangeScene()
|
||||
{
|
||||
SceneManager.LoadScene(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 53b791085ea93e74eb91492d67fa02a6
|
||||
@@ -5,6 +5,10 @@ namespace Darkmatter.Presentation
|
||||
{
|
||||
public class MenuScreen : MonoBehaviour
|
||||
{
|
||||
private void Start()
|
||||
{
|
||||
Cursor.lockState = CursorLockMode.None;
|
||||
}
|
||||
public void OnPlayBtnClick()
|
||||
{
|
||||
SceneManager.LoadScene(1);
|
||||
|
||||
Reference in New Issue
Block a user