예제 #1
0
    private void ClickSetPath()
    {
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
        {
            TraversableNode tn = hit.collider.GetComponent <TraversableNode>();
            if (tn == null)
            {
                return;
            }

            else if (Input.GetMouseButtonDown(1))
            {
                if (_startNode != null)
                {
                    _startNode.ResetMaterial();
                }

                path       = null;
                _startNode = tn;
                _startNode.GetComponent <Renderer>().material = mat;
                transform.position = _startNode.transform.position;
            }

            else if (Input.GetMouseButtonDown(0))
            {
                _endNode = tn;
                _endNode.GetComponent <Renderer>().material = mat;
                transform.position = _startNode.transform.position;

                if (_startNode != null && _endNode != null)
                {
                    path = NodeNav.TwinStarII(_startNode, _endNode, true);
                }
            }
        }
    }
예제 #2
0
    // ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ---------- ----------
    private void ClickSetPath()
    {
        RaycastHit hit;

        if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), out hit))
        {
            TraversableNode tn = hit.collider.GetComponent <TraversableNode>();
            if (tn == null)
            {
                return;
            }

            else if (Input.GetMouseButtonDown(1))
            {
                if (currentPositionNode != null)
                {
                    currentPositionNode.isOccupied = false;
                    currentPositionNode.RemoveInformation(this);
                }

                _nodePathStack                 = null;
                _currentPositionNode           = tn;
                currentPositionNode.isOccupied = true;
                currentPositionNode.AddInformation(this);

                transform.position = currentPositionNode.transform.position;
            }

            else if (Input.GetMouseButtonDown(0))
            {
                if (currentPositionNode != null && tn != null)
                {
                    _nodePathStack = NodeNav.TwinStarII(currentPositionNode, tn, true);
                }
            }
        }
    }