public void EstadoCable(string tipoCable, ConductorLiquido conductor)
    {
        if (tipoCable == "A")
        {
            if (conductor == null)
            {
                TextoCableA.text = "Cable A: Desconectado";
            }
            else
            {
                TextoCableA.text = "Cable A: Conectado a " + conductor.Nombre;
            }
        }


        if (tipoCable == "B")
        {
            if (conductor == null)
            {
                TextoCableB.text = "Cable B: Desconectado";
            }
            else
            {
                TextoCableB.text = "Cable B: Conectado a " + conductor.Nombre;
            }
        }
    }
Exemple #2
0
    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        PosicionAgarre = Camera.main.transform.position + ray.direction * DistanciaAgarre;

        if (_experimento.Agarrado && Input.GetMouseButtonDown(1))
        {
            _experimento.Soltar();
            return;
        }

        RaycastHit hit;

        if (!Physics.Raycast(ray, out hit, 100, 1 << LayerMask.NameToLayer("Mouse")))
        {
            GameObject[] objs = GameObject.FindGameObjectsWithTag("MaterialReactivo");
            for (int i = 0; i < objs.Length; i++)
            {
                ConductorLiquido c = objs[i].GetComponent <ConductorLiquido>();
                if (c != null)
                {
                    c.Desmarcar();
                }
            }

            return;
        }


        if (hit.collider.tag == "MaterialAgarrable")
        {
            if (_experimento.Agarrado == null && Input.GetMouseButtonDown(0))
            {
                _experimento.Agarrar(hit.collider.gameObject);
            }
        }
        else if (hit.collider.tag == "MaterialReactivo")
        {
            if (_experimento.Agarrado != null)
            {
                MaterialAgarrableCable cable = _experimento.Agarrado.GetComponent <MaterialAgarrableCable>();

                string tipoCable = cable.Tipo;

                ConductorLiquido conductor = hit.collider.GetComponent <ConductorLiquido>();
                conductor.MarcarTipo(tipoCable);

                if (Input.GetMouseButtonDown(0))
                {
                    _experimento.Soltar();
                    cable.TransformConexion = conductor.Conexion(tipoCable);
                    cable.EstaConectado     = true;

                    UIConductividad.Instancia.EstadoCable(cable.Tipo, conductor);
                }
            }
        }
    }