Пример #1
0
    private void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            MouseClickEvent clickEvent = MouseUtil.GetMousePositionInWorld();
            if (clickEvent.hitGameObject.tag == "Intractable")
            {
                target = clickEvent.hitGameObject;
                target.GetComponent <Collider>().enabled = false;
                Debug.Log("Picked Up " + target.name);
            }
        }
        if (Input.GetMouseButtonUp(0))
        {
            if (target)
            {
                MouseClickEvent clickEvent = MouseUtil.GetMousePositionInWorld();
                target.transform.position = clickEvent.point;
                target.GetComponent <Collider>().enabled = true;
                Debug.Log("Dropped " + target.name);
                target = null;
            }
        }

        if (target != null)
        {
            MouseClickEvent clickEvent = MouseUtil.GetMousePositionInWorld();
            target.transform.position = clickEvent.point + new Vector3(0, 0.2f, 0);
        }
    }
Пример #2
0
    void Update()
    {
        // Check for movement inputs.
        if (Input.GetMouseButtonDown(1) && !EventSystem.current.IsPointerOverGameObject())
        {
            MouseClickEvent mouseClick = MouseUtil.GetMousePositionInWorld();
            targetPosition = mouseClick.point;
            SetMovementMarker(targetPosition);

            if (mouseClick.hitGameObject.tag == "Intractable")
            {
                // End old interaction
                if (interactedObject != null)
                {
                    interactedObject.EndInteraction();
                }

                // Interact with object
                interactedObject = mouseClick.hitGameObject.gameObject.GetComponent <Interactable>();
                interactedObject.SetInteraction(agentController);
            }
            else
            {
                agentController.MoveToPosition(targetPosition);
                if (interactedObject)
                {
                    // Stop focusing on an Item.
                    interactedObject.EndInteraction();
                }
            }
            UIEventHandler.ContainerClosed();
            UIEventHandler.DialogInterrupted();
        }

        if (agentController.HasReachedDestination())
        {
            RemoveMovementMarker();
        }
        else
        {
            SetMovementMarker(agentController.GetAgentDestination());
        }
    }