get() public static method

public static get ( ) : AvailableBioBricksManager,
return AvailableBioBricksManager,
Exemplo n.º 1
0
    protected override DNABit produceDNABit()
    {
        LinkedList <BioBrick> deviceBricks = new LinkedList <BioBrick>();

        string[] bricks = new string[] { promoterName, rbsName, geneName, terminatorName };

        foreach (string brickName in bricks)
        {
            BioBrick brick = AvailableBioBricksManager.get().getBioBrickFromAll(brickName);
            if (brick != null)
            {
                deviceBricks.AddLast(brick);
            }
            else
            {
                Logger.Log("PickableDeviceRef4Bricks::produceDNABit failed to add brick with name " + brickName + "!", Logger.Level.WARN);
            }
        }

        if (ExpressionModule.isBioBricksSequenceValid(deviceBricks))
        {
            ExpressionModule deviceModule = new ExpressionModule(deviceName, deviceBricks);
            LinkedList <ExpressionModule> deviceModules = new LinkedList <ExpressionModule>();
            deviceModules.AddLast(deviceModule);
            Device result = Device.buildDevice(deviceName, deviceModules);
            return(result);
        }
        else
        {
            Logger.Log("PickableDeviceRef4Bricks::produceDNABit failed to produce DNABit - BioBrick sequence is incorrect: list=" + Logger.ToString <BioBrick>(deviceBricks), Logger.Level.WARN);
            return(null);
        }
    }
Exemplo n.º 2
0
    // Warning: loads from inputFiles is an array of names of files inside 'biobrickFilesPathPrefix'
    void loadDevices()
    {
        LinkedList <BioBrick> availableBioBricks = AvailableBioBricksManager.get().getAvailableBioBricks();
        LinkedList <BioBrick> allBioBricks       = AvailableBioBricksManager.get().getAllBioBricks();

        LevelInfo levelInfo = null;

        MemoryManager.get().tryGetCurrentLevelInfo(out levelInfo);

        List <Device> devices = new List <Device>();

        DeviceLoader dLoader = new DeviceLoader(availableBioBricks, allBioBricks);

        string[] filesToLoad;
        string   currentMapDevicesFilePath = MemoryManager.get().configuration.getGameMapName();

        if (null == levelInfo || !levelInfo.areAllDevicesAvailable)
        {
            filesToLoad = new string[] { currentMapDevicesFilePath };
        }
        else
        {
            List <string> fileList = new List <string>(deviceFiles);
            fileList.Add(currentMapDevicesFilePath);
            filesToLoad = fileList.ToArray();
        }
        foreach (string file in filesToLoad)
        {
            string fullPathFile = deviceFilesPathPrefix + file;
            Logger.Log("Inventory::loadDevices loads device file " + fullPathFile, Logger.Level.TRACE);
            devices.AddRange(dLoader.loadDevicesFromFile(fullPathFile));
        }
        UpdateData(devices, new List <Device>(), new List <Device>());
    }
 void OnPress(bool isPressed)
 {
     if (isPressed)
     {
         Logger.Log("AvailableTerminatorsButton::OnPress()", Logger.Level.INFO);
         AvailableBioBricksManager.get().displayTerminators();
     }
 }
Exemplo n.º 4
0
    protected override void addTo()
    {
        BioBrick biobrick = _dnaBit as BioBrick;

        if (null == biobrick)
        {
            biobrick = produceDNABit() as BioBrick;
        }
        if (null == biobrick)
        {
            Logger.Log("PickableBioBrick::addTo() - failed to produce non-null dna bit", Logger.Level.WARN);
        }
        else
        {
            Logger.Log("PickableBioBrick::addTo " + _dnaBit, Logger.Level.INFO);
            AvailableBioBricksManager.get().addAvailableBioBrick(biobrick, false);
        }
    }
Exemplo n.º 5
0
    protected override void addTo()
    {
        Device device = _dnaBit as Device;

        if (null == device)
        {
            device = produceDNABit() as Device;
        }
        if (null == device)
        {
            Logger.Log("PickableDevice::addTo() - failed to produce non-null dna bit", Logger.Level.WARN);
        }
        else
        {
            Logger.Log("PickableDevice::addTo " + _dnaBit, Logger.Level.INFO);
            foreach (BioBrick brick in device.getExpressionModules().First.Value.getBioBricks())
            {
                AvailableBioBricksManager.get().addAvailableBioBrick(brick, false);
            }
            Inventory.get().askAddDevice(device);
        }
    }
Exemplo n.º 6
0
    // Searches for a brick from its name in available BioBricks
    //  If it succeeds, adds brick to deviceBricks and returns true
    //  If it fails, searches for it in all the known BioBricks
    //      If it succeeds, adds brick to available BioBricks list and does previous success treatment
    //      If it fails, returns false
    private bool processBrick(string brickName, string filePath = "")
    {
        Logger.Log("DeviceLoader::loadDevicesFromFile brick name " + brickName, Logger.Level.TRACE);
        //"warn" parameter is true to indicate that there is no such BioBrick
        //as the one mentioned in the xml file of the device
        brick = LinkedListExtensions.Find <BioBrick>(_availableBioBricks
                                                     , b => (b.getName() == brickName)
                                                     , true
                                                     , " DeviceLoader::loadDevicesFromFile(" + filePath + ")"
                                                     );

        if (brick == null)
        {
            brick = LinkedListExtensions.Find <BioBrick>(_allBioBricks
                                                         , b => (b.getName() == brickName)
                                                         , true
                                                         , " DeviceLoader::loadDevicesFromFile(" + filePath + ")"
                                                         );
            if (brick != null)
            {
                Logger.Log("DeviceLoader::loadDevicesFromFile successfully added brick " + brick, Logger.Level.TRACE);
                AvailableBioBricksManager.get().addAvailableBioBrick(brick);
            }
        }
        if (brick != null)
        {
            Logger.Log("DeviceLoader::loadDevicesFromFile successfully added brick " + brick, Logger.Level.TRACE);
            deviceBricks.AddLast(brick);
            return(true);
        }
        else
        {
            Logger.Log("DeviceLoader::loadDevicesFromFile failed to add brick with name " + brickName + "!", Logger.Level.WARN);
            return(false);
        }
    }
Exemplo n.º 7
0
 protected override DNABit produceDNABit()
 {
     return(AvailableBioBricksManager.get().getBioBrickFromAll(bioBrickName));
 }
Exemplo n.º 8
0
 void OnEnable()
 {
     AvailableBioBricksManager.get().OnPanelEnabled();
 }
Exemplo n.º 9
0
 public static bool isOpenable()
 {
     //FIXME doesn't work with test null != _instance._currentDevice
     return(0 != AvailableBioBricksManager.get().getAvailableBioBricks().Count);
 }
Exemplo n.º 10
0
    //public Camera _uicamera;


    // Use this for initialization
    void Awake()
    {
        //shortcut
        CraftZoneManager    craftZoneManager    = CraftZoneManager.get();
        GameStateController gameStateController = GameStateController.get();
        //CraftFinalizer _craftfinalizer = craftFinalizer;
        GUITransitioner           guiTransitioner           = GUITransitioner.get();
        DevicesDisplayer          devicesDisplayer          = DevicesDisplayer.get();
        InfoWindowManager         infoWindowManager         = InfoWindowManager.get();
        AvailableBioBricksManager availableBioBricksManager = AvailableBioBricksManager.get();
        TooltipManager            tooltipManager            = TooltipManager.get();
        ModalManager modalManager        = ModalManager.get();
        GameObject   mediumInfoPanelCell = GameObject.Find("MediumInfoPanelCell");

        //GUITransitioner
        guiTransitioner.celliaGraph = mediumInfoPanelCell.transform.Find("CellMediumInfoBackgroundSprite").gameObject
                                      .GetComponent <VectrosityPanel>();
        guiTransitioner.roomGraph = GameObject.Find("MediumInfoPanelRoom").transform.Find("RoomMediumInfoBackgroundSprite").gameObject
                                    .GetComponent <VectrosityPanel>();
        guiTransitioner.animator    = GameObject.Find("WorldEquipButton").GetComponent <InventoryAnimator>();
        guiTransitioner.worldScreen = GameObject.Find("WorldScreensPanel");
        guiTransitioner.craftScreen = craftScreenPanel;

        ContinueButton  cb  = okButton1.GetComponent <ContinueButton>();
        StartGameButton sgb = okButton2.GetComponent <StartGameButton>();

        //GameStateController
        gameStateController.intro = introduction1;
        gameStateController.introContinueButton = cb;
        gameStateController.fadeSprite          = fade;
        gameStateController.endWindow           = end;
        EndMainMenuButton emmb = endMainMenuButton.GetComponent <EndMainMenuButton>();

        gameStateController.endMainMenuButton = emmb;
        gameStateController.mainMenu          = mainMenu;

        //TODO should be done in gameStateController instead
        tutorialPanels.SetActive(true);
        introduction1.SetActive(false);
        introduction2.SetActive(false);
        end.SetActive(false);
        pauseIndicator.SetActive(false);
        genericModalWindow.SetActive(false);

        craftScreenPanel.SetActive(false);

        mainMenu.open();

        gameStateController.pauseIndicator = pauseIndicator;

        //initialization of intro panels
        cb.nextInfoPanel         = introduction2;
        cb.nextInfoPanelContinue = sgb;

        //CraftFinalizer
        craftFinalizer.ToCraftZoneManager = craftZoneManager;

        //CraftZoneManager
        craftZoneManager.GetComponent <CraftZoneManager>().craftFinalizer = craftFinalizer;

        //CraftFinalizer _craftFinalizer2 = CraftZoneManager.get().GetComponent<CraftZoneManager>().craftFinalizer;
        if (null == craftFinalizer.craftFinalizationButton)
        {
            craftFinalizer.craftFinalizationButton = GameObject.Find("CraftButton").GetComponent <CraftFinalizationButton>();
        }

        craftZoneManager.displayedBioBrick      = craftZoneDisplayedBioBrickPrefab;
        craftZoneManager.lastHoveredInfoManager = lastHoveredInfo.GetComponent <LastHoveredInfoManager>();
        craftZoneManager.assemblyZonePanel      = craftScreenPanel.transform.FindChild("TopPanel").transform.FindChild("AssemblyZonePanel").gameObject;


        //DevicesDisplayer

        devicesDisplayer.equipPanel           = equipedDevicesSlotsPanel;
        devicesDisplayer.inventoryPanel       = inventoryDevicesSlotsPanel;
        devicesDisplayer.listedInventoryPanel = craftScreenPanel.transform.FindChild("BottomPanel").transform.FindChild("DevicesPanel").GetComponent <UIPanel>();

        devicesDisplayer.graphMoleculeList = mediumInfoPanelCell.GetComponent <GraphMoleculeList>() as GraphMoleculeList;

        devicesDisplayer.equipedDevice  = equipedDeviceButtonPrefabPos;
        devicesDisplayer.equipedDevice2 = equipedDeviceButtonPrefabPos2;

        devicesDisplayer.inventoryDevice       = inventoryDevicePrefab;
        devicesDisplayer.listedInventoryDevice = listedDevicePrefab;


        //InfoWindowManager
        infoWindowManager.infoPanel        = genericInfoWindow;
        infoWindowManager.titleLabel       = genericInfoWindow.transform.FindChild("TitleLabel").GetComponent <UILocalize>();
        infoWindowManager.subtitleLabel    = genericInfoWindow.transform.FindChild("SubtitleLabel").GetComponent <UILocalize>();
        infoWindowManager.explanationLabel = genericInfoWindow.transform.FindChild("ExplanationLabel").GetComponent <UILocalize>();
        infoWindowManager.bottomLabel      = genericInfoWindow.transform.FindChild("BottomLabel").GetComponent <UILocalize>();
        infoWindowManager.infoSprite       = genericInfoWindow.transform.FindChild("InfoSprite").GetComponent <UISprite>();

        //ModalManager
        modalManager.modalBackground               = modalBackground;
        modalManager.genericModalWindow            = genericModalWindow;
        modalManager.titleLabel                    = genericModalWindow.transform.FindChild("TitleLabel").GetComponent <UILocalize>();
        modalManager.explanationLabel              = genericModalWindow.transform.FindChild("ExplanationLabel").GetComponent <UILocalize>();
        modalManager.infoSprite                    = genericModalWindow.transform.FindChild("InfoSprite").GetComponent <UISprite>();
        modalManager.genericValidateButton         = genericModalWindow.transform.FindChild("ValidateButton").gameObject;
        modalManager.genericCenteredValidateButton = genericModalWindow.transform.FindChild("CenteredValidateButton").gameObject;
        modalManager.genericCancelButton           = genericModalWindow.transform.FindChild("CancelButton").gameObject;


        //DeviceInventory
        Inventory.get().animator = GameObject.Find("WorldEquipButton").GetComponent <InventoryAnimator>();
        Inventory.get().animator.tutorialArrowAnimation = tutorialArrow.GetComponent <ArrowAnimation>();

        //BiobrickInventory

        //AvailableBioBricksManager.get().bioBricksPanel = GameObject.Find("BiobricksPanel");
        availableBioBricksManager.bioBricksPanel    = craftScreenPanel.transform.FindChild("BottomPanel").transform.FindChild("BiobricksPanel").gameObject;
        availableBioBricksManager.availableBioBrick = availableBioBricksManager.bioBricksPanel.transform.FindChild("AvailableDisplayedBioBrickPrefab").gameObject;
        //AvailableBioBricksManager.get ().availableBioBrick = GameObject.Find ("AvailableDisplayedBioBrickPrefab");

        //TooltipManager
        tooltipManager.bioBrickTooltipPanel = biobrickTooltipPanel;
        tooltipManager.deviceTooltipPanel   = deviceTooltipPanel;
        tooltipManager.uiCamera             = GameObject.Find("Camera").GetComponent <Camera>();

        Logger.get().loggerGUIComponent = loggerGUIComponent;
    }
Exemplo n.º 11
0
    public LinkedList <Device> loadDevicesFromFile(string filePath)
    {
        Logger.Log("DeviceLoader::loadDevicesFromFile(" + filePath + ")", Logger.Level.INFO);

        LinkedList <Device> resultDevices = new LinkedList <Device>();

        XmlDocument xmlDoc = Tools.getXmlDocument(filePath);

        XmlNodeList deviceList = xmlDoc.GetElementsByTagName(BioBricksXMLTags.DEVICE);

        reinitVars();

        foreach (XmlNode deviceNode in deviceList)
        {
            try
            {
                deviceName = deviceNode.Attributes[BioBricksXMLTags.ID].Value;
            }
            catch (NullReferenceException exc)
            {
                Logger.Log("DeviceLoader::loadDevicesFromFile bad xml, missing field \"id\"\n" + exc, Logger.Level.WARN);
                continue;
            }
            catch (Exception exc)
            {
                Logger.Log("DeviceLoader::loadDevicesFromFile failed, got exc=" + exc, Logger.Level.WARN);
                continue;
            }

            Logger.Log("DeviceLoader::loadDevicesFromFile got id=" + deviceName
                       , Logger.Level.TRACE);


            bool processSuccess = true;

            if (checkString(deviceName))
            {
                // processes longer grammars that use explicit brick nodes names
                if (0 != deviceNode.ChildNodes.Count)
                {
                    foreach (XmlNode attr in deviceNode)
                    {
                        if (attr.Name == BioBricksXMLTags.BIOBRICK)
                        {
                            //find brick in existing bricks
                            string brickName = attr.Attributes[BioBricksXMLTags.ID].Value;
                            if (!processBrick(brickName, filePath))
                            {
                                // processes even longer grammar that uses explicit brick description
                                // because the brick wasn't found neither in 'available' nor 'all' biobricks lists
                                brick = bLoader.loadBioBrick(attr);
                                if (null != brick)
                                {
                                    AvailableBioBricksManager.get().addAvailableBioBrick(brick);
                                    deviceBricks.AddLast(brick);
                                }
                                else
                                {
                                    processSuccess = false;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            Logger.Log("DeviceLoader::loadDevicesFromFile unknown attr " + attr.Name, Logger.Level.WARN);
                        }
                    }
                }
                else
                {
                    // processes shortened grammar that uses only device name
                    foreach (string brickName in deviceName.Split(':'))
                    {
                        if (!processBrick(brickName, filePath))
                        {
                            processSuccess = false;
                            break;
                        }
                    }
                }

                if (processSuccess)
                {
                    ExpressionModule deviceModule = new ExpressionModule(deviceName, deviceBricks);
                    LinkedList <ExpressionModule> deviceModules = new LinkedList <ExpressionModule>();
                    deviceModules.AddLast(deviceModule);
                    device = Device.buildDevice(deviceName, deviceModules);
                    if (device != null)
                    {
                        resultDevices.AddLast(device);
                    }
                }
            }
            else
            {
                Logger.Log("DeviceLoader::loadDevicesFromFile Error : missing attribute id in Device node", Logger.Level.WARN);
            }
            reinitVars();
        }
        return(resultDevices);
    }