Exemplo n.º 1
0
 /// <summary>
 /// Finishes loading and activates the element
 /// </summary>
 /// <param name="currentUIElement"></param>
 private void ActivateElement(IGazeable currentUIElement)
 {
     currentUIElement.Activate();
     Activated = true;
     LoadingCircle.GetComponent <Animator>().SetBool("Loading", false);
     currentUIElement.OnHoverEnd();
 }
Exemplo n.º 2
0
    public void Update()
    {
        bool hasHit = Physics.Raycast(transform.position, transform.forward, out RaycastHit hit, MaxRange);

        if (hasHit && hit.collider.gameObject.GetComponentInChildren <IGazeable>() != null)
        {
            IGazeable currentUIElement = hit.collider.gameObject.GetComponentInChildren <IGazeable>();

            if (currentUIElement.Equals(LastUIElement))
            {
                Timer += Time.deltaTime;

                if (Timer >= TimeToLoad && !Activated)
                {
                    ActivateElement(currentUIElement);
                }
            }
            else
            {
                StartLoading(currentUIElement);
            }

            UpdateLoading(hit);
        }
        else
        {
            ResetLoader();
        }
    }
Exemplo n.º 3
0
 private void StartLoading(IGazeable currentUIElement)
 {
     LoadingCircle.GetComponent <Animator>().SetBool("Loading", true);
     Timer = 0;
     if (LastUIElement != null)
     {
         LastUIElement.OnHoverEnd();
     }
     currentUIElement.OnHoverStart();
 }
Exemplo n.º 4
0
 private void ResetLoader()
 {
     if (LastUIElement != null)
     {
         LastUIElement.OnHoverEnd();
     }
     LastUIElement = null;
     Timer         = 0;
     Activated     = false;
     LoadingCircle.GetComponent <Animator>().SetBool("Loading", false);
 }
Exemplo n.º 5
0
    private void UpdateLoading(RaycastHit hit)
    {
        LastUIElement = hit.collider.gameObject.GetComponentInChildren <IGazeable>();

        Vector3 offset = hit.normal;

        offset.Scale(new Vector3(0.005f, 0.005f, 0.005f));
        Vector3 position = hit.point + offset;

        LoadingCircle.transform.position = position;

        LoadingCircle.transform.rotation = Quaternion.LookRotation(hit.normal);
    }
Exemplo n.º 6
0
 protected void RaycastProcess()
 {
     if (Physics.Raycast(ray, out hit, 30f, gazeMask))
     {
         iGaze = (IGazeable)hit.collider.GetComponent <MonoBehaviour>();
         if (!prevIGaze.Equals(iGaze) || prevIGaze.Equals(null))
         {
             NotifyAllObserversOnStartGaze();
             iGaze.OnStartGazed();
             prevIGaze = iGaze;
         }
         iGaze.OnStayGazed();
     }
     else
     {
         NotifyAllObserversOnStopGaze();
         iGaze.OnStopGazed();
         iGaze = null;
     }
 }
Exemplo n.º 7
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        Vector3 fwd = transform.TransformDirection(Vector3.forward);

        Debug.DrawRay (transform.position, fwd*15);

        //if there is no flower set, then the flower is the only gazable object
        //otherwise any droppable area can be hit

        //		int layerMask1 = (int)GameManager.layerMasks.flower;

        if (GameManager.pickedUp) {
            layerMask1 = (int)GameManager.layerMasks.droppable;
            platform.layer = (int)GameManager.layerBits.droppable;
            flower.layer = (int)GameManager.layerBits.ignoreRaycast;
        }
        else{
            flower.layer = (int)GameManager.layerBits.flower;
            layerMask1 = (int)GameManager.layerMasks.flower;
            platform.layer = (int)GameManager.layerBits.ignoreRaycast;

        }

        if (GameManager.currScene == GameManager.scenes.proto2Input) {

            if (Physics.Raycast (transform.position, fwd, out hit, layerMask1)) {
                //			Debug.Log ("this is layer mask " + layerMask1.ToString());
                seenObj = hit.transform.GetComponent<IGazeable> ();
                if (seenObj != null) {

                    seenObj.onGazeEnter ();
                    currObj = seenObj;

                } else {
                    if (seenObj == null) {
                        //					Debug.Log ("SeenObj is Null");
                    } else if (currObj == null) {
                        //					Debug.Log ("CurrObj is Null");
                    }

                    if (currObj != null) {
                        Debug.Log ("CurrObj is " + currObj.ToString ());

                        currObj.onGazeExit ();
                        currObj = null;
                    }
                }
                //			Debug.Log ("hit " + hit.collider.gameObject.name);

            }
        }
        else if(GameManager.currScene==GameManager.scenes.proto1Snap){
            hoverFlower flowerMethods = flower.GetComponent<hoverFlower> ();
            if (Physics.Raycast (transform.position, fwd, out hit, layerMask1)) {
                seenObj = hit.transform.GetComponent<IGazeable> ();

                float flDistance = Vector3.Distance (hit.point, flower.transform.position);

                //Debug.Log ("This is im impact point" + hit.point.ToString ());
                Debug.Log ("flower distance is" + flDistance.ToString ());

                if (GameManager.pickedUp == false) {

                    if (flDistance > 0.70f && flDistance < 2f) {
                        Debug.Log ("hover flower");
                        flowerMethods.onGazeEnter ();

                        Material glowOrb = GameObject.Find ("flowerGlow").GetComponent<Renderer> ().material;
                        Utilities.setAlpha (glowOrb, flDistance*.5f);

                    } else if (flDistance < 0.70f) {
                        Debug.Log ("Pick up flower");
                        GameManager.onGaze = true;
                        flowerMethods.pickUpFlower ();
                    } else {
                        flowerMethods.onGazeExit ();
                    }
                } else { //simple code to drop flower
                    bool down = Input.GetKeyDown (KeyCode.Space);
                    bool leftClick = Input.GetMouseButton (0);

                    flowerMethods.dropFlower ();
                }

            }
        }
    }
Exemplo n.º 8
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        Vector3    fwd = transform.TransformDirection(Vector3.forward);

        Debug.DrawRay(transform.position, fwd * 15);
        cursorEndPosition = cursorEnd.transform.position;

        //if there is no flower set, then the flower is the only gazable object
        //otherwise any droppable area can be hit


//		int layerMask1 = (int)GameManager.layerMasks.flower;

        if (GameManager.pickedUp)
        {
            layerMask1     = (int)GameManager.layerMasks.droppable;
            platform.layer = (int)GameManager.layerBits.droppable;
            flower.layer   = (int)GameManager.layerBits.ignoreRaycast;
            ground.layer   = (int)GameManager.layerBits.droppable;
        }
        else
        {
            flower.layer = (int)GameManager.layerBits.ignoreRaycast;
//			glow.layer = 1 << (int)GameManager.layerBits.flowerGlow;
            layerMask1 = 1 << (int)GameManager.layerBits.flowerGlow;
            //layerMask1 = (int)GameManager.layerMasks.flower;
            platform.layer = (int)GameManager.layerBits.ignoreRaycast;
            ground.layer   = (int)GameManager.layerBits.ignoreRaycast;
        }



        hoverFlower flowerMethods = flower.GetComponent <hoverFlower> ();

        if (Physics.Raycast(transform.position, fwd, out hit, layerMask1))
        {
            Debug.Log("hit collider is " + hit.collider.name);
//			Debug.Log ("gameobject is " + hit.transform.gameObject.name);
            seenObj = hit.transform.GetComponent <IGazeable> ();

//			flDistance = Vector3.Distance (hit.point, flower.transform.position);
//			flDistance2 = Vector3.Distance (cursorEnd.transform.position, flower.transform.position);


            if (GameManager.pickedUp == false && flower.GetComponent <Rigidbody>().useGravity == false)
            {
                Material glowOrb = glow.GetComponent <Renderer> ().material;

                Vector3 glowSize = glowOriginalScale + new Vector3(1f, 1f, 1f);
                LeanTween.scale(glow, glowSize, 1f);
                Utilities.setAlpha(glowOrb, .5f);


//				float distancePastGlow = 0f;

//				if (flDistance2 > 2.5f && flDistance2 < 2.3f && cursorReady == true) {
//					Debug.Log ("hover flower");
//
//					flowerMethods.onGazeEnter ();
//					Utilities.setAlpha (glowOrb, flDistance2*.66f - .33f);
//
//					distancePastGlow = 2f - flDistance2;
//					glowExpand = distancePastGlow / glowExpandDampen;
//
//					if(glow.transform.localScale.x < 45f)
//						glow.transform.localScale += new Vector3 (distancePastGlow, distancePastGlow, distancePastGlow);
//
//				} else if (flDistance2 < 2.5f & cursorReady == true) {
//					Debug.Log ("Pick up flower");
//					GameManager.onGaze = true;
//					flowerMethods.pickUpFlower ();
//					cursorReady = false;
//				} else {
//					flowerMethods.onGazeExit ();
//					cursorReady = true;
//					glow.transform.localScale = glowOriginalScale;
//					Utilities.setAlpha (glowOrb, flDistance2*.5f);
//				}
            }
            else                 //simple code to drop flower
            {
                bool down      = Input.GetKeyDown(KeyCode.Space);
                bool leftClick = Input.GetMouseButton(0);

                if (down || leftClick)
                {
                    Debug.Log("Drop flower");
                    flowerMethods.dropFlower();
                    cursorReady = false;
                }
            }
        }
    }
Exemplo n.º 9
0
    // Update is called once per frame
    void Update()
    {
        RaycastHit hit;
        Vector3    fwd = transform.TransformDirection(Vector3.forward);

        Debug.DrawRay(transform.position, fwd * 15);

        //if there is no flower set, then the flower is the only gazable object
        //otherwise any droppable area can be hit


//		int layerMask1 = (int)GameManager.layerMasks.flower;

        if (GameManager.pickedUp)
        {
            layerMask1     = (int)GameManager.layerMasks.droppable;
            platform.layer = (int)GameManager.layerBits.droppable;
            flower.layer   = (int)GameManager.layerBits.ignoreRaycast;
        }
        else
        {
            flower.layer   = (int)GameManager.layerBits.flower;
            layerMask1     = (int)GameManager.layerMasks.flower;
            platform.layer = (int)GameManager.layerBits.ignoreRaycast;
        }

        if (GameManager.currScene == GameManager.scenes.proto2Input)
        {
            if (Physics.Raycast(transform.position, fwd, out hit, layerMask1))
            {
                //			Debug.Log ("this is layer mask " + layerMask1.ToString());
                seenObj = hit.transform.GetComponent <IGazeable> ();
                if (seenObj != null)
                {
                    seenObj.onGazeEnter();
                    currObj = seenObj;
                }
                else
                {
                    if (seenObj == null)
                    {
                        //					Debug.Log ("SeenObj is Null");
                    }
                    else if (currObj == null)
                    {
                        //					Debug.Log ("CurrObj is Null");
                    }

                    if (currObj != null)
                    {
                        Debug.Log("CurrObj is " + currObj.ToString());

                        currObj.onGazeExit();
                        currObj = null;
                    }
                }
                //			Debug.Log ("hit " + hit.collider.gameObject.name);
            }
        }
        else if (GameManager.currScene == GameManager.scenes.proto1Snap)
        {
            hoverFlower flowerMethods = flower.GetComponent <hoverFlower> ();
            if (Physics.Raycast(transform.position, fwd, out hit, layerMask1))
            {
                seenObj = hit.transform.GetComponent <IGazeable> ();

                float flDistance = Vector3.Distance(hit.point, flower.transform.position);

                //Debug.Log ("This is im impact point" + hit.point.ToString ());
                Debug.Log("flower distance is" + flDistance.ToString());


                if (GameManager.pickedUp == false)
                {
                    if (flDistance > 0.70f && flDistance < 2f)
                    {
                        Debug.Log("hover flower");
                        flowerMethods.onGazeEnter();

                        Material glowOrb = GameObject.Find("flowerGlow").GetComponent <Renderer> ().material;
                        Utilities.setAlpha(glowOrb, flDistance * .5f);
                    }
                    else if (flDistance < 0.70f)
                    {
                        Debug.Log("Pick up flower");
                        GameManager.onGaze = true;
                        flowerMethods.pickUpFlower();
                    }
                    else
                    {
                        flowerMethods.onGazeExit();
                    }
                }
                else                     //simple code to drop flower
                {
                    bool down      = Input.GetKeyDown(KeyCode.Space);
                    bool leftClick = Input.GetMouseButton(0);

                    flowerMethods.dropFlower();
                }
            }
        }
    }