コード例 #1
0
 void OnTriggerStay2D(Collider2D other)
 {
     if (other.tag.Contains("Pickable") && !m_currentlyCollidingWith)
     {
         //Debug.Log("collided with " + other.tag + " " + other.gameObject.name);
         Debug.Log("TES");
         m_currentlyCollidingWith = other;
         GameObject go = other.gameObject;
         Glass      g  = go.GetComponent <Glass>();
         if (g)
         {
             g.setSelected(true);
         }
         Alcohol a = go.GetComponent <Alcohol>();
         if (a)
         {
             a.setSelected(true);
         }
         Fruit f = go.GetComponent <Fruit>();
         if (f)
         {
             f.setSelected(true);
         }
     }
     else if (other.tag.Contains("Client") && !m_client)
     {
         m_client = other.gameObject;
     }
 }
コード例 #2
0
    void OnTriggerExit2D(Collider2D other)
    {
        GameObject go = other.gameObject;
        Glass      g  = go.GetComponent <Glass>();

        if (g)
        {
            g.setSelected(false);
        }
        Alcohol a = go.GetComponent <Alcohol>();

        if (a)
        {
            a.setSelected(false);
        }
        Fruit f = go.GetComponent <Fruit>();

        if (f)
        {
            f.setSelected(false);
        }
        if (m_currentlyCollidingWith == other)
        {
            //Debug.Log("collided with " + other.tag + " " + other.gameObject.name);
            Debug.Log("NO");
            m_currentlyCollidingWith = null;
        }

        if (other.tag.Contains("Client") && m_client)
        {
            Debug.Log("Remove client !");
            m_client = null;
        }

        if (other.tag.Contains("Trash"))
        {
            m_nextToTrashcan = false;
        }
    }