예제 #1
0
        public BehaviourTree Create(IServicesInjector gamePlayDependencies)
        {
            var tree = new TBehaviourTree();

            tree.LoadTree();
            var nodes = tree.TreeNodes.ToList();

            var localInjector = TorqueGamesInjector.GetEmpty();
            var localLinker   = localInjector.GetLinker();

            foreach (var node in nodes)
            {
                node.Init(gamePlayDependencies);
            }
            foreach (var node in nodes)
            {
                node.WriteLocalDependencies(localLinker);
            }
            foreach (var node in nodes)
            {
                node.ReadLocalDependencies(localInjector);
            }

            foreach (var node in nodes)
            {
                node.StartGame();
            }

            return(tree);
        }
예제 #2
0
 public override void WriteDependencies(IDependencyLinker linker, IServicesInjector gamePlayServices)
 {
     _camera = GetComponent <Camera>();
     linker
     .LinkInterface <ICameraBinder>()
     .WithGivenInstance(this);
 }
예제 #3
0
        private void LoadGameSession(IServicesInjector services)
        {
            var gameSession = services.Get <IGameSession>();

            if (gameCharacterPrefab == null)
            {
                gameCharacterPrefab = gameSession.PrefabToSpawn;
            }

            CurrentCharacter = Instantiate(gameCharacterPrefab, transform, false);
            CurrentCharacter.transform.position = transformData.position;
            CurrentCharacter.transform.rotation = transformData.rotation;
            CurrentCharacter.SetupData(gameSession.InstanceData, services);
            transformData.gameObject.SetActive(false);
        }
        public virtual Task StartGame(IServicesInjector services)
        {
            if (Components.Count != arrayTasks.Length)
            {
                arrayTasks = new Task[Components.Count];
            }
            var i = 0;

            foreach (var gameComponent in Components)
            {
                arrayTasks[i] = gameComponent.StartGame(services);
                i++;
            }
            return(Task.WhenAll(arrayTasks));
        }
        public static IServiceCollection AddEventBus <TConfiguration>(this IServiceCollection services, Assembly assemblyToScan, Action <TConfiguration> configure = null)
            where TConfiguration : IConfiguration, new()
        {
            TConfiguration configuration = new TConfiguration();

            configure?.Invoke(configuration);
            ISettings settings = configuration.BuildSettings();

            IServicesInjector injector = CreateServiceInjector <TConfiguration>();

            injector.AddPersistentConnection(services, settings);
            injector.AddSubscriptionManager(services);
            injector.AddEventBus(services, settings);
            injector.AddHandlers(services, assemblyToScan);

            return(services);
        }
예제 #6
0
 public virtual void Init(IServicesInjector gamePlayServices)
 {
 }
예제 #7
0
        public override async Task StartGame(IServicesInjector services)
        {
            await CurrentCharacter.StartGame(services);

            CurrentCharacter.gameObject.SetActive(true);
        }
예제 #8
0
 public override void EarlyInitialization(IServicesInjector gamePlayServices)
 {
     CurrentCharacter.EarlyInitialization(gamePlayServices);
 }
예제 #9
0
 public override void WriteDependencies(IDependencyLinker linker, IServicesInjector services)
 {
     _linker = linker;
     LoadGameSession(services);
     CurrentCharacter.WriteDependencies(_linker, services);
 }
예제 #10
0
 public override void WriteDependencies(IDependencyLinker linker, IServicesInjector externalDependencies)
 {
     linker.LinkInterface <IPlayerBinder>().WithGivenInstance(this);
 }
예제 #11
0
 public abstract void SetupData(ICharacterInstanceData data, IServicesInjector gamePlayInjector);
예제 #12
0
 public void SetupData(IServicesInjector injector, TorqueGamesInjector playerInjector)
 {
     GamePlayDependencies = injector;
     InitializeLocalDependencies(playerInjector);
 }
예제 #13
0
 public virtual void WriteDependencies(IDependencyLinker linker, IServicesInjector externalDependencies)
 {
 }
예제 #14
0
 public void ReadLocalDependencies(IServicesInjector localDependencies)
 {
 }
예제 #15
0
 public override void EarlyInitialization(IServicesInjector gamePlayServices)
 {
     model = gamePlayServices.Get <IPlayerAnimatorModel>();
 }
예제 #16
0
 public override void EarlyInitialization(IServicesInjector gamePlayServices)
 {
     Camera       = gamePlayServices.Get <ICameraBinder>().GetCamera();
     PlayerBinder = gamePlayServices.Get <IPlayerBinder>();
 }
 public override void EarlyInitialization(IServicesInjector gamePlayServices)
 {
     PlayerAimHelper = gamePlayServices.Get <IPlayerAimHelper>();
     model           = gamePlayServices.Get <IPlayerMovementModel>();
     //rb = gamePlayServices.Get<PlayerBinder>().Rigidbody;
 }
예제 #18
0
 public CharacterFactory(IServicesInjector gameInjector, IDependencyLinker gamePlayLinker)
 {
     _gameInjector   = gameInjector;
     _gamePlayLinker = gamePlayLinker;
 }
예제 #19
0
 public virtual Task StartGame(IServicesInjector services) => Task.CompletedTask;
예제 #20
0
 public virtual void EarlyInitialization(IServicesInjector gamePlayServices)
 {
 }