예제 #1
0
    public void getPressPosInteractable()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

        if (!Input.GetMouseButtonDown(0))
        {
            return;
        }

        RaycastHit hit;

        // Check if item pressed is interactable.
        if (!Physics.Raycast(ray, out hit, layerMask))
        {
            Debug.Log("Nothing hit");
            return;
        }

        hitCollider = hit.collider.transform.position;
        otherObject = hit.collider.gameObject;
        //Debug.Log("Item has been pressed " + hit.collider.name);

        if (hit.collider.tag != "interactable" && hit.collider.tag != "arrow")
        {
            Debug.Log("Destroyed Arrows");
            InstantDestroyArrows();
        }

        // Check if interactable object has been moved to, and what direction you're in.
        if (hit.collider.tag == "interactable" /* && Vector3.Distance(transform.position, otherObject) < 1 */)
        {
            // objectPressedBool = true;
            // Debug.Log("Entered box click");
            // LockMovement();
            objectClicked = hit.collider.gameObject;
            InstantDestroyArrows();

            if (arrowInteractionSwitcher)
            {
                OldSpawnArrows();
            }
            else
            {
                bool[] arrowBool = new bool[2];
                arrowBool = _ISC.IsHorizontal(otherObject);

                if (arrowBool[1] == true)
                {
                    if (arrowBool[0] == true)
                    {
                        _moveObject.CheckNorthSouth(objectClicked);
                    }

                    else
                    {
                        _moveObject.CheckWestEast(objectClicked);
                    }
                }
                else
                {
                    Debug.Log("Out of bounds");
                }
            }
        }

        if (hit.collider.tag == "arrow")
        {
            Debug.Log("Entered arrow statement");
            arrowClicked = hit.collider.gameObject;


            /*          if(hit.collider.tag == "northArrow") {
             *              Debug.Log("North arrow clicked");
             *          }
             *          if(hit.collider.tag == "southArrow") {
             *              Debug.Log("North arrow clicked");
             *          }
             *          if(hit.collider.tag == "northArrow") {
             *              Debug.Log("North arrow clicked");
             *          }
             *          if(hit.collider.tag == "northArrow") {
             *              Debug.Log("North arrow clicked");
             *          } */

            switch (hit.collider.name)
            {
            case "northArrow":

                //Debug.Log("North Arrow Clicked");
                _moveObject.MoveNorth(objectClicked, arrowInteractionSwitcher);
                DestroyArrows(hit.collider.gameObject);
                break;

            case "southArrow":
                //Debug.Log("South Arrow Clicked");
                _moveObject.MoveSouth(objectClicked, arrowInteractionSwitcher);
                DestroyArrows(hit.collider.gameObject);
                break;

            case "eastArrow":
                //Debug.Log("East Arrow Clicked");
                _moveObject.MoveEast(objectClicked, arrowInteractionSwitcher);
                DestroyArrows(hit.collider.gameObject);
                break;

            case "westArrow":
                //Debug.Log("West Arrow Clicked");
                _moveObject.MoveWest(objectClicked, arrowInteractionSwitcher);
                DestroyArrows(hit.collider.gameObject);
                break;

            default:
                //Debug.Log("Name doesn't exist");
                break;
            }


            /*                 if(colliding ) {
             *              otherObject.transform.position = oldPos;
             *              // Play not moveable animation
             *              }
             *
             *              else {
             *              otherObject.transform.position = oldPos;
             *              Vector3.Lerp(hitCollider, new Vector3(hitCollider.x, hitCollider.y, hitCollider.z), interactStep);
             *              // Play move animation
             *              } */
        }
        /*         CheckObjectMovement(otherObject); */
    }