Миксер
Почини интерфейс
This commit is contained in:
1 parent
1aceea1b79
commit
60c28f54f2
74 files changed
+8060
-1059
No files matched your search
@@ -9,12 +9,18 @@ using Code.Infrastructure.Input;
|
||||
using Code.Infrastructure.Loadings;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Code.Infrastructure.UI.Panels;
|
||||
using Reflex.Core;
|
||||
using Unity.Cinemachine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Code.Example.Platformer
|
||||
{
|
||||
public interface IPlayerReachedFinishHandle : IGlobalSubscriber
|
||||
{
|
||||
void PlayerReachedFinish();
|
||||
}
|
||||
|
||||
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class PlatformerState :
|
||||
@@ -26,7 +32,11 @@ namespace Code.Example.Platformer
|
||||
IPlatformerPlayerLoadedHandle,
|
||||
IPlatformerPlayerSpawnedHandle,
|
||||
IReadyToPlayHandle,
|
||||
IPlayerReachedFinishHandle
|
||||
IPlayerReachedFinishHandle,
|
||||
ILoadingPanelOpenedHandle,
|
||||
ILoadingPanelClosedHandle,
|
||||
IPlatformerEnemySpawnedHandle,
|
||||
IPlayerDiedHandle
|
||||
{
|
||||
private IPlatformerEnemyFactory _enemyFactory;
|
||||
private IPlatformerPlayerFactory _playerFactory;
|
||||
@@ -37,7 +47,7 @@ namespace Code.Example.Platformer
|
||||
|
||||
private Container _fixdamncontainer;
|
||||
|
||||
private Loading _loading;
|
||||
private Loading _loading;
|
||||
|
||||
public PlatformerState(AppStateMachineContext context, EventBus eventBus) : base(context, eventBus)
|
||||
{
|
||||
@@ -49,30 +59,11 @@ namespace Code.Example.Platformer
|
||||
{
|
||||
EventBus.Subscribe(this);
|
||||
|
||||
// Dependency scene
|
||||
// Level scene
|
||||
// Camera
|
||||
// Enemy snail
|
||||
// Enemy bee
|
||||
// Enemy boar
|
||||
// Player
|
||||
// Music
|
||||
_loading = new(8, InitialLoadingCompleted);
|
||||
// LoadingScreen
|
||||
_loading = new(1, StartInitialLoading);
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.Loading);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Platformer, LoadSceneMode.Single).Forget();
|
||||
Context.InputService.EnableMap(ActionMappings.Platformer);
|
||||
Context.CameraFactory.LoadCinemachineCamera(CameraMode.Platformer).Forget();
|
||||
}
|
||||
private void InitialLoadingCompleted()
|
||||
{
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
|
||||
_enemyFactory.SpawnEnemy(PlatformerEntityType.Boar, _currentLevelData.enemySpawnPoints[0].position);
|
||||
|
||||
_playerFactory.SpawnPlayer(_currentLevelData.playerCheckPoints[0].position);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnExitState()
|
||||
{
|
||||
@@ -83,10 +74,51 @@ namespace Code.Example.Platformer
|
||||
_playerFactory.ReleasePlayer();
|
||||
|
||||
Context.CameraFactory.ReleaseCinemachineCamera(CameraMode.Platformer);
|
||||
EventBus.Unsubscribe(this);
|
||||
Context.InputService.DisableMap(ActionMappings.Platformer);
|
||||
|
||||
_audioFactory.ReleaseAudios(AudioNames.Platformer);
|
||||
|
||||
EventBus.Unsubscribe(this);
|
||||
}
|
||||
|
||||
private void StartInitialLoading()
|
||||
{
|
||||
|
||||
// Dependency scene
|
||||
// Level scene
|
||||
// Camera
|
||||
// Enemy snail
|
||||
// Enemy bee
|
||||
// Enemy boar
|
||||
// Player
|
||||
// Music
|
||||
_loading = new(8, InitialLoadingCompleted);
|
||||
|
||||
Context.AudioService.ChangeGroupVolume(
|
||||
AudioGroupType.Music,
|
||||
1f,
|
||||
0.5f,
|
||||
() => Context.AudioService.PlayRepeatedly(AudioNames.Platformer,0, AudioGroupType.Music));
|
||||
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Platformer, LoadSceneMode.Single).Forget();
|
||||
Context.InputService.EnableMap(ActionMappings.Platformer);
|
||||
Context.CameraFactory.LoadCinemachineCamera(CameraMode.Platformer).Forget();
|
||||
}
|
||||
|
||||
private void InitialLoadingCompleted()
|
||||
{
|
||||
_loading = new Loading(2, CloseLevel1LoadingScreen);
|
||||
|
||||
_enemyFactory.SpawnEnemy(PlatformerEntityType.Snail, _currentLevelData.enemySpawnPoints[0].position);
|
||||
|
||||
_playerFactory.SpawnPlayer(_currentLevelData.playerCheckPoints[0].position);
|
||||
}
|
||||
|
||||
private void CloseLevel1LoadingScreen()
|
||||
{
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
|
||||
EventBus.RaiseEvent<IGameplayFreezeable>(x=> x.UnFreeze());
|
||||
}
|
||||
|
||||
|
||||
@@ -110,6 +142,13 @@ namespace Code.Example.Platformer
|
||||
_playerEntity = entity;
|
||||
|
||||
Context.CameraFactory.GetCinematicCamera(CameraMode.Platformer).Follow = entity.transform;
|
||||
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
public void PlatformerEnemySpawned(Entity.Entity entity)
|
||||
{
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
public void OnReadyToPlay(AudioNames groupName)
|
||||
@@ -119,25 +158,40 @@ namespace Code.Example.Platformer
|
||||
|
||||
public void PlayerReachedFinish()
|
||||
{
|
||||
_loading = new(1, Level2LoadingCompleted);
|
||||
_loading = new Loading(1, StartLevel2Loading);
|
||||
|
||||
Context.AudioService.ChangeGroupVolume(
|
||||
AudioGroupType.Music,
|
||||
0f,
|
||||
0.5f,
|
||||
() => Context.AudioService.CancelMusic(AudioNames.Platformer, 0));
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.Loading);
|
||||
|
||||
_playerEntity.Freeze();
|
||||
EventBus.RaiseEvent<IGameplayFreezeable>(x=> x.Freeze());
|
||||
|
||||
SceneManager.MoveGameObjectToScene(_playerEntity.gameObject, Context.SceneLoader.GetScene(SceneId.Platformer));
|
||||
}
|
||||
|
||||
private void StartLevel2Loading()
|
||||
{
|
||||
_loading = new(2, StartLevel2Gameplay);
|
||||
|
||||
Context.SceneLoader.UnloadSceneAsync(SceneId.Platformer2).Forget();
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Platformer3, LoadSceneMode.Additive).Forget();
|
||||
}
|
||||
|
||||
private void Level2LoadingCompleted()
|
||||
|
||||
private void StartLevel2Gameplay()
|
||||
{
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
Context.AudioService.ChangeGroupVolume(
|
||||
AudioGroupType.Music,
|
||||
1f,
|
||||
0.5f,
|
||||
() => Context.AudioService.PlayRepeatedly(AudioNames.Platformer,7, AudioGroupType.Music));
|
||||
|
||||
_enemyFactory.SpawnEnemy(PlatformerEntityType.Boar, _currentLevelData.enemySpawnPoints[0].position);
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
|
||||
_playerEntity.transform.position = _currentLevelData.playerCheckPoints[0].position;
|
||||
_playerEntity.UnFreeze();
|
||||
EventBus.RaiseEvent<IGameplayFreezeable>(x=> x.UnFreeze());
|
||||
}
|
||||
|
||||
public void OnPlatformerSceneLoaded()
|
||||
@@ -179,6 +233,13 @@ namespace Code.Example.Platformer
|
||||
|
||||
public void OnPlatformer3SceneLoaded()
|
||||
{
|
||||
SceneManager.SetActiveScene(Context.SceneLoader.GetScene(SceneId.Platformer3));
|
||||
|
||||
_enemyFactory.SpawnEnemy(PlatformerEntityType.Boar, _currentLevelData.enemySpawnPoints[0].position);
|
||||
|
||||
_playerEntity.transform.position = _currentLevelData.playerCheckPoints[0].position;
|
||||
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
public void OnPlatformer3SceneInitialized(Container container)
|
||||
@@ -187,10 +248,20 @@ namespace Code.Example.Platformer
|
||||
|
||||
_loading.DoProgress();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IPlayerReachedFinishHandle : IGlobalSubscriber
|
||||
{
|
||||
void PlayerReachedFinish();
|
||||
public void LoadingPanelOpened(UIPanel panel)
|
||||
{
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
public void LoadingPanelClosed()
|
||||
{
|
||||
}
|
||||
|
||||
public void PlayerDied()
|
||||
{
|
||||
Context.StateMachine.SwitchState(AppStates.MainMenu)
|
||||
.AllowStateTransition(AppStates.Platformer);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user