예제 #1
0
    void Update()
    {
        var speedBodyIncrement = (difficulty / 10);

        Debug.Log("Incremente de crecimiento  " + speedBodyIncrement);
        CharacterbodyFat.transform.localScale = new Vector3(CharacterbodyFat.transform.localScale.x + (0.5f + speedBodyIncrement) * Time.deltaTime, CharacterbodyFat.transform.localScale.y, CharacterbodyFat.transform.localScale.z);
        if ((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || Input.GetMouseButtonDown(0))
        {
            var mousWorldPos = cam.ScreenToWorldPoint(Input.mousePosition);
            var pos          = new Vector3(mousWorldPos.x, mousWorldPos.y, this.transform.position.z);

            GameObject objectHit = MyHelpers.getRaycastedGameObject(new Vector3(Input.mousePosition.x, Input.mousePosition.y, this.transform.position.z), cam);

            if (objectHit != null)
            {
                if (objectHit.name.Equals("circle(Clone)"))
                {
                    Destroy(objectHit);
                    if (CharacterbodyFat.transform.localScale.x >= 2.575463f)
                    {
                        CharacterbodyFat.transform.localScale = new Vector3(CharacterbodyFat.transform.localScale.x - 0.5f, 5, 5);
                    }
                }
            }
        }
    }
	private void swipe (string currentLocation, Vector2 mStartPosition){
		GameObject objectHit =  MyHelpers.getRaycastedGameObject(new Vector3(mStartPosition.x,mStartPosition.y,1f),Camera.current);
		if (objectHit != null ) {
			MyHandClass hand = objectHit.GetComponent<MyHandClass>();
			if (hand != null && hand.location.Equals (currentLocation)) {
				hand.OnSwipe ();
			}
		}
	}
 void Update()
 {
             #if UNITY_EDITOR
     if (Input.GetMouseButtonDown(0))
     {
         GameObject objectHit = MyHelpers.getRaycastedGameObject(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 1f), cam);
         if (objectHit != null)
         {
             MyHandClass hand = objectHit.GetComponent <MyHandClass>();
             if (hand != null)
             {
                 hand.OnSwipe();
             }
         }
     }
             #endif
 }
    void Update()
    {
        if ((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began) || Input.GetMouseButtonDown(0))
        {
            if (lineRenderer == null)
            {
                var trailRendererGO = new GameObject("trailRenderer");
                lineRenderer            = trailRendererGO.AddComponent <TrailRenderer>();
                lineRenderer.startWidth = 0.06f;
                lineRenderer.endWidth   = 0.01f;
                lineRenderer.time       = 2f;
                lineRenderer.material   = Resources.Load <Material>("Materials/LineRenderer");
            }

            if (!isMouseDown)
            {
                isMouseDown = true;

                var mousWorldPos = cam.ScreenToWorldPoint(Input.mousePosition);
                var pos          = new Vector3(mousWorldPos.x, mousWorldPos.y, this.transform.position.z);

                GameObject objectHit = MyHelpers.getRaycastedGameObject(new Vector3(Input.mousePosition.x, Input.mousePosition.y, this.transform.position.z), cam);
                if (objectHit != null)
                {
                    if (objectHit.name.Equals("StartPoint"))
                    {
                        //  GameObject.Find("leftEye").transform.localPosition;
                        Debug.Log("GOOD START");
                        goodStart = true;
                    }
                    else
                    {
                        mainScript.gameOver(true);
                    }
                }
            }
        }
        if ((Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended) || Input.GetMouseButtonUp(0))
        {
            isMouseDown = false;

            Debug.Log("FINGER RELEASEE  :( ");
            mainScript.gameOver(true);
        }
        if (isMouseDown)
        {
            var mousWorldPos = cam.ScreenToWorldPoint(Input.mousePosition);
            var pos          = new Vector3(mousWorldPos.x, mousWorldPos.y, this.transform.position.z);

            GameObject objectHit = MyHelpers.getRaycastedGameObject(new Vector3(Input.mousePosition.x, Input.mousePosition.y, this.transform.position.z), cam);
            if (objectHit != null && !objectHit.name.Equals("StartPoint"))
            {
                if (objectHit.name.Equals("FinalPoint") && goodStart)
                {
                    //  GameObject.Find("leftEye").transform.localPosition;
                    Debug.Log("WIIIIN");
                    mainScript.gameOver();
                }
                else
                {
                    Debug.Log("LOOSE");

                    mainScript.gameOver(true);
                }
            }
            lineRenderer.transform.localPosition = new Vector3(pos.x, pos.y, 0f);
        }
    }