Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
		
        GameObject gestureObject = GameObject.FindWithTag( "Gesture" );
        if (gestureObject != null)
        {
            bool rChange = false;
            bool lChange = false;

            GestureRecognizer gRec = gestureObject.GetComponent<GestureRecognizer>();
            if (rightArm != gRec.rightArm)
            {
                rightArm = gRec.rightArm;
                rChange = true;
            }
            if (leftArm != gRec.leftArm)
            {
                leftArm = gRec.leftArm;
                lChange = true;
            }
			
             if (leftArm == GestureRecognizer.ARM_STATE.AS_POS_Y &&
                rightArm == GestureRecognizer.ARM_STATE.AS_POS_Y )
            {
                currentGesture = Gesture.SELECT;
                this.Select();
                
            }
            else if (leftArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                rightArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                currentGesture ==Gesture.SELECT)
            {
                //currentGesture = Gesture.THROW;
                this.Throw();
            }
			else if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_Y &&
                rightArm == GestureRecognizer.ARM_STATE.AS_NEG_Y &&
                currentGesture ==Gesture.SELECT) {
				Selector s = selector.GetComponent<Selector>();
		        s.Disable();
				s.Hide();
                if (swordRightflag == false && shieldflag == false)
                {
                    swordLeftflag = true;
                    swordRightflag = true;
                    //swordRightObject.transform.position = tempVectSwordRight + transform.position;
                }
                currentGesture = Gesture.NONE;
			}


			if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_X &&
                rightArm == GestureRecognizer.ARM_STATE.AS_POS_X && currentGesture != Gesture.SELECT)
			{
				swordLeftflag = false;
				swordRightflag = false;
				shieldflag = true;
			}  else if (currentGesture != Gesture.SELECT && currentGesture != Gesture.THROW) {
				swordLeftflag = true;
				swordRightflag = true;
				shieldflag = false;
			}
			if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_Y &&
                rightArm == GestureRecognizer.ARM_STATE.AS_POS_Y && currentGesture != Gesture.SELECT && currentGesture != Gesture.THROW)
			{
				audio.PlayOneShot(GhostVoice,0.1f);
				foreach(GameObject fruit in radar.fruits)
					{
                        if (fruit != null)
                        {
                            GameObject DestroyObject = Instantiate(Destroyed, fruit.transform.position, fruit.transform.rotation) as GameObject;
                            Destroy(DestroyObject, 5);
                            Destroy(fruit);
                        }
					}
				
			}
			swordLeftObject.active = swordLeftflag;
			swordRightObject.active = swordRightflag;
			if (shieldflag) {
				shieldObject.renderer.enabled = true;
				shieldCollider.collider.enabled =true;
			} else {
				shieldObject.renderer.enabled = false;
				shieldCollider.collider.enabled =false;
			}
        }
    }
Esempio n. 2
0
    // Update is called once per frame
    void Update()
    {
        if (hitsLeft <= 0)
        {
            hitsLeft = 0;
            Debug.Log("Player Died");
        }

        //GestureRecognizer.ARM_STATE rightArm =

        GameObject gestureObject = GameObject.FindWithTag("Gesture");

        if (gestureObject != null)
        {
            bool rChange = false;
            bool lChange = false;

            GestureRecognizer gRec = gestureObject.GetComponent <GestureRecognizer>();
            if (rightArm != gRec.rightArm)
            {
                rightArm = gRec.rightArm;
                //Debug.Log(Time.deltaTime + "right " + rightArm);
                rChange = true;
            }
            if (leftArm != gRec.leftArm)
            {
                leftArm = gRec.leftArm;
                //Debug.Log(Time.deltaTime + "left " + leftArm);
                lChange = true;
            }

            if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_X &&
                rightArm == GestureRecognizer.ARM_STATE.AS_POS_X &&
                (currentGesture == Gesture.NONE || currentGesture == Gesture.HEAL || currentGesture == Gesture.SELECT))
            {
                currentGesture = Gesture.HEAL;
                this.Heal();
            }

            else if (leftArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                     rightArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                     (currentGesture == Gesture.NONE || currentGesture == Gesture.LIGHTNING || currentGesture == Gesture.SELECT))
            {
                currentGesture = Gesture.LIGHTNING;
                this.Lightning();
            }

            else if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_X &&
                     rightArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                     (currentGesture == Gesture.NONE || currentGesture == Gesture.SELECT))
            {
                currentGesture = Gesture.SELECT;
                this.Select();
            }

            else if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_Y &&
                     rightArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                     (currentGesture == Gesture.SELECT))
            {
                currentGesture = Gesture.HOLDING;
                this.Grab();
            }

            else if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_X &&
                     rightArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                     (currentGesture == Gesture.HOLDING))
            {
                currentGesture = Gesture.HEAL;
                this.Throw();
            }

            else if (leftArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                     (currentGesture == Gesture.NONE || currentGesture == Gesture.PUSH || currentGesture == Gesture.SELECT))
            {
                currentGesture = Gesture.PUSH;
                this.Push();
            }
            else if (currentGesture != Gesture.SELECT && currentGesture != Gesture.HOLDING)
            {
                //Debug.Log("None" + Time.deltaTime);
                currentGesture = Gesture.NONE;
            }
            else
            {
                Selector s = selector.GetComponent <Selector>();
                s.Disable();
                s.Hide();
                laf.DisablePush();
                laf.DisableLightning();
            }

            Debug.Log(this.currentGesture + " " + Time.deltaTime);
        }
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        GameObject gestureObject = GameObject.FindWithTag("Gesture");

        if (gestureObject != null)
        {
            bool rChange = false;
            bool lChange = false;

            GestureRecognizer gRec = gestureObject.GetComponent <GestureRecognizer>();
            if (rightArm != gRec.rightArm)
            {
                rightArm = gRec.rightArm;
                rChange  = true;
            }
            if (leftArm != gRec.leftArm)
            {
                leftArm = gRec.leftArm;
                lChange = true;
            }

            if (leftArm == GestureRecognizer.ARM_STATE.AS_POS_Y &&
                rightArm == GestureRecognizer.ARM_STATE.AS_POS_Y)
            {
                currentGesture = Gesture.SELECT;
                this.Select();
            }
            else if (leftArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                     rightArm == GestureRecognizer.ARM_STATE.AS_POS_Z &&
                     currentGesture == Gesture.SELECT)
            {
                //currentGesture = Gesture.THROW;
                this.Throw();
            }
            else if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_Y &&
                     rightArm == GestureRecognizer.ARM_STATE.AS_NEG_Y &&
                     currentGesture == Gesture.SELECT)
            {
                Selector s = selector.GetComponent <Selector>();
                s.Disable();
                s.Hide();
                if (swordRightflag == false && shieldflag == false)
                {
                    swordLeftflag  = true;
                    swordRightflag = true;
                    //swordRightObject.transform.position = tempVectSwordRight + transform.position;
                }
                currentGesture = Gesture.NONE;
            }


            if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_X &&
                rightArm == GestureRecognizer.ARM_STATE.AS_POS_X && currentGesture != Gesture.SELECT)
            {
                swordLeftflag  = false;
                swordRightflag = false;
                shieldflag     = true;
            }
            else if (currentGesture != Gesture.SELECT && currentGesture != Gesture.THROW)
            {
                swordLeftflag  = true;
                swordRightflag = true;
                shieldflag     = false;
            }
            if (leftArm == GestureRecognizer.ARM_STATE.AS_NEG_Y &&
                rightArm == GestureRecognizer.ARM_STATE.AS_POS_Y && currentGesture != Gesture.SELECT && currentGesture != Gesture.THROW)
            {
                audio.PlayOneShot(GhostVoice, 0.1f);
                foreach (GameObject fruit in radar.fruits)
                {
                    if (fruit != null)
                    {
                        GameObject DestroyObject = Instantiate(Destroyed, fruit.transform.position, fruit.transform.rotation) as GameObject;
                        Destroy(DestroyObject, 5);
                        Destroy(fruit);
                    }
                }
            }
            swordLeftObject.active  = swordLeftflag;
            swordRightObject.active = swordRightflag;
            if (shieldflag)
            {
                shieldObject.renderer.enabled   = true;
                shieldCollider.collider.enabled = true;
            }
            else
            {
                shieldObject.renderer.enabled   = false;
                shieldCollider.collider.enabled = false;
            }
        }
    }