Example #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);
        }
Example #2
0
 public override void WriteDependencies(IDependencyLinker linker, IServicesInjector gamePlayServices)
 {
     _camera = GetComponent <Camera>();
     linker
     .LinkInterface <ICameraBinder>()
     .WithGivenInstance(this);
 }
Example #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);
        }
Example #6
0
 public virtual void Init(IServicesInjector gamePlayServices)
 {
 }
Example #7
0
        public override async Task StartGame(IServicesInjector services)
        {
            await CurrentCharacter.StartGame(services);

            CurrentCharacter.gameObject.SetActive(true);
        }
Example #8
0
 public override void EarlyInitialization(IServicesInjector gamePlayServices)
 {
     CurrentCharacter.EarlyInitialization(gamePlayServices);
 }
Example #9
0
 public override void WriteDependencies(IDependencyLinker linker, IServicesInjector services)
 {
     _linker = linker;
     LoadGameSession(services);
     CurrentCharacter.WriteDependencies(_linker, services);
 }
Example #10
0
 public override void WriteDependencies(IDependencyLinker linker, IServicesInjector externalDependencies)
 {
     linker.LinkInterface <IPlayerBinder>().WithGivenInstance(this);
 }
 public abstract void SetupData(ICharacterInstanceData data, IServicesInjector gamePlayInjector);
Example #12
0
 public void SetupData(IServicesInjector injector, TorqueGamesInjector playerInjector)
 {
     GamePlayDependencies = injector;
     InitializeLocalDependencies(playerInjector);
 }
Example #13
0
 public virtual void WriteDependencies(IDependencyLinker linker, IServicesInjector externalDependencies)
 {
 }
Example #14
0
 public void ReadLocalDependencies(IServicesInjector localDependencies)
 {
 }
Example #15
0
 public override void EarlyInitialization(IServicesInjector gamePlayServices)
 {
     model = gamePlayServices.Get <IPlayerAnimatorModel>();
 }
Example #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;
 }
Example #18
0
 public CharacterFactory(IServicesInjector gameInjector, IDependencyLinker gamePlayLinker)
 {
     _gameInjector   = gameInjector;
     _gamePlayLinker = gamePlayLinker;
 }
Example #19
0
 public virtual Task StartGame(IServicesInjector services) => Task.CompletedTask;
Example #20
0
 public virtual void EarlyInitialization(IServicesInjector gamePlayServices)
 {
 }