72 lines
2.5 KiB
C#
72 lines
2.5 KiB
C#
using System;
|
|
using Code.Example.Platformer.Entity;
|
|
using Code.Example.Platformer.Level;
|
|
using Code.Infrastructure.EventBus;
|
|
using Code.Infrastructure.Loadings;
|
|
using Code.Infrastructure.SceneLoader;
|
|
using Reflex.Core;
|
|
using Reflex.Enums;
|
|
using UnityEngine;
|
|
using Resolution = Reflex.Enums.Resolution;
|
|
|
|
namespace Code.Example.Platformer
|
|
{
|
|
public class PlatformerEnemySceneInstaller :
|
|
MonoBehaviour,
|
|
IInstaller,
|
|
IPlatformerEnemyFactoryInitializedHandle,
|
|
IPlatformerPlayerFactoryInitializedHandle,
|
|
IDisposable
|
|
{
|
|
// [SerializeField] private PlatformerCanvas gameplayPlatformerCanvas;
|
|
[SerializeField] private PlatformerFirstLevelData firstLevelData;
|
|
|
|
private Loading _sceneInit;
|
|
|
|
private void LoadingComplete()
|
|
{
|
|
_container.Resolve<EventBus>()
|
|
.RaiseEvent<IOnPlatformerSceneLoadedHandler>(x => x.OnPlatformerSceneInitialized(_container));
|
|
}
|
|
|
|
public void InstallBindings(ContainerBuilder containerBuilder)
|
|
{
|
|
// Enemies
|
|
// Player
|
|
// Container
|
|
_sceneInit = new(3, LoadingComplete);
|
|
|
|
// containerBuilder.RegisterValue(gameplayPlatformerCanvas);
|
|
containerBuilder.Parent.Resolve<EventBus>().Subscribe(this);
|
|
|
|
containerBuilder.RegisterValue(firstLevelData);
|
|
containerBuilder.RegisterType(typeof(PlatformerEnemyFactory), new []{typeof(IPlatformerEnemyFactory)}, Lifetime.Scoped, Resolution.Eager);
|
|
containerBuilder.RegisterType(typeof(PlatformerPlayerFactory), new []{typeof(IPlatformerPlayerFactory)}, Lifetime.Scoped, Resolution.Eager);
|
|
containerBuilder.OnContainerBuilt += OnContainerBuild;
|
|
}
|
|
private Container _container;
|
|
private void OnContainerBuild(Container container)
|
|
{
|
|
// gameplayPlatformerCanvas.GameplayPlatformerCanvas.worldCamera =
|
|
// container.Resolve<CameraStateMachineContext>().cameraLoadedData.Camera;
|
|
|
|
_container = container;
|
|
_sceneInit.DoProgress();
|
|
}
|
|
|
|
public void PlatformerEnemyFactoryInitialized()
|
|
{
|
|
_sceneInit.DoProgress();
|
|
}
|
|
|
|
public void PlatformerPlayerFactoryInitialized()
|
|
{
|
|
_sceneInit.DoProgress();
|
|
}
|
|
|
|
public void Dispose()
|
|
{
|
|
_container.Resolve<EventBus>().Unsubscribe(this);
|
|
}
|
|
}
|
|
} |