コード例 #1
0
    void OnTriggerEnter(Collider other)
    {
        MetallicInteractable m = other.gameObject.GetComponent <MetallicInteractable>();

        if (m != null)
        {
            objectsInTriggerZone.Add(m);

            //check if there is now a connection
            if (companionTrigger.objectsInTriggerZone.Contains(m))
            {
                circuit.setConnected(true);
                connectingObjects.Add(m);
                companionTrigger.objectsInTriggerZone.Add(m);
            }
        }
    }
コード例 #2
0
    void OnTriggerExit(Collider other)
    {
        MetallicInteractable m = other.gameObject.GetComponent <MetallicInteractable>();

        if (m != null)
        {
            objectsInTriggerZone.Remove(m);
            if (connectingObjects.Contains(m))  //m no longer connects the trigger zones
            {
                connectingObjects.Remove(m);
                companionTrigger.connectingObjects.Remove(m);
                if (connectingObjects.Count == 0)
                {
                    circuit.setConnected(false);                              //no connecting objects means the circuit is not connected
                }
            }
        }
    }