Platformer example started
This commit is contained in:
1 parent
efcfaae647
commit
9f026b76d6
325 files changed
+23540
-270
No files matched your search
@@ -10,7 +10,8 @@ namespace Code.Infrastructure.App
|
||||
{
|
||||
Bootstrap,
|
||||
Gameplay,
|
||||
MainMenu
|
||||
MainMenu,
|
||||
Platformer
|
||||
}
|
||||
|
||||
public class AppStateMachineContext
|
||||
|
||||
@@ -9,6 +9,7 @@ using Code.Infrastructure.UI;
|
||||
using Code.Infrastructure.Volume;
|
||||
using Reflex.Core;
|
||||
using Reflex.Enums;
|
||||
using Reflex.Injectors;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.Universal;
|
||||
@@ -26,7 +27,8 @@ namespace Code.Infrastructure.App
|
||||
IVolumeLoaded,
|
||||
IAudioSourcePoolInitializedHandle,
|
||||
IAudioConfigsLoadedHandle,
|
||||
ICinematicMachineHandle
|
||||
ICinematicMachineHandle,
|
||||
ILayerMasksInitializedHandle
|
||||
{
|
||||
public void InstallBindings(ContainerBuilder containerBuilder)
|
||||
{
|
||||
@@ -64,7 +66,6 @@ namespace Code.Infrastructure.App
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterType(typeof(AudioService), new[] { typeof(IAudioService) }, Lifetime.Singleton,
|
||||
Resolution.Eager);
|
||||
|
||||
}
|
||||
|
||||
private void InitLoadings()
|
||||
@@ -79,8 +80,9 @@ namespace Code.Infrastructure.App
|
||||
// Audio Factory
|
||||
// Audio Pool
|
||||
// Cinemachine Camera
|
||||
_initialLoading = new Loading(10, () => EssentialLoadEnded(_thatRightContainer));
|
||||
|
||||
// Layer masks
|
||||
_initialLoading = new Loading(11, () => EssentialLoadEnded(_thatRightContainer));
|
||||
|
||||
_ui2CamLoading = new Loading(2,
|
||||
() =>
|
||||
{
|
||||
@@ -99,7 +101,9 @@ namespace Code.Infrastructure.App
|
||||
_thatRightContainer = container;
|
||||
|
||||
container.Resolve<EventBus.EventBus>().Subscribe(this);
|
||||
|
||||
|
||||
ConstructorInjector.Construct(typeof(LayerMasks), container);
|
||||
|
||||
var cameraFactory = container.Resolve<CameraFactory>();
|
||||
cameraFactory.CreateCameraStateMachine(container.Resolve<CameraStateMachine>())
|
||||
.Forget();
|
||||
@@ -109,7 +113,8 @@ namespace Code.Infrastructure.App
|
||||
{
|
||||
container.Resolve<EventBus.EventBus>().Unsubscribe(this);
|
||||
container.Resolve<AppStateMachine>().SwitchState(AppStates.Bootstrap)
|
||||
.AllowStateTransition(AppStates.Gameplay);
|
||||
.AllowStateTransition(AppStates.Gameplay)
|
||||
.AllowStateTransition(AppStates.Platformer);
|
||||
container.Resolve<AppStateMachineContext>().StateMachine = container.Resolve<AppStateMachine>();
|
||||
}
|
||||
|
||||
@@ -127,7 +132,8 @@ namespace Code.Infrastructure.App
|
||||
{
|
||||
_thatRightContainer.Resolve<CameraStateMachineContext>().cameraLoadedData = data;
|
||||
_thatRightContainer.Resolve<CameraStateMachine>().SwitchState(CameraMode.None)
|
||||
.AllowStateTransition(CameraMode.ThirdPerson);
|
||||
.AllowStateTransition(CameraMode.ThirdPerson)
|
||||
.AllowStateTransition(CameraMode.Platformer);
|
||||
|
||||
data.Camera.GetUniversalAdditionalCameraData().renderPostProcessing = true;
|
||||
|
||||
@@ -198,5 +204,10 @@ namespace Code.Infrastructure.App
|
||||
{
|
||||
_initialLoading.DoProgress();
|
||||
}
|
||||
|
||||
public void LayerMasksInitialized()
|
||||
{
|
||||
_initialLoading.DoProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,6 @@ using Code.Infrastructure.SceneLoader;
|
||||
using Reflex.Core;
|
||||
using Reflex.Enums;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Resolution = Reflex.Enums.Resolution;
|
||||
|
||||
namespace Code.Infrastructure.App.SceneInstallers
|
||||
@@ -23,6 +22,8 @@ namespace Code.Infrastructure.App.SceneInstallers
|
||||
containerBuilder.RegisterValue(raceTrackData);
|
||||
containerBuilder.RegisterType(typeof(RaceGame), Lifetime.Scoped,
|
||||
Resolution.Lazy);
|
||||
containerBuilder.RegisterType(typeof(PlayerPrefsRacePoopshitter), Lifetime.Scoped,
|
||||
Resolution.Lazy);
|
||||
|
||||
containerBuilder.OnContainerBuilt += PostInstall;
|
||||
}
|
||||
|
||||
@@ -48,11 +48,13 @@ namespace Code.Infrastructure.App.States
|
||||
// Factory
|
||||
// PlayerCounter
|
||||
// WinScreen
|
||||
// ScoreScreen
|
||||
// CinemachineCamera
|
||||
_gameplayLoading = new Loading(6, GameplayLoadingCompleted);
|
||||
_gameplayLoading = new Loading(7, GameplayLoadingCompleted);
|
||||
|
||||
Context.UIService.TryLoadPanel(UIPanelType.PlayerScoreCounter);
|
||||
Context.UIService.TryLoadPanel(UIPanelType.WinScreen);
|
||||
Context.UIService.TryLoadPanel(UIPanelType.PlayerScores);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Gameplay, LoadSceneMode.Single).Forget();
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
Context.CameraFactory.LoadCinemachineCamera(CameraMode.ThirdPerson).Forget();
|
||||
@@ -73,14 +75,15 @@ namespace Code.Infrastructure.App.States
|
||||
_raceGame.PlacedRacers[0].gameObject.transform;
|
||||
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
|
||||
_raceGame.StartRacers();
|
||||
}
|
||||
|
||||
protected override void OnExitState()
|
||||
{
|
||||
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
||||
{
|
||||
Context.UIService.TryRemovePanel(UIPanelType.PlayerScoreCounter);
|
||||
Context.UIService.TryRemovePanel(UIPanelType.WinScreen);
|
||||
Context.UIService.TryRemovePanel(UIPanelType.PlayerScores);
|
||||
Context.CameraFactory.ReleaseCinemachineCamera(CameraMode.ThirdPerson);
|
||||
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
||||
|
||||
@@ -125,9 +128,14 @@ namespace Code.Infrastructure.App.States
|
||||
for (var i = 0; i < cachedScores.Count; i++)
|
||||
if (cachedScores[i].Key.Data.type == RacerType.Player) id = i + 1;
|
||||
|
||||
UNTILTHEYFIXCONTAINERS.Resolve<PlayerPrefsRacePoopshitter>().AddRace(new(_raceGame.RaceTime, id));
|
||||
|
||||
var winText = $@"{id} МЕСТО\n";
|
||||
winScreen.SetText(winText);
|
||||
|
||||
|
||||
var getPanel = Context.UIService.TryGetPanel(UIPanelType.PlayerScores);
|
||||
((PlayerScores)getPanel)
|
||||
.SetText(UNTILTHEYFIXCONTAINERS.Resolve<PlayerPrefsRacePoopshitter>().GetRaces());
|
||||
Context.UIService.ClosePanel(UIPanelType.PlayerScoreCounter);
|
||||
Context.UIService.OpenPanel(UIPanelType.WinScreen);
|
||||
|
||||
@@ -137,7 +145,11 @@ namespace Code.Infrastructure.App.States
|
||||
private async UniTaskVoid EndTheGame()
|
||||
{
|
||||
await UniTask.WaitForSeconds(3f);
|
||||
Context.UIService.ClosePanel(UIPanelType.WinScreen);
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.PlayerScores);
|
||||
await UniTask.WaitForSeconds(5f);
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.Loading);
|
||||
Context.StateMachine.SwitchState(AppStates.MainMenu).AllowStateTransition(AppStates.Gameplay);
|
||||
}
|
||||
@@ -151,7 +163,7 @@ namespace Code.Infrastructure.App.States
|
||||
|
||||
public void UILoaded(UIPanelType uiPanelType)
|
||||
{
|
||||
if(uiPanelType == UIPanelType.WinScreen)
|
||||
if(uiPanelType is UIPanelType.WinScreen or UIPanelType.PlayerScores)
|
||||
{
|
||||
_gameplayLoading.DoProgress();
|
||||
return;
|
||||
|
||||
@@ -13,18 +13,16 @@ namespace Code.Infrastructure.App.States
|
||||
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class MainMenuState : IUIPanelLoaded, IReadyToPlayHandle, IOnMainMenuSceneLoadedHandler
|
||||
{
|
||||
private EventBus.EventBus _eventBus;
|
||||
{
|
||||
public MainMenuState(AppStateMachineContext context, EventBus.EventBus eventBus) : base(context,eventBus)
|
||||
{
|
||||
_eventBus = eventBus;
|
||||
{
|
||||
}
|
||||
|
||||
public override AppStates myState => AppStates.MainMenu;
|
||||
private Loading _loading;
|
||||
protected override void OnEnterState()
|
||||
{
|
||||
_eventBus.Subscribe(this);
|
||||
EventBus.Subscribe(this);
|
||||
|
||||
_loading = new Loading(2, LoadComplete);
|
||||
|
||||
@@ -38,7 +36,7 @@ namespace Code.Infrastructure.App.States
|
||||
{
|
||||
// Context.AudioFactory.ReleaseAudios(AudioNames.UISounds);
|
||||
Context.UIService.TryRemovePanel(UIPanelType.DebugSceneChooser);
|
||||
_eventBus.Unsubscribe(this);
|
||||
EventBus.Unsubscribe(this);
|
||||
}
|
||||
|
||||
public void UILoaded(UIPanelType uiPanelType)
|
||||
|
||||
Reference in new issue
Block a user