private void Inject() { // Services ImpactService impactService = new ImpactService(); // Groupal controller PortalsController portalsController = new PortalsController(); PortalUICollection portalUIList = new PortalUICollection(); portalsController.SetPortalRemoveListener(portalUIList); // Factories PlayerFactory playerFactory = new PlayerFactory(portalsController, portalsController, impactService, portalUIList); EnemyFactory enemyFactory = new EnemyFactory(impactService); PortalFactory portalFactory = new PortalFactory(portalsController, portalUIList); // References PlayerUI playerUI = GameObject.Find("/Player").GetComponent <PlayerUI>(); EnemyUI enemyUI1 = GameObject.Find("/Enemies/Enemy1").GetComponent <EnemyUI>(); EnemyUI enemyUI2 = GameObject.Find("/Enemies/Enemy2").GetComponent <EnemyUI>(); PortalUI portalUI1 = GameObject.Find("/Portals/Portal1").GetComponent <PortalUI>(); PortalUI portalUI2 = GameObject.Find("/Portals/Portal2").GetComponent <PortalUI>(); PortalUI portalUI3 = GameObject.Find("/Portals/Portal3").GetComponent <PortalUI>(); // Injection playerFactory.CreatePlayer(playerUI); enemyFactory.CreateEnemy(enemyUI1); enemyFactory.CreateEnemy(enemyUI2); portalFactory.CreatePortal(portalUI1); portalFactory.CreatePortal(portalUI2); portalFactory.CreatePortal(portalUI3); }
private static void SetConnections(JObject json, IReadOnlyDictionary <int, List <IConnection> > connections) { if (!json.ContainsKey("connections")) { return; } foreach (var jConnection in json["connections"].Children <JObject>()) { if (jConnection.ContainsKey("portal")) { PortalFactory.CreatePortal(jConnection, _rooms); continue; } ConnectionFactory.CreateConnection(jConnection, _rooms, out var conn1, out var conn2, out var roomId1, out var roomId2); connections[roomId1].Add(conn2); connections[roomId2].Add(conn1); } }