Exemplo n.º 1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        Tunnel tunnel = collision.GetComponent <Tunnel>();

        if (tunnel == null)
        {
            return;
        }

        if (tunnel.connections0.Count == 0)
        {
            AddConnections0(tunnel);
        }
        if (tunnel.connections1.Count == 0)
        {
            AddConnections1(tunnel);
        }

        foreach (Tunnel connectedTunnel in tunnel.connections0)
        {
            if (connectedTunnel.connections0.Count == 0)
            {
                AddConnections0(connectedTunnel);
                itemSpawn.SpawnAlongTunnel(connectedTunnel);
            }
        }

        foreach (Tunnel connectedTunnel in tunnel.connections1)
        {
            if (connectedTunnel.connections1.Count == 0)
            {
                AddConnections1(connectedTunnel);
                itemSpawn.SpawnAlongTunnel(connectedTunnel);
            }
        }
    }