Ejemplo n.º 1
0
    void SwitchBeam()
    {
        if (Physics.Raycast(_ray, out _hit, 1000))
        {
            GameObject goBeam = _hit.transform.gameObject;
            if (goBeam.layer == 9) //check if the selected object is a beam
            {
                Beam beam = _triGrid.GetBeam(goBeam);
                beam._exists = !beam._exists;
                if (beam._exists)
                {
                    // this number will be used to detemine if a beam should exist
                    beam._startNode._connectedBeams++;
                    beam._endNode._connectedBeams++;

                    _triGrid._numberOfBeams++;
                }
                else
                {
                    _triGrid._numberOfBeams--;
                }
                _triGrid._beamExists[beam._index] = !_triGrid._beamExists[beam._index];

                beam.SwitchBeams();
            }
        }
    }