Фабрика игрока
This commit is contained in:
1 parent
653342d080
commit
a7872a0f8c
45 files changed
+395
-168
No files matched your search
@@ -17,7 +17,12 @@ namespace Code.Example.Platformer
|
||||
{
|
||||
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class PlatformerState : IOnPlatformerSceneLoadedHandler, ICinematicMachineHandle, IPlatformerEnemyLoadedHandle
|
||||
public partial class PlatformerState :
|
||||
IOnPlatformerSceneLoadedHandler,
|
||||
ICinematicMachineHandle,
|
||||
IPlatformerEnemyLoadedHandle,
|
||||
IPlatformerPlayerLoadedHandle,
|
||||
IPlatformerPlayerSpawnedHandle
|
||||
{
|
||||
public PlatformerState(AppStateMachineContext context, EventBus eventBus) : base(context, eventBus)
|
||||
{
|
||||
@@ -33,7 +38,8 @@ namespace Code.Example.Platformer
|
||||
// Enemy snail
|
||||
// Enemy bee
|
||||
// Enemy boar
|
||||
_loading = new(5, LoadingCompleted);
|
||||
// Player
|
||||
_loading = new(6, LoadingCompleted);
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.Loading);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Platformer, LoadSceneMode.Single).Forget();
|
||||
@@ -48,6 +54,8 @@ namespace Code.Example.Platformer
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
|
||||
_enemyFactory.SpawnEnemy(PlatformerEntityType.Snail, _firstLevelData.enemySpawnPoints[0].position);
|
||||
|
||||
_playerFactory.SpawnPlayer(_firstLevelData.playerCheckPoints[0].position);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +65,8 @@ namespace Code.Example.Platformer
|
||||
_enemyFactory.ReleaseEnemy(PlatformerEntityType.Snail);
|
||||
_enemyFactory.ReleaseEnemy(PlatformerEntityType.Boar);
|
||||
|
||||
_playerFactory.ReleasePlayer();
|
||||
|
||||
Context.CameraFactory.ReleaseCinemachineCamera(CameraMode.Platformer);
|
||||
EventBus.Unsubscribe(this);
|
||||
Context.InputService.DisableMap(ActionMappings.Platformer);
|
||||
@@ -68,9 +78,14 @@ namespace Code.Example.Platformer
|
||||
}
|
||||
|
||||
private IPlatformerEnemyFactory _enemyFactory;
|
||||
private IPlatformerPlayerFactory _playerFactory;
|
||||
private PlatformerFirstLevelData _firstLevelData;
|
||||
|
||||
private Container _fixdamncontainer;
|
||||
|
||||
public void OnPlatformerSceneInitialized(Container container)
|
||||
{
|
||||
_fixdamncontainer = container;
|
||||
_firstLevelData = container.Resolve<PlatformerFirstLevelData>();
|
||||
_enemyFactory = container.Resolve<IPlatformerEnemyFactory>();
|
||||
|
||||
@@ -78,6 +93,10 @@ namespace Code.Example.Platformer
|
||||
_enemyFactory.LoadEnemy(PlatformerEntityType.Boar);
|
||||
_enemyFactory.LoadEnemy(PlatformerEntityType.Snail);
|
||||
|
||||
_playerFactory = container.Resolve<IPlatformerPlayerFactory>();
|
||||
|
||||
_playerFactory.LoadPlayer();
|
||||
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
@@ -92,5 +111,15 @@ namespace Code.Example.Platformer
|
||||
{
|
||||
if(entity) _loading.DoProgress();
|
||||
}
|
||||
|
||||
public void PlatformerPlayerLoaded()
|
||||
{
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
public void PlatformerPlayerSpawned(Entity.Entity entity)
|
||||
{
|
||||
Context.CameraFactory.GetCinematicCamera(CameraMode.Platformer).Follow = entity.transform;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user