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

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();
}
}
@@ -1,6 +1,7 @@
using Code.App.StateMachine;
using Code.Configs;
using Code.Gameplay.Camera;
using Code.Gameplay.Player;
using Code.Input;
using Code.Scenes;
using Code.StaticData;
@@ -22,6 +23,7 @@ namespace Code.App
InstallInfrastructureUnit(containerBuilder, staticDataService);
containerBuilder.AddSingleton(typeof(InputService), typeof(IInputService));
containerBuilder.AddSingleton(typeof(PlayerFactory), typeof(IPlayerFactory));
InitializeCamera(containerBuilder, staticDataService);
containerBuilder.AddSingleton(typeof(UIService), typeof(IUIService));
@@ -61,6 +63,7 @@ namespace Code.App
containerBuilder.AddSingleton(staticDataService, typeof(IStaticDataService));
containerBuilder.AddSingleton(staticDataService.InputConfig.inputActionAsset, typeof(InputActionAsset));
containerBuilder.AddSingleton(staticDataService.CameraConfig, typeof(CameraConfig));
containerBuilder.AddSingleton(staticDataService.PlayerConfig, typeof(PlayerConfig));
containerBuilder.AddSingleton(staticDataService.CharacterConfig, typeof(CharacterConfig));
containerBuilder.AddSingleton(staticDataService.UIConfig.canvasPrefab, typeof(Canvas));
containerBuilder.AddSingleton(staticDataService.UIConfig.uiElementsPrefabs, typeof(UIElement[]));
@@ -1,4 +1,5 @@
using Code.Gameplay.Camera;
using Code.Gameplay.Player;
using Code.Input;
using Code.Scenes;
using Code.UI;
@@ -8,10 +9,11 @@ namespace Code.App.StateMachine
{
public class AppStateMachineContext
{
[Inject] public ISceneLoaderService SceneLoaderService;
[Inject] public IInputService InputService;
[Inject] public AppStateMachine StateMachine;
[Inject] public CameraStateMachine CameraStateMachine;
[Inject] public IUIService UIService;
[Inject] public ISceneLoaderService SceneLoaderService { get; private set; }
[Inject] public IInputService InputService { get; private set; }
[Inject] public AppStateMachine StateMachine { get; private set; }
[Inject] public CameraStateMachine CameraStateMachine { get; private set; }
[Inject] public IUIService UIService { get; private set; }
[Inject] public IPlayerFactory PlayerFactory { get; private set; }
}
}