static void SetupTriggerGimmicks(IEnumerable <GameObject> rootGameObjects, ItemCreator itemCreator, ItemDestroyer itemDestroyer)
        {
            RoomStateRepository = new RoomStateRepository();
            GimmickManager      = new GimmickManager(RoomStateRepository, itemCreator, itemDestroyer);
            SignalGenerator     = new SignalGenerator();
            var triggerManager = new TriggerManager(RoomStateRepository, itemCreator, GimmickManager, SignalGenerator);
            var items          = GetComponentsInGameObjectsChildren <IItem>(rootGameObjects).ToArray();

            triggerManager.Add(items.SelectMany(x => x.gameObject.GetComponents <IItemTrigger>()));
            triggerManager.Add(GetComponentsInGameObjectsChildren <IPlayerTrigger>(rootGameObjects));
            triggerManager.Add(GetComponentsInGameObjectsChildren <IGlobalTrigger>(rootGameObjects));
            GimmickManager.AddGimmicksInScene(GetComponentsInGameObjectsChildren <IGimmick>(rootGameObjects));
            foreach (var item in items)
            {
                GimmickManager.AddGimmicksInItem(item.gameObject.GetComponentsInChildren <IGimmick>(true), item.Id.Value);
            }

            new LogicManager(itemCreator, RoomStateRepository, GimmickManager,
                             GetComponentsInGameObjectsChildren <IItemLogic>(rootGameObjects),
                             GetComponentsInGameObjectsChildren <IPlayerLogic>(rootGameObjects),
                             GetComponentsInGameObjectsChildren <IGlobalLogic>(rootGameObjects),
                             SignalGenerator);
            new PlayerEffectManager(PlayerPresenter, itemCreator, GetComponentsInGameObjectsChildren <IPlayerEffectGimmick>(rootGameObjects));
            new CreateItemGimmickManager(itemCreator, GetComponentsInGameObjectsChildren <ICreateItemGimmick>(rootGameObjects));
            new DestroyItemGimmickManager(itemCreator, itemDestroyer, GetComponentsInGameObjectsChildren <IDestroyItemGimmick>(rootGameObjects));

            var onReceiveOwnershipItemTriggerManager = new OnReceiveOwnershipItemTriggerManager(itemCreator);
            var onCreateItemTriggerManager           = new OnCreateItemTriggerManager(itemCreator);
            var onJoinPlayerTriggerManager           = new OnJoinPlayerTriggerManager();

            onCreateItemTriggerManager.Invoke(items.SelectMany(x => x.gameObject.GetComponents <IOnCreateItemTrigger>()));
            onJoinPlayerTriggerManager.Invoke(GetComponentsInGameObjectsChildren <IOnJoinPlayerTrigger>(rootGameObjects));
            onReceiveOwnershipItemTriggerManager.InvokeOnStart(items.SelectMany(x => x.gameObject.GetComponents <IOnReceiveOwnershipItemTrigger>()));
        }
Exemplo n.º 2
0
        static void SetupTriggerGimmicks(IEnumerable <GameObject> rootGameObjects, ItemCreator itemCreator, ItemDestroyer itemDestroyer)
        {
            var roomStateRepository = new RoomStateRepository();
            var gimmickManager      = new GimmickManager(roomStateRepository, itemCreator, itemDestroyer);
            var triggerManager      = new TriggerManager(roomStateRepository, itemCreator, gimmickManager);
            var items = GetComponentsInGameObjectsChildren <IItem>(rootGameObjects).ToArray();

            triggerManager.Add(items.SelectMany(x => x.gameObject.GetComponents <IItemTrigger>()));
            gimmickManager.AddGimmicksInScene(GetComponentsInGameObjectsChildren <IGimmick>(rootGameObjects));
            foreach (var item in items)
            {
                gimmickManager.AddGimmicksInItem(item.gameObject.GetComponentsInChildren <IGimmick>(true), item.Id.Value);
            }

            new PlayerGimmickManager(PlayerPresenter, itemCreator, GetComponentsInGameObjectsChildren <IPlayerGimmick>(rootGameObjects));
            new CreateItemGimmickManager(itemCreator, GetComponentsInGameObjectsChildren <ICreateItemGimmick>(rootGameObjects));
            new DestroyItemGimmickManager(itemCreator, itemDestroyer, GetComponentsInGameObjectsChildren <IDestroyItemGimmick>(rootGameObjects));
            var onCreateItemTriggerManager = new OnCreateItemTriggerManager(itemCreator);

            onCreateItemTriggerManager.Invoke(items.SelectMany(x => x.gameObject.GetComponents <IOnCreateItemTrigger>()));
        }