Exemplo n.º 1
0
    // Note: This should not run during inspect mode
    public void ReticleGaze()
    {
        if (!_inpsectScript.inspectionMode)
        {
            int x = Screen.width / 2;
            int y = Screen.height / 2;

            Ray        ray = mainCamera.ScreenPointToRay(new Vector3(x, y));
            RaycastHit _hit;

            if (Physics.Raycast(ray, out _hit, rayDistance))
            {
                Debug.DrawRay(ray.origin, ray.direction * 100, Color.yellow);                 // Drawing ray visual
                // if the ray hits an object with a tag, change the text

                Prop          _prop     = _hit.collider.GetComponent <Prop>();
                MakeUIElement noteMaker = _hit.collider.GetComponent <MakeUIElement>();

                if (_prop != null)
                {
                    tMPGUI.text = _prop.displayName;
                    reticle.SetActive(false);
                }
                else if (noteMaker != null)
                {
                    tMPGUI.text = "?";
                    reticle.SetActive(false);
                }

                //Switch for other objects
            }
            else
            {
                tMPGUI.text = "";
                reticle.SetActive(true);
            }
        }
    }
Exemplo n.º 2
0
    // (REWRITE!) Picking up the item and entering "Inspection Mode"
    // Note: Seperate shooting Raycast from PickupObject()?
    // This function should only cover the picking up option
    public void PickupObject()
    {
        if (Input.GetMouseButtonDown(0))
        {
            int x = Screen.width / 2;
            int y = Screen.height / 2;

            Ray        ray = mainCamera.GetComponent <Camera>().ScreenPointToRay(new Vector3(x, y));
            RaycastHit hit = new RaycastHit();
            if (Physics.Raycast(ray, out hit))
            {
                //Debug.Log(hit.collider);

                Prop pickupable = hit.collider.GetComponent <Prop>();
                //temp
                PillarButton    button        = hit.collider.GetComponent <PillarButton>();
                LightOrbScript  orb           = hit.collider.GetComponent <LightOrbScript>();
                WorldCanvasMenu canvas        = hit.collider.GetComponent <WorldCanvasMenu>();
                MakeUIElement   makeUiElement = hit.collider.GetComponent <MakeUIElement>();
                SunRotator      sunDial       = hit.collider.GetComponent <SunRotator>();


                Debug.DrawRay(ray.origin, ray.direction * 100, Color.green); // Drawing ray

                if (pickupable != null &&
                    Vector3.Distance(pickupable.transform.position, mainCamera.transform.position) < pickupDistance)
                {
                    // Getting item original Location (These are not being set to the right value)
                    // _objOriginalPos = pickupable.originalPos;
                    //_objOriginalRot = pickupable.originalRot;
                    //Debug.Log(" IO._objOriginalRot: " + pickupable.originalRot);


                    isCarrying    = true;
                    carriedObject = pickupable;
                    carriedObject.transform.parent = gameObject.transform;
                    pickupable.GetComponent <Rigidbody>().isKinematic = true;
                    pickupable.amPickedUp = true;
                }
                if (button != null)
                {
                    button.amPressed = true;
                }
                if (orb != null && orb.objPlaced)
                {
                    orb.transform.Rotate(90, 0, 0);
                }
                if (canvas != null)
                {
                    CanvasInteraction();
                }

                if (sunDial != null)
                {
                    sunDial.amActivated = true;
                    sunDial.RotateSun();
                }

                if (makeUiElement != null)
                {
                    if (!makeUiElement.elementActive)
                    {
                        makeUiElement.EnableUI();
                    }
                    else
                    {
                        makeUiElement.DisableUI();
                    }
                }
            }
        }
    }