Inheritance: MonoBehaviour
コード例 #1
0
    /*!
     * \brief Will draw the lines in the list
     * \param resize If true will resize the lines first
     */
    private void drawLines(bool resize)
    {
        if (_molecules == null)
        {
            return;
        }
        foreach (VectrosityPanelLine line in _lines)
        {
            Molecule m = ReactionEngine.getMoleculeFromName(line.moleculeName, _molecules);

            //TODO dynamic resize
            //if(resize)
            //line.resize();

            if (!_paused)
            {
                if (m != null)
                {
                    line.addPoint(m.getConcentration());
                }
                else
                {
                    line.addPoint(0f);
                }
            }
            line.redraw();
        }
    }
コード例 #2
0
    private bool safeLazyInit()
    {
        if (null == _reactionEngine)
        {
            _reactionEngine = ReactionEngine.get();
        }

        if (_reactionEngine != null)
        {
            if (null == _mediums)
            {
                _mediums = _reactionEngine.getMediumList();
            }
            if (null == _mediums)
            {
                Logger.Log("VectrosityPanel::safeLazyInit failed to get mediums", Logger.Level.WARN);
                return(false);
            }
        }
        else
        {
            Logger.Log("VectrosityPanel::safeLazyInit failed to get ReactionEngine", Logger.Level.WARN);
            return(false);
        }

        return(true);
    }
コード例 #3
0
    /*!
     * \brief Adds an IReaction to a medium
     * \param mediumId The medium ID.
     * \param reaction The reaction to add.
     */
    public void addReactionToMedium(int mediumId, IReaction reaction)
    {
        Logger.Log("ReactionEngine::addReactionToMedium(" + mediumId + ", " + reaction + ")", Logger.Level.INFO);
        Medium med = ReactionEngine.getMediumFromId(mediumId, _mediums);

        if (med == null)
        {
            Logger.Log("ReactionEngine::addReactionToMedium medium #" + mediumId + "not found", Logger.Level.WARN);
            return;
        }

        /*TODO FIXME USEFULNESS?/////////////////////////////////////////////////////////////////////
         * ReactionSet reactionsSet = null;
         * string medName = med.getName()+"Reactions";
         * foreach (ReactionSet rs in _reactionsSets) {
         * if (rs.id == medName) reactionsSet = rs;
         * }
         * if (reactionsSet != null) {
         * reactionsSet.reactions.AddLast(IReaction.copyReaction(reaction));
         * } else {
         * Logger.Log("ReactionEngine::addReactionToMedium reactionsSet == null", Logger.Level.WARN);
         * }
         * //////////////////////////////////////////////////////////////////////////////////////////*/

        med.addReaction(IReaction.copyReaction(reaction));
    }
コード例 #4
0
ファイル: Medium.cs プロジェクト: afaucher17/Hero.Coli
    /*!
     * \brief Load Molecules from a MoleculeSet
     * \param molSet The set to Load
     * \param allMolecules The list of all the molecules
     */
    public void initMoleculesFromMoleculeSets(MoleculeSet molSet, ArrayList allMolecules)
    {
        Logger.Log("Medium::initMoleculesFromMoleculeSets medium#" + _numberId, Logger.Level.TRACE);
        Molecule newMol;
        Molecule startingMolStatus;

        _molecules = new ArrayList();
        foreach (Molecule mol in allMolecules)
        {
            newMol            = new Molecule(mol);
            startingMolStatus = ReactionEngine.getMoleculeFromName(mol.getName(), molSet.molecules);
            if (startingMolStatus == null)
            {
                newMol.setConcentration(0);
            }
            else
            {
                newMol.setConcentration(startingMolStatus.getConcentration());
            }
            Logger.Log("Medium::initMoleculesFromMoleculeSets medium#" + _numberId
                       + " add mol " + newMol.getName()
                       + " with cc=" + newMol.getConcentration()
                       , Logger.Level.TRACE
                       );
            _molecules.Add(newMol);
        }
    }
コード例 #5
0
    /*!
     * Find the Limiting reactant in the attribute _reactant
     * and return the factor as following :
     *
     *    [MinReactant] / CoefReactant
     */
    private float getLimitantFactor(ArrayList molecules)
    {
        Product  minReact = null;
        bool     b        = true;
        Molecule mol      = null;
        Molecule molMin   = null;

        foreach (Product r in _reactants)
        {
            mol = ReactionEngine.getMoleculeFromName(r.getName(), molecules);
            if (b && mol != null)
            {
                molMin   = mol;
                minReact = r;
                b        = false;
            }
            else if (mol != null)
            {
                if (molMin != null && ((mol.getConcentration() / r.getQuantityFactor()) < (molMin.getConcentration() / minReact.getQuantityFactor())))
                {
                    molMin   = mol;
                    minReact = r;
                }
            }
        }
        if (minReact == null)
        {
            return(0f);
        }
        return(molMin.getConcentration() / minReact.getQuantityFactor());
    }
コード例 #6
0
ファイル: ReactionEngine.cs プロジェクト: CyberCRI/Hero.Coli
 public static ReactionEngine get() {
   if(_instance == null) {
     Logger.Log("ReactionEngine::get was badly initialized", Logger.Level.WARN);
     _instance = GameObject.Find(gameObjectName).GetComponent<ReactionEngine>();
   }
   return _instance;
 }
コード例 #7
0
    //! Processing a reaction.

    /*!
     *  \param molecules A list of molecules (not usefull here)
     *
     * A diffusion reaction based on fick model is calculated by using this formula :
     * dn/dt = c1 - c2 * P * A
     * Where:
     *    - dn is the difference of concentration that will be applied
     *    - c1 and c2 the concentration the molecules in the 2 Mediums
     *    - P is the permeability coefficient
     *    - A is the contact surface size between the two Mediums
     */
    public override void react(ArrayList molecules)
    {
        ArrayList molMed1 = _medium1.getMolecules();
        ArrayList molMed2 = _medium2.getMolecules();
        Molecule  mol2;
        float     c1;
        float     c2;
        float     result;

        if (_P == 0f || _surface == 0f)
        {
            return;
        }
        foreach (Molecule mol1 in molMed1)
        {
            c1   = mol1.getConcentration();
            mol2 = ReactionEngine.getMoleculeFromName(mol1.getName(), molMed2);
            if (mol2 != null && mol2.getFickFactor() > 0f)
            {
                c2     = mol2.getConcentration();
                result = (c2 - c1) * _P * _surface * mol2.getFickFactor() * _reactionSpeed * ReactionEngine.reactionsSpeed;

                if (enableSequential)
                {
                    mol2.addConcentration(-result);
                    mol1.addConcentration(result);
                }
                else
                {
                    mol2.subNewConcentration(result);
                    mol1.addNewConcentration(result);
                }
            }
        }
    }
コード例 #8
0
 /*!
  * \brief Called at the beginning.
  */
 public void Start()
 {
     initialize();
     _reactionEngine = ReactionEngine.get();
     StartPhenotype();
     initMolecules();
 }
コード例 #9
0
ファイル: Medium.cs プロジェクト: afaucher17/Hero.Coli
    /*!
     * \brief Initialize the Medium
     * \param reactionsSets The list of all the reactions sets
     * \param moleculesSets The list of all the molecules sets
     */
    public void Init(LinkedList <ReactionSet> reactionsSets, LinkedList <MoleculeSet> moleculesSets)
    {
        //Receive a linkedlist of Sets
        _reactions       = new LinkedList <IReaction>();
        _numberGenerator = new NumberGenerator(NumberGenerator.normale, -10f, 10f, 0.01f);

        //Try to find the good set in the LinkedList
        ReactionSet reactSet = ReactionEngine.getReactionSetFromId(_reactionsSet, reactionsSets);
        MoleculeSet molSet   = ReactionEngine.getMoleculeSetFromId(_moleculesSet, moleculesSets);

        //Put all the different molecules from the linkedList in an arrayList
        ArrayList allMolecules = ReactionEngine.getAllMoleculesFromMoleculeSets(moleculesSets);

        if (reactSet == null)
        {
            Logger.Log("Medium::Init Cannot find group of reactions named " + _reactionsSet, Logger.Level.WARN);
        }
        if (molSet == null)
        {
            Logger.Log("Medium::Init Cannot find group of molecules named" + _moleculesSet, Logger.Level.WARN);
        }

        initATPProduction();
        initReactionsFromReactionSet(reactSet);
        initMoleculesFromMoleculeSets(molSet, allMolecules);
        initDegradationReactions(allMolecules);
        foreach (IReaction r in _reactions)
        {
            r.enableSequential = _enableSequential;
        }
    }
コード例 #10
0
ファイル: Medium.cs プロジェクト: afaucher17/Hero.Coli
 //TODO refactor interactions out of medium
 private void manageMoleculeConcentrationWithKey(String molecule)
 {
     if (GameStateController.isShortcutKey(GameStateController.keyPrefix + molecule + _shortkeyPlusSuffix))
     {
         if (_enableSequential)
         {
             ReactionEngine.getMoleculeFromName(molecule, _molecules).addConcentration(10f);
         }
         else
         {
             ReactionEngine.getMoleculeFromName(molecule, _molecules).addNewConcentration(100f);
         }
     }
     if (GameStateController.isShortcutKey(GameStateController.keyPrefix + molecule + _shortkeyMinusSuffix))
     {
         if (_enableSequential)
         {
             ReactionEngine.getMoleculeFromName(molecule, _molecules).addConcentration(-10f);
         }
         else
         {
             ReactionEngine.getMoleculeFromName(molecule, _molecules).addNewConcentration(-100f);
         }
     }
 }
コード例 #11
0
 /*!
  * \brief Called at each tick of the game.
  */
 public void Update()
 {
     if (!ReactionEngine.isPaused())
     {
         UpdatePhenotype();
     }
 }
コード例 #12
0
    void OnTriggerEnter(Collider collider)
    {
        Logger.Log("PhenoFickContact::OnTriggerEnter collider=" + collider, Logger.Level.DEBUG);
        PhysicalMedium PMext = collider.gameObject.GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter collider.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    colliderMediumIdExt = PMext.MediumId;
        Medium colliderMediumExt   = ReactionEngine.getMediumFromId(colliderMediumIdExt, _reactionEngine.getMediumList());

        if (colliderMediumExt == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter The collided medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        PhysicalMedium PM = GetComponent <PhysicalMedium>();

        if (PMext == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter this.PMext == null", Logger.Level.TRACE);
            return;
        }
        int    mediumId = PM.MediumId;
        Medium medium   = ReactionEngine.getMediumFromId(mediumId, _reactionEngine.getMediumList());

        if (medium == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter The medium does not exist in the reaction Engine. Load it or change the MediumId number in the PhysicalMedium script.", Logger.Level.WARN);
            return;
        }

        float        surface  = Math.Min(PM.Size, PMext.Size);
        Fick         fick     = _reactionEngine.getFick();
        FickReaction reaction = Fick.getFickReactionFromIds(colliderMediumIdExt, mediumId, fick.getFickReactions());

        if (reaction == null)
        {
            Logger.Log("PhenoFickContact::OnTriggerEnter This FickReaction does not exist.", Logger.Level.WARN);
            return;
        }
        reaction.setSurface(surface);

        // set medium as medium of collider
        Logger.Log("colliderMediumIdExt : " + colliderMediumIdExt, Logger.Level.INFO);
        configureExternalDisplays(colliderMediumIdExt);
        _collidedMediumIds.AddLast(colliderMediumIdExt);

        /*
         * Logger.Log("PhenoFickContact::OnTriggerEnter"
         +" reaction.setSurface("+surface+")"
         +" _collidedMediumIds.Count="+_collidedMediumIds.Count
         +" _collidedMediumIds.Last.Value="+_collidedMediumIds.Last.Value
         * ,Logger.Level.);
         */
    }
コード例 #13
0
 /*!
  * Execute a Node of type : Word
  * \param node The node of the tree to execute
  * \param molecules The list of molecules
  * \return return the concentration of the molecule in the node.
  */
 private Molecule execWord(TreeNode <PromoterNodeData> node, ArrayList molecules)
 {
     if (node == null || molecules == null)
     {
         return(null);
     }
     return(ReactionEngine.getMoleculeFromName(node.getData().value, molecules));
 }
コード例 #14
0
    /*
     * \brief This function do the reaction.
     * \details The ActiveTransportReaction is a reaction that is exactly the same as EnzymeReaction.
     * The only difference is that the production are added to the destination medium and not to the
     * medium where the reaction is going on.
     * \param molecules dont usefull, can be set to null
     * \sa execEnzymeReaction
     */
    public override void react(ArrayList molecules)
    {
        if (!_isActive)
        {
            return;
        }

        ArrayList molSrcMed = _srcMedium.getMolecules();
        ArrayList molDstMed = _dstMedium.getMolecules();
        Molecule  substrate = ReactionEngine.getMoleculeFromName(_substrate, molSrcMed);

        if (substrate == null)
        {
            return;
        }

        float delta = execEnzymeReaction(molSrcMed) * _reactionSpeed * ReactionEngine.reactionsSpeed;

        float energyCoef;
        float energyCostTot;

        if (delta > 0f && _energyCost > 0f && enableEnergy)
        {
            energyCostTot = _energyCost * delta;
            energyCoef    = _medium.getEnergy() / energyCostTot;
            if (energyCoef > 1f)
            {
                energyCoef = 1f;
            }
            _medium.subEnergy(energyCostTot);
        }
        else
        {
            energyCoef = 1f;
        }

        delta *= energyCoef;
        if (enableSequential)
        {
            substrate.subConcentration(delta);
        }
        else
        {
            substrate.subNewConcentration(delta);
        }
        foreach (Product pro in _products)
        {
            Molecule mol = ReactionEngine.getMoleculeFromName(pro.getName(), molDstMed);
            if (enableSequential)
            {
                mol.addConcentration(delta);
            }
            else
            {
                mol.addNewConcentration(delta);
            }
        }
    }
コード例 #15
0
 void Start()
 {
     _reactionEngine = ReactionEngine.get();
     _graphWindow    = gameObject.GetComponentInChildren <GraphWindow>();
     if (setMedium(ReactionEngine.getMediumFromId(_mediumId, _reactionEngine.getMediumList())) == false)
     {
         Logger.Log("Failed to load medium curves", Logger.Level.ERROR);
     }
 }
コード例 #16
0
 public static ReactionEngine get()
 {
     if (_instance == null)
     {
         Logger.Log("ReactionEngine::get was badly initialized", Logger.Level.WARN);
         _instance = GameObject.Find(gameObjectName).GetComponent <ReactionEngine>();
     }
     return(_instance);
 }
コード例 #17
0
ファイル: Medium.cs プロジェクト: afaucher17/Hero.Coli
    /*!
     * \brief Add a concentration to molecule corresponding to the name.
     * \param name The name of the Molecules.
     * \param value The value to Add.
     */
    public void addMolConcentration(string name, float value)
    {
        Molecule mol = ReactionEngine.getMoleculeFromName(name, _molecules);

        if (mol != null)
        {
            mol.setConcentration(mol.getConcentration() + value);
        }
    }
コード例 #18
0
    /*!
     * \brief remove a reaction from a medium
     * \param mediumId The medium ID.
     * \param name The reaction's name.
     */
    public void removeReactionFromMediumByName(int mediumId, string name)
    {
        Medium med = ReactionEngine.getMediumFromId(mediumId, _mediums);

        if (med == null)
        {
            return;
        }
        med.removeReactionByName(name);
    }
コード例 #19
0
    /*!
     * This function is called at each frame.
     * It find the limiting reactant and consume as reactant and produce product
     * as much as possible.
     *
     * The formula is :
     *
     *    delta =  Min(Reactant_1 / Coef_1, Reactant_2 / Coef_2, ... , Reactant_n / Coef_n)
     *    for each product P : [P] += delta * Coef_P
     *    for each reactant R : [R] -= delta * Coef_R
     */
    public override void react(ArrayList molecules)
    {
        if (!_isActive)
        {
            return;
        }

        float delta = getLimitantFactor(molecules);

        float energyCoef;
        float energyCostTot;

        if (delta > 0f && _energyCost > 0f && enableEnergy)
        {
            energyCostTot = _energyCost * delta;
            energyCoef    = _medium.getEnergy() / energyCostTot;
            if (energyCoef > 1f)
            {
                energyCoef = 1f;
            }
            _medium.subEnergy(energyCostTot);
        }
        else
        {
            energyCoef = 1f;
        }

        delta *= energyCoef;
        Molecule mol;

        foreach (Product react in _reactants)
        {
            mol = ReactionEngine.getMoleculeFromName(react.getName(), molecules);
            if (enableSequential)
            {
                mol.subConcentration(delta * react.getQuantityFactor());
            }
            else
            {
                mol.subNewConcentration(delta * react.getQuantityFactor());
            }
        }
        foreach (Product prod in _products)
        {
            mol = ReactionEngine.getMoleculeFromName(prod.getName(), molecules);
            if (enableSequential)
            {
                mol.addConcentration(delta * prod.getQuantityFactor());
            }
            else
            {
                mol.addNewConcentration(delta * prod.getQuantityFactor());
            }
        }
    }
コード例 #20
0
    /*!
     * \brief This method gets all molecular concentrations
     * \sa Molecule
     * \sa Molecule.getConcentration()
     */
    public void initMolecules()
    {
        LinkedList <Medium> mediums = _reactionEngine.getMediumList();

        _mediumRef = ReactionEngine.getMediumFromId(_mediumId, mediums);

        if (_mediumRef != null && _molecules == null)
        {
            _molecules = _mediumRef.getMolecules();
        }
    }
コード例 #21
0
ファイル: Hero.cs プロジェクト: afaucher17/Hero.Coli
    private void initializeIfNecessary()
    {
        //???
        //gameObject.SetActive(true);
        _isAlive = true;

        //LinkedList<Medium> mediums = ReactionEngine.get ().getMediumList();
        _medium          = ReactionEngine.getMediumFromId(1, ReactionEngine.get().getMediumList());
        _maxMediumEnergy = _medium.getMaxEnergy();
        _energy          = _medium.getEnergy() / _maxMediumEnergy;
    }
コード例 #22
0
ファイル: ModuleInfo.cs プロジェクト: quito/DSynBio_reloaded
    public void addToReactionEngine(int mediumID, ReactionEngine reactionEngine)
    {
        Debug.Log("module promoter: "+_promoterName);

        PromoterProprieties proprieties = getProprieties();
        Debug.Log("proprieties="+proprieties.ToString());

        IReaction reaction = Promoter.buildPromoterFromProps(proprieties);
        Debug.Log("reaction="+reaction);

        reactionEngine.addReactionToMedium(mediumID, reaction);
    }
コード例 #23
0
    /* !
     * \brief Remove from the specified medium the reaction that has the same characteristics as the one given as parameter
     * \param mediumId The Id of the medium to remove from.
     * \param reaction The model of reaction to remove.
     * \param checkNameAndMedium Whether the name and medium must be taken into account or not.
     */
    public void removeReaction(int mediumId, IReaction reaction, bool checkNameAndMedium = false)
    {
        Medium med = ReactionEngine.getMediumFromId(mediumId, _mediums);

        if (med == null)
        {
            Logger.Log("ReactionEngine::removeReaction could not find medium with id " + mediumId, Logger.Level.WARN);
            return;
        }

        med.removeReaction(reaction, checkNameAndMedium);
    }
コード例 #24
0
    //! Default constructor
    public IReaction()
    {
        _products      = new LinkedList <Product>();
        _isActive      = true;
        _reactionSpeed = 1f;
        _energyCost    = 0f;

        //TODO CHECK THIS
        //enableSequential = true;
        //enableEnergy = false;
        enableSequential = ReactionEngine.get().enableSequential;
        enableEnergy     = ReactionEngine.get().enableEnergy;
    }
コード例 #25
0
  void Start() {
    _reactionEngine = ReactionEngine.get();

    safeInitialization();
    
    if(null != equipedWithMoleculesDeviceDummy)
    {
      equipedWithMoleculesDeviceDummy.SetActive(false);
    }
    else
    {
      Logger.Log("GraphMoleculeList::Start failed safeInitialization ", Logger.Level.WARN);
    }
  }
コード例 #26
0
    void Start()
    {
        _reactionEngine = ReactionEngine.get();

        safeInitialization();

        if (null != equipedWithMoleculesDeviceDummy)
        {
            equipedWithMoleculesDeviceDummy.SetActive(false);
        }
        else
        {
            Logger.Log("GraphMoleculeList::Start failed safeInitialization ", Logger.Level.WARN);
        }
    }
コード例 #27
0
    /*!
     * \brief Load a list of properties in order to convert it into a ActiveTransportReaction
     * \param props The list of ActiveTransportProperties
     * \param mediums The list of mediums
     */
    public void loadActiveTransportReactionsFromProperties(LinkedList <ActiveTransportProperties> props, LinkedList <Medium> mediums)
    {
        ActiveTransportReaction reaction;
        Medium med;

        foreach (ActiveTransportProperties prop in props)
        {
            reaction = new ActiveTransportReaction();
            reaction.setName(prop.name);
            reaction.setSubstrate(prop.substrate);
            reaction.setEnzyme(prop.enzyme);
            reaction.setKcat(prop.Kcat);
            reaction.setEffector(prop.effector);
            reaction.setAlpha(prop.alpha);
            reaction.setBeta(prop.beta);
            reaction.setKm(prop.Km);
            reaction.setKi(prop.Ki);
            reaction.setEnergyCost(prop.energyCost);
            foreach (Product p in prop.products)
            {
                reaction.addProduct(p);
            }
            med = ReactionEngine.getMediumFromId(prop.srcMediumId, mediums);
            if (med == null)
            {
                Debug.Log("Cannot load Active Transport properties because the medium Id : " + prop.srcMediumId + " is unknown.");
                break;
            }
            reaction.setSrcMedium(med);
            med = ReactionEngine.getMediumFromId(prop.dstMediumId, mediums);
            if (med == null)
            {
                Debug.Log("Cannot load Active Transport properties because the medium Id : " + prop.dstMediumId + " is unknown.");
                break;
            }
            reaction.setDstMedium(med);
            med = ReactionEngine.getMediumFromId(prop.mediumId, mediums);
            if (med == null)
            {
                Debug.Log("Cannot load Active Transport properties because the medium Id : " + prop.mediumId + " is unknown.");
                break;
            }
            reaction.setMedium(med);
            med.addReaction(reaction);
        }
    }
コード例 #28
0
    public ArrowAnimationManager arrowManager;                  //Manager for the arrow Animation

    // Use this for initialization
    void Start()
    {
        _reactionEngine   = ReactionEngine.get();
        _devicesDisplayer = DevicesDisplayer.get();

        SetScreen2(false);
        SetScreen3(false);
        SetScreen1(true);


        _devicesDisplayer.UpdateScreen();
        _currentScreen = GameScreen.screen1;

        _timeAtLastFrame = Time.realtimeSinceStartup;

        arrowManager = new ArrowAnimationManager();
    }
コード例 #29
0
ファイル: GUITransitioner.cs プロジェクト: CyberCRI/Hero.Coli
	public ArrowAnimationManager arrowManager;		//Manager for the arrow Animation
	
	// Use this for initialization
	void Start () {

    _reactionEngine = ReactionEngine.get();
    _devicesDisplayer = DevicesDisplayer.get();

		SetScreen2(false);
		SetScreen3(false);
		SetScreen1(true);
		
		
		_devicesDisplayer.UpdateScreen();
		_currentScreen = GameScreen.screen1;
		
		_timeAtLastFrame = Time.realtimeSinceStartup;

		arrowManager = new ArrowAnimationManager();
	}
コード例 #30
0
    public static IReaction        buildFickReactionFromProps(FickProperties props, LinkedList <Medium> mediums)
    {
        FickReaction reaction = new FickReaction();
        Medium       med1     = ReactionEngine.getMediumFromId(props.MediumId1, mediums);
        Medium       med2     = ReactionEngine.getMediumFromId(props.MediumId2, mediums);

        if (med1 == null || med2 == null)
        {
            Debug.Log("failed to build FickReaction from FickProperties beacause one or all the medium id don't exist");
            return(null);
        }
        reaction.setSurface(props.surface);
        reaction.setPermCoef(props.P);
        reaction.setMedium1(med1);
        reaction.setMedium2(med2);
        reaction.setEnergyCost(props.energyCost);

        return(reaction);
    }
コード例 #31
0
    /*!
     * \details The degradation reaction following the formula above:
     *
     *            [X] = degradationRate * [X]
     *
     * \param molecules The list of molecules
     */
    public override void react(ArrayList molecules)
    {
        if (!_isActive)
        {
            return;
        }

        Molecule mol   = ReactionEngine.getMoleculeFromName(_molName, molecules);
        float    delta = mol.getDegradationRate() * mol.getConcentration();

        if (enableSequential)
        {
            mol.subConcentration(mol.getDegradationRate() * mol.getConcentration() * _reactionSpeed * ReactionEngine.reactionsSpeed);
        }
        else
        {
            mol.subNewConcentration(delta * _reactionSpeed * ReactionEngine.reactionsSpeed);
        }
    }
コード例 #32
0
    /*!
     * \brief This function is called as Update in Monobehaviour.
     * \details This function is called in the Phenotype class in the Update function
     * This function should be implemented and all the graphical action has to be implemented in it.
     * \sa Phenotype
     */
    public override void UpdatePhenotype()
    {
        //bool isThresholdEnabled = false;
        Molecule mol = ReactionEngine.getMoleculeFromName(MoleculeName, _molecules);

        if (mol == null)
        {
            return;
        }
        Debug.LogError("deprecated GetComponent calls");
        if (mol.getConcentration() >= Threshold && gameObject.GetComponent("ParticleSystem") == null)
        {
            gameObject.AddComponent <ParticleSystem>();
        }
        else if (mol.getConcentration() < Threshold && gameObject.GetComponent("ParticleSystem") != null)
        {
            Destroy(gameObject.GetComponent("ParticleSystem"));
        }
//       Instantiate(prefab, new Vector3(GetComponent.Transform.x, GetComponent.Transform.y, GetComponent.Transform.z), Quaternion.identity);
    }
コード例 #33
0
    public void Pause(bool pause)
    {
        _pauseTransition = !pause;
        if (_reactionEngine == null)
        {
            _reactionEngine = ReactionEngine.get();
        }
        _reactionEngine.Pause(pause);
        _timeScale = pause ? 0 : 1;
        if (pause)
        {
            Time.timeScale = 0;
        }

        roomGraph.setPause(pause);
        celliaGraph.setPause(pause);
        hero.Pause(pause);
        control.Pause(pause);
        EnemiesManager.Paused = pause;
    }
コード例 #34
0
ファイル: VectrosityPanel.cs プロジェクト: CyberCRI/Hero.Coli
  private bool safeLazyInit()
  {
    if(null==_reactionEngine) {
        _reactionEngine = ReactionEngine.get();
    }

    if(_reactionEngine != null) {
        if(null==_mediums) {
            _mediums = _reactionEngine.getMediumList();
        }
        if(null==_mediums) {
            Logger.Log ("VectrosityPanel::safeLazyInit failed to get mediums", Logger.Level.WARN);
            return false;
        }
    } else {
        Logger.Log ("VectrosityPanel::safeLazyInit failed to get ReactionEngine", Logger.Level.WARN);
        return false;
    }

    return true;
  }
コード例 #35
0
    public void setMedium(int mediumId)
    {
        if (!safeLazyInit())
        {
            return;
        }

        _mediumId = mediumId;

        Medium medium = ReactionEngine.getMediumFromId(_mediumId, _mediums);

        if (medium == null)
        {
            Logger.Log("VectrosityPanel Can't find the given medium (" + _mediumId + ")", Logger.Level.ERROR);
            return;
        }

        _molecules = medium.getMolecules();
        if (_molecules == null)
        {
            Logger.Log("VectrosityPanel Can't find molecules in medium (" + _mediumId + ")", Logger.Level.ERROR);
            return;
        }

        VectrosityPanelLine line;

        foreach (Molecule m in _molecules)
        {
            line = _lines.Find(l => m.getName() == l.moleculeName);
            if (null == line)
            {
                _lines.Add(new Line(width, height, infos, _mediumId, m.getName()));
            }
        }

        drawLines(true);

        lineCount = _lines.Count;
    }
コード例 #36
0
ファイル: GUITransitioner.cs プロジェクト: CyberCRI/Hero.Coli
    public void Pause (bool pause)
    {
        _pauseTransition = !pause;
        if (_reactionEngine == null) {
            _reactionEngine = ReactionEngine.get ();
        }
        _reactionEngine.Pause (pause);
        _timeScale = pause ? 0 : 1;
        if (pause) {
            Time.timeScale = 0;
        }

        roomGraph.setPause (pause);
        celliaGraph.setPause (pause);  
        hero.Pause (pause);
        control.Pause (pause);
        EnemiesManager.Paused = pause;
    }
コード例 #37
0
ファイル: ReactionEngine.cs プロジェクト: CyberCRI/Hero.Coli
  //! This function is called at the initialisation of the simulation (like a Constructor)
  void Awake()
  {
    _instance = this;

    FileLoader fileLoader = new FileLoader();
    _reactionsSets = new LinkedList<ReactionSet>();
    _moleculesSets = new LinkedList<MoleculeSet>();
    _mediums = new LinkedList<Medium>();
    

		//TODO there is only one file in _moleculesFiles and in _reactionsFiles
    foreach (string file in _reactionsFiles)
		{
			LinkedList<ReactionSet> lr = fileLoader.loadObjectsFromFile<ReactionSet>(file,"reactions");
      if(null != lr)
        LinkedListExtensions.AppendRange<ReactionSet>(_reactionsSets, lr);
		}
    foreach (string file in _moleculesFiles)
		{
      Logger.Log("ReactionEngine::Awake() loading molecules from file", Logger.Level.DEBUG);

			LinkedList<MoleculeSet> lm = fileLoader.loadObjectsFromFile<MoleculeSet>(file,"molecules");
      if(null != lm)
			  LinkedListExtensions.AppendRange<MoleculeSet>(_moleculesSets, lm);

            Logger.Log("ReactionEngine::Awake() loading molecules from file done"
                       +": _moleculesSets="+Logger.ToString<MoleculeSet>(_moleculesSets)
                       , Logger.Level.DEBUG);
		}
    
    foreach (string file in _mediumsFiles)
		{
      LinkedList<Medium> lmed = fileLoader.loadObjectsFromFile<Medium>(file,"Medium");
      if(null != lmed)
			  LinkedListExtensions.AppendRange<Medium>(_mediums, lmed);
		}

    foreach (Medium medium in _mediums)
    {
      medium.Init(_reactionsSets, _moleculesSets);
      medium.enableSequential(enableSequential);
      medium.enableNoise(enableNoise);
      medium.enableEnergy(enableEnergy);
      medium.enableShufflingReactionOrder = enableShufflingReactionOrder;
    }

        Logger.Log("ReactionEngine::Awake() FickReactions starting", Logger.Level.INFO);

    _fick = new Fick();
    _fick.loadFicksReactionsFromFiles(_fickFiles, _mediums);

        Logger.Log("ReactionEngine::Awake() activeTransport starting", Logger.Level.INFO);

    _activeTransport = new ActiveTransport();        
    _activeTransport.loadActiveTransportReactionsFromFiles(_activeTransportFiles, _mediums);

        Logger.Log("ReactionEngine::Awake() done", Logger.Level.INFO);
  }
コード例 #38
0
ファイル: Equipment.cs プロジェクト: CyberCRI/Hero.Coli
 new void Start()
 {
   base.Start();
   Logger.Log("Equipment::Start()", Logger.Level.DEBUG);
   _reactionEngine = ReactionEngine.get();
 }
コード例 #39
0
ファイル: Phenotype.cs プロジェクト: CyberCRI/Hero.Coli
  /*!
    \brief Called at the beginning.
   */
  public void Start () {
    initialize();
    _reactionEngine = ReactionEngine.get();
    StartPhenotype();
	  initMolecules();
  }
コード例 #40
0
ファイル: Phenotype.cs プロジェクト: CyberCRI/Hero.Coli
 public void initialize() {
   _reactionEngine = null;
   _mediumRef = null;
   _molecules = null;
 }
コード例 #41
0
 void Start()
 {
     GameObject obj = GameObject.Find("ReactionEngine");
     if(obj){
         _RE = obj.GetComponent<ReactionEngine>();
         if(!_RE)
             Debug.LogError("Could not find Reaction Engine");
     }
     else
         Debug.LogError("Could not find Reaction Engine");
 }
コード例 #42
0
 void Start () {
   _reactionEngine = ReactionEngine.get ();
   _graphWindow = gameObject.GetComponentInChildren<GraphWindow>();
   if (setMedium(ReactionEngine.getMediumFromId(_mediumId, _reactionEngine.getMediumList())) == false)
     Logger.Log("Failed to load medium curves", Logger.Level.ERROR);
 }