Exemple #1
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "ECP")
     {
         ExternalReceptorProperties objProps = (ExternalReceptorProperties)this.GetComponent("ExternalReceptorProperties");
         objProps.isActive = false;
         other.GetComponent <ExtraCellularProperties>().changeState(false);
         other.GetComponent <Rigidbody2D>().isKinematic = true;
         StartCoroutine(transformReceptor(other));
     }
 }
    public GameObject parentObject;     //Parent object used for unity editor Tree Hierarchy

    #region Private Methods

    private void OnTriggerEnter2D(Collider2D other)
    {
        //test
        Debug.Log("OnTriggerEnter2D -> object name = " + this.gameObject.name);

        //Get reference for parent object in UnityEditor
        parentObject = GameObject.FindGameObjectWithTag("MainCamera");

        //IF signal protein collides with full receptor (level 1)
        if (other.gameObject.tag == "ECP" && this.gameObject.name.Equals("_ReceptorInactive(Clone)"))
        {
            ExternalReceptorProperties objProps = (ExternalReceptorProperties)this.GetComponent("ExternalReceptorProperties");
            objProps.isActive = false;
            other.GetComponent <ExtraCellularProperties>().changeState(false);
            other.GetComponent <Rigidbody2D>().isKinematic = true;

            StartCoroutine(transformReceptor(other));
            //check if action is a win condition for the scene/level
            if (GameObject.FindWithTag("Win_FullReceptorActivated"))
            {
                WinScenario.dropTag("Win_FullReceptorActivated");
            }
        }



        //IF signal protein collides with left receptor
        else if (other.gameObject.tag == "ECP" && this.gameObject.name.Equals("Left_Receptor_Inactive(Clone)"))
        {
            ExternalReceptorProperties objProps = (ExternalReceptorProperties)this.GetComponent("ExternalReceptorProperties");
            objProps.isActive = false;
            other.GetComponent <ExtraCellularProperties>().changeState(false);
            other.GetComponent <Rigidbody2D>().isKinematic = true;

            StartCoroutine(transformLeftReceptor(other));
            //check if action is a win condition for the scene/level
            if (GameObject.FindWithTag("Win_LeftReceptorWithProtein"))
            {
                WinScenario.dropTag("Win_LeftReceptorWithProtein");
            }
        }


        //IF right receptor collides with left receptor(with protein signaller)
        else if (other.gameObject.tag == "RightReceptor" && this.gameObject.name.Equals("Left_Receptor_Active(Clone)"))
        {
            StartCoroutine(transformLeftReceptorWithProtein(other));
            //check if action is a win condition for the scene/level
            if (GameObject.FindWithTag("Win_ReceptorsCollideWithProtein"))
            {
                WinScenario.dropTag("Win_ReceptorsCollideWithProtein");
            }
        }
    }