Platformer example started
This commit is contained in:
1 parent
efcfaae647
commit
9f026b76d6
325 files changed
+23540
-270
No files matched your search
@@ -0,0 +1,65 @@
|
||||
using Code.Infrastructure.App;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Code.Infrastructure.Generators;
|
||||
using Code.Infrastructure.Input;
|
||||
using Code.Infrastructure.Loadings;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Reflex.Core;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Code.Example.Platformer
|
||||
{
|
||||
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class PlatformerState : IOnPlatformerSceneLoadedHandler, ICinematicMachineHandle
|
||||
{
|
||||
public PlatformerState(AppStateMachineContext context, EventBus eventBus) : base(context, eventBus)
|
||||
{
|
||||
}
|
||||
|
||||
public override AppStates myState => AppStates.Platformer;
|
||||
protected override void OnEnterState()
|
||||
{
|
||||
EventBus.Subscribe(this);
|
||||
|
||||
_loading = new(2, LoadingCompleted);
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.Loading);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Platformer, LoadSceneMode.Single).Forget();
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
Context.CameraFactory.LoadCinemachineCamera(CameraMode.Platformer).Forget();
|
||||
}
|
||||
private Loading _loading;
|
||||
|
||||
private void LoadingCompleted()
|
||||
{
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnExitState()
|
||||
{
|
||||
Context.CameraFactory.ReleaseCinemachineCamera(CameraMode.Platformer);
|
||||
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
||||
EventBus.Unsubscribe(this);
|
||||
}
|
||||
|
||||
public void OnPlatformerSceneLoaded()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void OnPlatformerSceneInitialized(Container container)
|
||||
{
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
public void CinemachineLoaded(CinemachineCamera cinemachineCamera)
|
||||
{
|
||||
_loading.DoProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user