Example #1
0
    public void OnFingerSet(Lean.LeanFinger finger)
    {
        // Right side of the screen?
        if (finger.ScreenPosition.x > Screen.width / 2)
        {
            // Does it exist?
            if (RightObject != null)
            {
                // Position it in front of the finger
                RightObject.position = finger.GetWorldPosition(10.0f);
            }
        }
        // Left side?
        else
        {
            // Does it exist?
            if (RightObject != null)
            {
                // Position it in front of the finger
                LeftObject.position = finger.GetWorldPosition(10.0f);
            }
        }

        // NOTE: If you want to prevent fingers from crossing sides then you can check finger.StartScreenPosition first
    }
    public void OnFingerTap(Lean.LeanFinger finger)
    {
        Vector2 referencePoint = new Vector2();

        referencePoint.x = 0.0f;
        referencePoint.y = 0.0f;
        if (finger.GetDistance(referencePoint) < 200.0)
        {
            foreach (GameObject obj in onTapDisplays)
            {
                obj.SetActive(!obj.activeSelf);
            }
        }


        // Does the prefab exist?
        if (Prefab != null)
        {
            // Make sure the finger isn't over any GUI elements
            if (finger.IsOverGui == false)
            {
                // Clone the prefab, and place it where the finger was tapped
                var position = finger.GetWorldPosition(50.0f);
                var rotation = Quaternion.identity;
                var clone    = (GameObject)Instantiate(Prefab, position, rotation);

                // Make sure the prefab gets destroyed after some time
                Destroy(clone, 2.0f);
            }
        }
    }
Example #3
0
    public void OnFingerTap(Lean.LeanFinger finger)
    {
        // Does the prefab exist?
        if (Prefab != null)
        {
            // Make sure the finger isn't over any GUI elements
            if (finger.IsOverGui == false)
            {
                Debug.Log("Letter A");
                // Clone the prefab, and place it where the finger was tapped
                var position = finger.GetWorldPosition(50.0f);
                var rotation = Quaternion.identity;
                var clone    = (GameObject)Instantiate(Prefab, position, rotation);

                // Make sure the prefab gets destroyed after some time
                Destroy(clone, 2.0f);
            }
            else
            {
                Debug.Log("Letter B");
            }
        }
        else
        {
            Debug.Log("Letter C");
        }
    }
Example #4
0
    //tap is called after fingerup and everything has been reset
    //this causes it to be falsely recognized after a drag when it should
    //be its own gesture
    public void OnFingerTap(Lean.LeanFinger finger)
    {
        if (!finger.IsOverGui && okToTap && !autoBuild)
        {
            var point = finger.GetWorldPosition(50.0f);
            //var hit = Physics2D.OverlapPointA(point);
            var hits = Physics2D.OverlapPointAll(point);

            bool noHits = true;
            foreach (Collider2D coll in hits)
            {
                //don't react to any slow circle triggers
                if (!coll.isTrigger)
                {
                    print("hit: " + coll);
                    if (coll.gameObject == selected)
                    {
                        var shipPiece = coll.gameObject.GetComponent <ShipPiece>();
                        if (shipPiece != null)
                        {
                            if (shipPiece.CheckForACircleJoint())
                            {
                                shipPiece.DestroyCircleJoints();
                                jointsExist    = false;
                                selected.layer = LayerMask.NameToLayer("Default");
                                selected.transform.GetChild(0).gameObject.layer = LayerMask.NameToLayer("Default");
                                shipPiece.ResetOverlapNum();
                                shipPiece.SetJustCreated(true);
                                SetAlpha(0.5f);
                                slowMode = true;
                            }
                            else
                            {
                                slowMode = false;
                                Destroy(selected);
                            }
                        }
                    }
                    else
                    {
                        DeSelect();
                        SetSelected(coll.gameObject);
                    }
                    noHits = false;
                    break;
                }
            }
            if (noHits)
            {
                DeSelect();
                print("no hit");
            }
        }
    }
Example #5
0
    public void PlayerShoot(Lean.LeanFinger f)
    {
        // SE USA PARA DISPARA EN CUALQUIER LUGAR con el finger o mouse tap
        //Transform ti = crossHairA.transform;
        Vector3 v = f.GetWorldPosition(arms.distanceHit, mainCamera);

        StartShootLaser(v);


        //Vector2 viewPortPosB;
        //Vector2 screenPosB;
        //Ray winRay = mainCamera.ScreenPointToRay(Input.mousePosition);
        //RaycastHit winHit;

        //if (Physics.Raycast(winRay, out winHit, arms.distanceHit, arms.layerMaskHit.value))
        //{
        //    //SOLO CUANDO HIT UN METEORO
        //    //Debug.Log("NO x: " + hit.point.x.ToString() + " y: " + hit.point.y.ToString());

        //    if (winHit.collider.gameObject.CompareTag("Meteor") || winHit.collider.gameObject.CompareTag("MeteorPath"))
        //    {
        //        scrMeteorControll m = winHit.collider.gameObject.GetComponent<scrMeteorControll>();
        //        if (!m.isMeteorSelected)
        //        {
        //            //gameControll.poolTargetEnemy[lastMeteorID].GetComponent<scrMeteorControll>().isMeteorSelected = true;
        //            //listMeteorID.Add(newID);
        //            //lastMeteorID = newID;
        //            m.isMeteorSelected = true;
        //            if (!arms.isLaserEnable)
        //                gameControll.SetTargetEnemy(winHit);

        //            Debug.Log("Meteor_" + m.meteorID.ToString());



        //            viewPortPosB = mainCamera.ScreenToViewportPoint(new Vector3(inputPos.x, inputPos.y, 0f));
        //            screenPosB = new Vector2(
        //                ((viewPortPosB.x * recCrossHair.sizeDelta.x) - (recCrossHair.sizeDelta.x * 0.5f)),
        //                ((viewPortPosB.y * recCrossHair.sizeDelta.y) - (recCrossHair.sizeDelta.y * 0.5f)));
        //            //restringo el area par aseleccionar
        //            recCrossHairB.anchoredPosition = screenPosB;
        //            StopCoroutine("StartRedCrossHair");
        //            StartCoroutine("StartRedCrossHair");
        //        }

        //        StartShootLaser(winHit.collider.gameObject.transform.position);
        //        Debug.Log("JHIT");
        //    }
        //}
    }