Exemplo n.º 1
0
    void Naming()
    {
        foreach (char c in Input.inputString)
        {
            if (c == '\b')
            {
                if (debugText.Length > 0)
                {
                    debugText = debugText.Substring(0, debugText.Length - 1);
                }
            }
            else if ((c == '\n') || (c == '\r'))
            {
                // state = gb_state.Connecting;


                // if(debugText != string.Empty)
                // {
                if (debugText == string.Empty)
                {
                    debugText = (++nonRoomNextKey).ToString();
                }

                state                = gb_state.Moving;
                selectedNode.name    = "Point_" + debugText;
                selectedNode.nodeKey = debugText;

                selectedNode.isRoom = ((debugText[0] == '1') || (debugText[0] == '2') || (debugText[0] == '3') ||
                                       (debugText[0] == '4') || (debugText[0] == '5') || (debugText[0] == '6') ||
                                       (debugText[0] == '7') || (debugText[0] == '8'));

                print("New node is " + "Point_" + debugText);
                debugText = string.Empty;
                // }
            }
            else
            {
                debugText += c;
            }
        }
    }
Exemplo n.º 2
0
    void Shooting()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Ray ray = cam_transform.GetComponent <Camera>().ScreenPointToRay(new Vector3(Screen.width / 2f, Screen.height / 2f, 0f));

            RaycastHit hit;
            Debug.Log(ray.origin);
            Debug.Log(ray.direction);

            if (Physics.Raycast(ray, out hit, 10000f, groundMask))
            {
                GameObject node_new = Instantiate(nodePrefab, hit.point + Vector3.up * heightAboveGround, Quaternion.identity);
                //lastPlacedNode = node_new.GetComponent<Node>();
                SelectNode(node_new.GetComponent <Node>());

                state = gb_state.Naming;
                Debug.Log("HIT " + hit.collider.name);
                Debug.DrawRay(ray.origin, ray.direction * hit.distance, Color.blue, 5f);
            }
        }
    }
Exemplo n.º 3
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.V))
        {
            switch (state)
            {
            case gb_state.Moving:
                state = gb_state.Connecting;
                break;

            case gb_state.Naming:
                Debug.LogWarning("Cant exit Naming state");
                break;

            case gb_state.Connecting:
                state = gb_state.Moving;
                break;
            }
        }
        switch (state)
        {
        case gb_state.Moving:
            Moving();
            break;

        case gb_state.Naming:
            Naming();
            break;

        case gb_state.Connecting:
            Connecting();
            break;

        default:
            Debug.LogError("State " + state.ToString() + " has no behaviour");
            break;
        }
    }