Пример #1
0
    // Update is called once per frame
    void Update()
    {
        down      = Input.GetKeyDown(KeyCode.Space);
        leftClick = Input.GetMouseButton(0);

        //		if (down)
        //			Debug.Log ("Hit down");
        //		if (held)
        //			Debug.Log ("HELD");
        //		if (up)
        //			Debug.Log ("UP");

        if (down || leftClick)
        {
            //if flower is picked up, then either drop me on platform or on the ground
            if (GameManager.pickedUp)
            {
                Debug.Log("++Drop Flower Down");

                flower.dropFlower();


                //if flower is not picked up and I'm being looked at, then pick me up!
            }
            else
            {
                flower.pickUpFlower();
            }
        }
    }
Пример #2
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;
                }
            }
        }
    }
Пример #3
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();
                }
            }
        }
    }