Развитие гоночек
This commit is contained in:
1 parent
ec60c47652
commit
b54083521f
532 files changed
+16091
-28231
No files matched your search
@@ -1,31 +1,102 @@
|
||||
using Code.Example.Race;
|
||||
using Code.Example.Race.Racer;
|
||||
using Code.Example.Race.Track;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Camera.CameraStates;
|
||||
using Code.Infrastructure.Generators;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using UnityEngine;
|
||||
using Code.Infrastructure.Input;
|
||||
using Code.Infrastructure.Loadings;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Reflex.Core;
|
||||
using Reflex.Injectors;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Code.Infrastructure.App.States
|
||||
{
|
||||
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class GameplayState : IOnGameplaySceneLoadedHandler
|
||||
[State(typeof(AppStates), typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class GameplayState : IOnGameplaySceneLoadedHandler, IRaceGameInitializedHandle, IRacerFactoryInitializedHandle, IUIPanelLoaded
|
||||
{
|
||||
public GameplayState(AppStateMachineContext context, EventBus.EventBus eventBus) : base(context, eventBus)
|
||||
{
|
||||
}
|
||||
|
||||
public override AppStates myState => AppStates.Gameplay;
|
||||
|
||||
private Loading _gameplayLoading;
|
||||
|
||||
protected override void OnEnterState()
|
||||
{
|
||||
|
||||
EventBus.Subscribe(this);
|
||||
Context.UIService.OpenPanel(UIPanelType.Loading);
|
||||
|
||||
// Scene
|
||||
// RaceGame
|
||||
// Factory
|
||||
// PlayerCounter
|
||||
_gameplayLoading = new Loading(4, GameplayLoadingCompleted);
|
||||
Context.UIService.TryLoadPanel(UIPanelType.PlayerScoreCounter);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Gameplay, LoadSceneMode.Single).Forget();
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
}
|
||||
|
||||
private void GameplayLoadingCompleted()
|
||||
{
|
||||
_raceGame.PlaceRacers();
|
||||
|
||||
Context.Camera.SwitchState(CameraMode.ThirdPerson).AllowStateTransition(CameraMode.None);
|
||||
((ThirdPersonState)Context.Camera.CurrentBaseState).SetFollowTarget(_raceGame.PlacedRacers[0].gameObject.transform, _raceGame.PlacedRacers[0].CarRigidbody);
|
||||
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
_raceGame.StartRacers();
|
||||
}
|
||||
|
||||
protected override void OnExitState()
|
||||
{
|
||||
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
||||
Context.UIService.TryRemovePanel(UIPanelType.PlayerScoreCounter);
|
||||
EventBus.Unsubscribe(this);
|
||||
}
|
||||
|
||||
public void OnGameplaySceneLoaded()
|
||||
{
|
||||
}
|
||||
|
||||
private RaceTrackData _raceTrackData;
|
||||
private RaceGame _raceGame;
|
||||
private Container UNTILTHEYFIXCONTAINERS;
|
||||
public void OnGameplaySceneInitialized(Container container)
|
||||
{
|
||||
_raceTrackData = container.Resolve<RaceTrackData>();
|
||||
|
||||
Context.Camera.Camera.transform.position = _raceTrackData.CameraPosition.transform.position;
|
||||
Context.Camera.Camera.transform.rotation = _raceTrackData.CameraPosition.transform.rotation;
|
||||
|
||||
UNTILTHEYFIXCONTAINERS = container;
|
||||
_gameplayLoading.DoProgress();
|
||||
|
||||
container.Resolve<IRacerFactory>();
|
||||
}
|
||||
|
||||
public void RaceGameReady()
|
||||
{
|
||||
_gameplayLoading.DoProgress();
|
||||
}
|
||||
|
||||
public void RacerFactoryInitialized()
|
||||
{
|
||||
_raceGame = (RaceGame)ConstructorInjector.Construct(typeof(RaceGame), UNTILTHEYFIXCONTAINERS);
|
||||
|
||||
_gameplayLoading.DoProgress();
|
||||
}
|
||||
|
||||
public void UILoaded(UIPanelType uiPanelType)
|
||||
{
|
||||
if (uiPanelType != UIPanelType.PlayerScoreCounter) return;
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.PlayerScoreCounter);
|
||||
_gameplayLoading.DoProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user