Допил интерфейса, здоровья, денег

This commit is contained in:
ThomasCharester committed 2025-10-30 21:13:42 +03:00
1 parent b214bb0f63
commit bea109175b
29 files changed
+675 -789

No files matched your search

@@ -6,13 +6,15 @@ using Code.Scenes;
using Code.StateMachine;
using Code.UI;
using UnityEngine;
using UnityEngine.InputSystem;
namespace Code.App.AppStates
{
public class GameplayState : BaseState<AppStateMachineContext>
{
private PlayerHealthPoints _playerHealthPoints;
private PlayerHealth _playerHealth;
private PlayerMoney _playerMoney;
public GameplayState(AppStateMachineContext context) : base(context)
{
}
@@ -21,28 +23,65 @@ namespace Code.App.AppStates
{
Context.SceneLoaderService.LoadScene((int)SceneIds.MovementDev, SceneLoaded);
Context.InputService.EnableMap(ActionMappings.Gameplay);
Context.UIService.LoadingScreen.Show();
Context.UIService.SwitchPanelTo(UIPanel.Gameplay);
Context.CameraStateMachine.SwitchState(CameraMode.FirstPerson);
_playerMoney = Context.PlayerFactory.CreatePlayerMoney();
_playerHealth = Context.PlayerFactory.CreatePlayerHealth();
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.GiveHealth, GiveHealth);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.GiveMoney, GiveHealth);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.LooseHealth, LooseHealth);
Context.InputService.DebugBindAction((int)ActionMappings.Debug, (int)DebugActions.LooseMoney, LooseMoney);
}
private void SceneLoaded()
{
((GameplayPanel)Context.UIService.CurrentPanel).Initialize(_playerMoney, _playerHealth);
Context.UIService.LoadingScreen.Hide();
base.EnterState();
}
private void GiveHealth(InputAction.CallbackContext context)
{
_playerHealth.GetDamage(-1);
}
private void LooseHealth(InputAction.CallbackContext context)
{
_playerHealth.GetDamage(1);
}
private void GiveMoney(InputAction.CallbackContext context)
{
_playerMoney.GiveMoney(100);
}
private void LooseMoney(InputAction.CallbackContext context)
{
_playerMoney.GiveMoney(100);
}
public override void Tick()
{
}
public override void ExitState()
{
_playerHealth = null;
_playerMoney = null;
Context.InputService.DisableMap(ActionMappings.Gameplay);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.GiveHealth, GiveHealth);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.GiveMoney, GiveHealth);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.LooseHealth, LooseHealth);
Context.InputService.DebugUnbindAction((int)ActionMappings.Debug, (int)DebugActions.LooseMoney, LooseMoney);
base.ExitState();
}
}