Фабрика противников
This commit is contained in:
1 parent
93819c1dd3
commit
653342d080
35 files changed
+527
-406
No files matched your search
@@ -1,3 +1,5 @@
|
||||
using Code.Example.Platformer.Entity;
|
||||
using Code.Example.Platformer.Level;
|
||||
using Code.Infrastructure.App;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Camera;
|
||||
@@ -15,7 +17,7 @@ namespace Code.Example.Platformer
|
||||
{
|
||||
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class PlatformerState : IOnPlatformerSceneLoadedHandler, ICinematicMachineHandle
|
||||
public partial class PlatformerState : IOnPlatformerSceneLoadedHandler, ICinematicMachineHandle, IPlatformerEnemyLoadedHandle
|
||||
{
|
||||
public PlatformerState(AppStateMachineContext context, EventBus eventBus) : base(context, eventBus)
|
||||
{
|
||||
@@ -26,7 +28,12 @@ namespace Code.Example.Platformer
|
||||
{
|
||||
EventBus.Subscribe(this);
|
||||
|
||||
_loading = new(2, LoadingCompleted);
|
||||
// Scene
|
||||
// Camera
|
||||
// Enemy snail
|
||||
// Enemy bee
|
||||
// Enemy boar
|
||||
_loading = new(5, LoadingCompleted);
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.Loading);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Platformer, LoadSceneMode.Single).Forget();
|
||||
@@ -39,14 +46,20 @@ namespace Code.Example.Platformer
|
||||
{
|
||||
Context.AudioService.CancelMusic(AudioNames.UISounds,0);
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
|
||||
_enemyFactory.SpawnEnemy(PlatformerEntityType.Snail, _firstLevelData.enemySpawnPoints[0].position);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnExitState()
|
||||
{
|
||||
{
|
||||
_enemyFactory.ReleaseEnemy(PlatformerEntityType.Bee);
|
||||
_enemyFactory.ReleaseEnemy(PlatformerEntityType.Snail);
|
||||
_enemyFactory.ReleaseEnemy(PlatformerEntityType.Boar);
|
||||
|
||||
Context.CameraFactory.ReleaseCinemachineCamera(CameraMode.Platformer);
|
||||
Context.InputService.DisableMap(ActionMappings.Platformer);
|
||||
EventBus.Unsubscribe(this);
|
||||
Context.InputService.DisableMap(ActionMappings.Platformer);
|
||||
}
|
||||
|
||||
public void OnPlatformerSceneLoaded()
|
||||
@@ -54,14 +67,30 @@ namespace Code.Example.Platformer
|
||||
|
||||
}
|
||||
|
||||
private IPlatformerEnemyFactory _enemyFactory;
|
||||
private PlatformerFirstLevelData _firstLevelData;
|
||||
public void OnPlatformerSceneInitialized(Container container)
|
||||
{
|
||||
_firstLevelData = container.Resolve<PlatformerFirstLevelData>();
|
||||
_enemyFactory = container.Resolve<IPlatformerEnemyFactory>();
|
||||
|
||||
_enemyFactory.LoadEnemy(PlatformerEntityType.Bee);
|
||||
_enemyFactory.LoadEnemy(PlatformerEntityType.Boar);
|
||||
_enemyFactory.LoadEnemy(PlatformerEntityType.Snail);
|
||||
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void CinemachineLoaded(CinemachineCamera cinemachineCamera)
|
||||
{
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
public void PlatformerEnemyLoaded(PlatformerEntityType type, Entity.Entity entity)
|
||||
{
|
||||
if(entity) _loading.DoProgress();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user