Exemplo n.º 1
0
    // Here is the logic for either selecting a path to walk to or an
    // object to interact with (NPC or item)
    void ClickAction()
    {
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            switch (hit.collider.name)
            {
            case "SelectBox1":
                uiController.ChoiceClicked(1);
                break;

            case "SelectBox2":
                uiController.ChoiceClicked(2);
                break;

            case "SelectBox3":
                uiController.ChoiceClicked(3);
                break;

            case "SelectBox4":
                uiController.ChoiceClicked(4);
                break;

            case "PhoneIcon":
                uiController.CreatePhone();
                break;

            case "DialogBox1":
                convoController.MakeConversationChoice(1);
                break;

            case "DialogBox2":
                convoController.MakeConversationChoice(2);
                break;

            case "DialogBox3":
                convoController.MakeConversationChoice(3);
                break;

            default:
                Debug.Log(hit.collider.name + " clicked .. no event");
                break;
            }
        }
        else // If no hitbox, then check the node clicked on
        {
            uiController.WipeUI();
            Vector3 point = ray.origin + (ray.direction * 4.5f);

            // Check the node clicked on to see if there is an action to take on it
            NodeGrid pointNode = grid.FindClosestNode(point.x, point.y);
            if (pointNode != null)
            {
                if (pointNode.IsEmpty())
                {
                    hero.StartPath(pointNode);
                }
                else
                {
                    tempInteractable = pointNode.occupyingObject.GetComponent <Interactable>();
                    InteractableInfo interactableInfo = tempInteractable.GetComponent <Interactable>().info;
                    if (interactableInfo != null)
                    {
                        uiController.CreateSelection(tempInteractable.transform.position.x,
                                                     tempInteractable.transform.position.y,
                                                     interactableInfo);
                    }
                }
            }
        }
    }