Example #1
0
 public static void DFChargingEnd(ChargedInfo cInfo)
 {
     if (IT_Gesture.onDFChargeEndE != null)
     {
         IT_Gesture.onDFChargeEndE(cInfo);
     }
 }
Example #2
0
    //called when a charge event is ended
    void OnChargeEnd(ChargedInfo cInfo)
    {
        Ray        ray = Camera.main.ScreenPointToRay(cInfo.pos);
        RaycastHit hit;

        //use raycast at the cursor position to detect the object
        if (Physics.Raycast(ray, out hit, Mathf.Infinity))
        {
            if (hit.collider.transform == chargeObj)
            {
                //place the indicator at the object position and assign a random color to it
                Indicator.transform.position = chargeObj.position;
                Indicator.startColor         = GetRandomColor();

                //adjust the indicator speed with respect to the charged percent
                Indicator.startSpeed = 1 + 3 * cInfo.percent;
                //emit a set number of particles with respect to the charged percent
                Indicator.Emit((int)(10 + cInfo.percent * 75f));

                //reset the particle speed, since it's shared by other event
                StartCoroutine(ResumeSpeed());
            }
        }
        chargeTextMesh.text = "HoldToCharge";
    }
 public static void DFChargingEnd(ChargedInfo cInfo)
 {
     if (onDFChargeEndE != null)
     {
         onDFChargeEndE(cInfo);
     }
 }
Example #4
0
 public static void ChargeEnd(ChargedInfo cInfo)
 {
     //Debug.Log("charge end "+cInfo.percent);
     if (onChargeEndE != null)
     {
         onChargeEndE(cInfo);
     }
 }
Example #5
0
 public static void Charging(ChargedInfo cInfo)
 {
     //Debug.Log("charging "+chargePercent);
     if (onChargingE != null)
     {
         onChargingE(cInfo);
     }
 }
Example #6
0
 //triggered when mouse/single-finger charging event is on-going
 //this is just to simulate 2-fingers charge event using right-mouse-click
 void OnCharging(ChargedInfo cInfo)
 {
     if(cInfo.isMouse){
         if(cInfo.index==1){
             //if this is triggered by right-mouse-button, modified the fingerCount and call OnMFCharging with the same chargeInfo
             cInfo.fingerCount=2;
             OnMFCharging(cInfo);
         }
     }
 }
Example #7
0
 //triggered when a multiple finger charge event is on-going
 void OnMFCharging(ChargedInfo cInfo)
 {
     if (cInfo.fingerCount == 2)
     {
         //adjust the length of the indicator bar accordingly to the percent
         bar.pixelInset = new Rect(bar.pixelInset.x, bar.pixelInset.y, cInfo.percent * 150, bar.pixelInset.height);
         //adjust the color on the bar
         bar.color = new Color(cInfo.percent, 1 - cInfo.percent, 0);
     }
 }
Example #8
0
 //triggered when mouse/single-finger charging event is ended
 void OnChargeEnd(ChargedInfo cInfo)
 {
     if (cInfo.isMouse)
     {
         if (cInfo.index == 1)
         {
             //if this is triggered by right-mouse-button, modified the fingerCount and call OnMFChargeEnd with the same chargeInfo
             cInfo.fingerCount = 2;
             OnMFChargeEnd(cInfo);
         }
     }
 }
Example #9
0
 //called when a charging event is detected
 void OnCharging(ChargedInfo cInfo)
 {
     Ray ray = Camera.main.ScreenPointToRay(cInfo.pos);
     RaycastHit hit;
     //use raycast at the cursor position to detect the object
     if(Physics.Raycast(ray, out hit, Mathf.Infinity)){
         if(hit.collider.transform==chargeObj){
             //display the charged percentage on screen
             chargeTextMesh.text="Charging "+(cInfo.percent*100).ToString("f1")+"%";
         }
     }
 }
Example #10
0
 public static void ChargeStart(ChargedInfo cInfo)
 {
     if (cInfo.fingerCount > 1)
     {
         if (IT_Gesture.onMFChargeStartE != null)
         {
             IT_Gesture.onMFChargeStartE(cInfo);
         }
     }
     else if (IT_Gesture.onChargeStartE != null)
     {
         IT_Gesture.onChargeStartE(cInfo);
     }
 }
Example #11
0
    //called when a charging event is detected
    void OnCharging(ChargedInfo cInfo)
    {
        Ray        ray = Camera.main.ScreenPointToRay(cInfo.pos);
        RaycastHit hit;

        //use raycast at the cursor position to detect the object
        if (Physics.Raycast(ray, out hit, Mathf.Infinity))
        {
            if (hit.collider.transform == chargeObj)
            {
                //display the charged percentage on screen
                chargeTextMesh.text = "Charging " + (cInfo.percent * 100).ToString("f1") + "%";
            }
        }
    }
Example #12
0
 //*****************************************************************************//
 //charge
 public static void ChargeStart(ChargedInfo cInfo)
 {
     if (cInfo.fingerCount > 1)
     {
         if (onMFChargeStartE != null)
         {
             onMFChargeStartE(cInfo);
         }
     }
     else
     {
         if (onChargeStartE != null)
         {
             onChargeStartE(cInfo);
         }
     }
 }
Example #13
0
 public static void ChargeEnd(ChargedInfo cInfo)
 {
     if (cInfo.fingerCount > 1)
     {
         if (cInfo.fingerCount == 2)
         {
             DFChargingEnd(cInfo);
         }
         if (IT_Gesture.onMFChargeEndE != null)
         {
             IT_Gesture.onMFChargeEndE(cInfo);
         }
     }
     else if (IT_Gesture.onChargeEndE != null)
     {
         IT_Gesture.onChargeEndE(cInfo);
     }
 }
Example #14
0
    //triggered when a multiple finger charge event has ended
    void OnMFChargeEnd(ChargedInfo cInfo)
    {
        if (cInfo.fingerCount == 2)
        {
            //reset the bullet
            //adjust the position os it's at the tip of the barrel
            bullet.transform.position = turret.TransformPoint(new Vector3(0, 0, 1.0f));
            //match the bullet rotation to turret's, so that when force is applied, the bullet head in the right direction
            bullet.transform.rotation = turret.rotation;
            //cancel current force on bullet
            bullet.rigidbody.velocity = Vector3.zero;

            //shoot the bullet based on the charged percent
            bullet.rigidbody.AddForce(cInfo.percent * maxForce * bullet.transform.forward);

            //clear the charge indicator bar
            bar.pixelInset = new Rect(bar.pixelInset.x, bar.pixelInset.y, 0, bar.pixelInset.height);
        }
    }
Example #15
0
 public static void Charging(ChargedInfo cInfo)
 {
     if (cInfo.fingerCount > 1)
     {
         if (cInfo.fingerCount == 2)
         {
             DFCharging(cInfo);
         }
         if (onMFChargingE != null)
         {
             onMFChargingE(cInfo);
         }
     }
     else
     {
         if (onChargingE != null)
         {
             onChargingE(cInfo);
         }
     }
 }
Example #16
0
    //called when a charge event is ended
    void OnChargeEnd(ChargedInfo cInfo)
    {
        Ray ray = Camera.main.ScreenPointToRay(cInfo.pos);
        RaycastHit hit;
        //use raycast at the cursor position to detect the object
        if(Physics.Raycast(ray, out hit, Mathf.Infinity)){
            if(hit.collider.transform==chargeObj){
                //place the indicator at the object position and assign a random color to it
                Indicator.transform.position=chargeObj.position;
                Indicator.startColor=GetRandomColor();

                //adjust the indicator speed with respect to the charged percent
                Indicator.startSpeed=1+3*cInfo.percent;
                //emit a set number of particles with respect to the charged percent
                Indicator.Emit((int)(10+cInfo.percent*75f));

                //reset the particle speed, since it's shared by other event
                StartCoroutine(ResumeSpeed());
            }
        }
        chargeTextMesh.text="HoldToCharge";
    }
Example #17
0
 //*****************************************************************************//
 //charge
 public static void ChargeStart(ChargedInfo cInfo)
 {
     if(cInfo.fingerCount>1){
         if(onMFChargeStartE!=null) onMFChargeStartE(cInfo);
     }
     else{
         if(onChargeStartE!=null) onChargeStartE(cInfo);
     }
 }
Example #18
0
    IEnumerator MouseRoutine(int index)
    {
        mouseIndex.Add(index);

        //init tap variables
        float   startTime = Time.time;
        Vector2 startPos  = Input.mousePosition;
        Vector2 lastPos   = startPos;
        bool    longTap   = false;

        //init charge variables
        _ChargeState chargeState     = _ChargeState.Clear;
        int          chargeDir       = 1;
        float        chargeConst     = 0;
        float        startTimeCharge = Time.time;
        Vector2      startPosCharge  = Input.mousePosition;

        yield return(null);

        while (mouseIndex.Contains(index))
        {
            Vector2 curPos = Input.mousePosition;

            if (Time.time - startTimeCharge > minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.time - startTimeCharge) / maxChargeTime), 0, 1);
                ChargedInfo cInfo        = new ChargedInfo(curPos, chargedValue, index, true);
                Gesture.ChargeStart(cInfo);

                startPosCharge = curPos;
            }
            else if (chargeState == _ChargeState.Charging)
            {
                if (Vector3.Distance(curPos, startPosCharge) > 5)
                {
                    chargeState = _ChargeState.Clear;
                    float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.time - startTimeCharge) / maxChargeTime), 0, 1);
                    ChargedInfo cInfo        = new ChargedInfo(lastPos, chargedValue, index, true);
                    Gesture.ChargeEnd(cInfo);
                }
                else
                {
                    float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.time - startTimeCharge) / maxChargeTime), 0, 1);
                    ChargedInfo cInfo        = new ChargedInfo(curPos, chargedValue, index, true);

                    if (chargeMode == _ChargeMode.PingPong)
                    {
                        if (chargedValue == 1 || chargedValue == 0)
                        {
                            chargeDir *= -1;
                            if (chargeDir == 1)
                            {
                                chargeConst = 0;
                            }
                            else if (chargeDir == -1)
                            {
                                chargeConst = 1;
                            }
                            startTimeCharge = Time.time;
                        }
                        Gesture.Charging(cInfo);
                    }
                    else
                    {
                        if (chargedValue < 1.0f)
                        {
                            Gesture.Charging(cInfo);
                        }
                        else
                        {
                            cInfo.percent = 1.0f;

                            if (chargeMode == _ChargeMode.Once)
                            {
                                chargeState = _ChargeState.Charged;
                                Gesture.ChargeEnd(cInfo);
                                startTimeCharge = Mathf.Infinity;
                                chargedValue    = 0;
                            }
                            else if (chargeMode == _ChargeMode.Clamp)
                            {
                                chargeState = _ChargeState.Charged;
                                Gesture.Charging(cInfo);
                            }
                            else if (chargeMode == _ChargeMode.Loop)
                            {
                                chargeState = _ChargeState.Clear;
                                Gesture.ChargeEnd(cInfo);
                                startTimeCharge = Time.time;
                            }
                        }
                    }
                }
            }

            if (!longTap && Time.time - startTime > longTapTime && Vector2.Distance(lastPos, startPos) < 5)
            {
                Gesture.LongTap(new Tap(curPos, 1, index, true));
                longTap = true;
            }

            lastPos = curPos;

            yield return(null);
        }

        //check for shortTap
        //if(Time.time-startTime<=shortTapTime && Vector2.Distance(lastPos, startPos)<5){ // TAKEN OUT BY ME!! Want full on taps for Windows - won't be using taps for shooting in iOS anyhow
        if (Time.time - startTime <= shortTapTime)
        {
            //Gesture.ShortTap(startPos);
            CheckMultiTapMouse(index, startPos);
        }

        //check for charge
        if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && chargeMode != _ChargeMode.Once))
        {
            float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.time - startTimeCharge) / maxChargeTime), 0, 1);
            ChargedInfo cInfo        = new ChargedInfo(lastPos, chargedValue, index, true);
            Gesture.ChargeEnd(cInfo);
        }
    }
Example #19
0
	IEnumerator MouseRoutine(int index){
		mouseIndex.Add(index);
		
		//init tap variables
		float startTime=Time.realtimeSinceStartup;
		Vector2 startPos=Input.mousePosition;
		Vector2 lastPos=startPos;
		bool longTap=false;
		
		//init charge variables
		_ChargeState chargeState=_ChargeState.Clear;
		int chargeDir=1;
		float chargeConst=0;
		float startTimeCharge=Time.realtimeSinceStartup;
		Vector2 startPosCharge=Input.mousePosition;
		
		yield return null;
		
		while(mouseIndex.Contains(index)){
			
			Vector2 curPos=Input.mousePosition;
			
			if(Time.realtimeSinceStartup-startTimeCharge>minChargeTime && chargeState==_ChargeState.Clear){
				chargeState=_ChargeState.Charging;
				float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/maxChargeTime), 0, 1);
				ChargedInfo cInfo=new ChargedInfo(curPos, chargedValue, index, true);
				IT_Gesture.ChargeStart(cInfo);
				
				startPosCharge=curPos;
			}
			else if(chargeState==_ChargeState.Charging){
				if(Vector3.Distance(curPos, startPosCharge)>tapPosDeviation){
					chargeState=_ChargeState.Clear;
					float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/maxChargeTime), 0, 1);
					ChargedInfo cInfo=new ChargedInfo(lastPos, chargedValue, index, true);
					IT_Gesture.ChargeEnd(cInfo);
				}
				else{
					float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/maxChargeTime), 0, 1);
					ChargedInfo cInfo=new ChargedInfo(curPos, chargedValue, index, true);
					
					if(chargeMode==_ChargeMode.PingPong){
						if(chargedValue==1 || chargedValue==0){
							chargeDir*=-1;
							if(chargeDir==1) chargeConst=0;
							else if(chargeDir==-1) chargeConst=1;
							startTimeCharge=Time.realtimeSinceStartup;
						}
						IT_Gesture.Charging(cInfo);
					}
					else{
						if(chargedValue<1.0f){
							IT_Gesture.Charging(cInfo);
						}
						else{
							cInfo.percent=1.0f;
							
							if(chargeMode==_ChargeMode.Once){
								chargeState=_ChargeState.Charged;
								IT_Gesture.ChargeEnd(cInfo);
								startTimeCharge=Mathf.Infinity;
								chargedValue=0;
							}
							else if(chargeMode==_ChargeMode.Clamp){
								chargeState=_ChargeState.Charged;
								IT_Gesture.Charging(cInfo);
							}
							else if(chargeMode==_ChargeMode.Loop){
								chargeState=_ChargeState.Clear;
								IT_Gesture.ChargeEnd(cInfo);
								startTimeCharge=Time.realtimeSinceStartup;
							}
						}
						
					}
				}
			}
			
			if(!longTap && Time.realtimeSinceStartup-startTime>longTapTime && Vector2.Distance(lastPos, startPos)<maxTapDisplacementAllowance){
				IT_Gesture.LongTap(new Tap(curPos, 1, index, true));
				longTap=true;
			}
			
			lastPos=curPos;
			
			yield return null;
		}
		
		//check for shortTap
		if(Time.realtimeSinceStartup-startTime<=shortTapTime && Vector2.Distance(lastPos, startPos)<maxTapDisplacementAllowance){
			//IT_Gesture.ShortTap(startPos);
			CheckMultiTapMouse(index, startPos, lastPos);
		}
		
		//check for charge
		if(chargeState==_ChargeState.Charging || (chargeState==_ChargeState.Charged && chargeMode!=_ChargeMode.Once)){
			float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/maxChargeTime), 0, 1);
			ChargedInfo cInfo=new ChargedInfo(lastPos, chargedValue, index, true);
			IT_Gesture.ChargeEnd(cInfo);
		}
		
	}
Example #20
0
 //triggered when a multiple finger charge event is on-going
 void OnMFCharging(ChargedInfo cInfo)
 {
     if(cInfo.fingerCount==2){
         //adjust the length of the indicator bar accordingly to the percent
         bar.pixelInset=new Rect(bar.pixelInset.x, bar.pixelInset.y, cInfo.percent*150, bar.pixelInset.height);
         //adjust the color on the bar
         bar.color=new Color(cInfo.percent, 1-cInfo.percent, 0);
     }
 }
Example #21
0
    //triggered when a multiple finger charge event has ended
    void OnMFChargeEnd(ChargedInfo cInfo)
    {
        if(cInfo.fingerCount==2){
            //reset the bullet
            //adjust the position os it's at the tip of the barrel
            bullet.transform.position=turret.TransformPoint(new Vector3(0, 0, 1.0f));
            //match the bullet rotation to turret's, so that when force is applied, the bullet head in the right direction
            bullet.transform.rotation=turret.rotation;
            //cancel current force on bullet
            bullet.GetComponent<Rigidbody>().velocity=Vector3.zero;

            //shoot the bullet based on the charged percent
            bullet.GetComponent<Rigidbody>().AddForce(cInfo.percent*maxForce*bullet.transform.forward);

            //clear the charge indicator bar
            bar.pixelInset=new Rect(bar.pixelInset.x, bar.pixelInset.y, 0, bar.pixelInset.height);
        }
    }
Example #22
0
    public IEnumerator Routine(TapDetector tapD)
    {
        tapDetector     = tapD;
        triggerTime     = Time.realtimeSinceStartup;
        startTimeCharge = Time.realtimeSinceStartup;
        yield return(new WaitForSeconds(0.075f));

        if (indexes.Count < 2)
        {
            routineEnded = true;
            yield break;
        }
        count  = indexes.Count;
        posAvg = Vector2.zero;
        for (int i = 0; i < positions.Count; i++)
        {
            posAvg += positions[i];
        }
        posAvg      /= (float)positions.Count;
        this.posList = new Vector2[positions.Count];
        positions.CopyTo(this.posList);
        indexList = new int[indexes.Count];
        indexes.CopyTo(indexList);
        bool  isOn     = true;
        float liftTime = -1f;

        while (isOn)
        {
            for (int j = 0; j < indexes.Count; j++)
            {
                Touch touch = IT_Gesture.GetTouch(indexes[j]);
                if (touch.phase == TouchPhase.Moved)
                {
                    isOn = false;
                }
                if (touch.position == Vector2.zero)
                {
                    if (indexes.Count == count)
                    {
                        liftTime = Time.realtimeSinceStartup;
                    }
                    indexes.RemoveAt(j);
                    j--;
                }
            }
            if (Time.realtimeSinceStartup - startTimeCharge > tapDetector.minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                ChargedInfo cInfo3 = new ChargedInfo(val: Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f), p: posAvg, posL: this.posList, inds: indexList);
                IT_Gesture.ChargeStart(cInfo3);
            }
            else if (chargeState == _ChargeState.Charging)
            {
                float       chargedValue = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f);
                ChargedInfo cInfo2       = new ChargedInfo(posAvg, this.posList, chargedValue, indexList);
                if (tapDetector.chargeMode == _ChargeMode.PingPong)
                {
                    if (chargedValue == 1f || chargedValue == 0f)
                    {
                        chargeDir *= -1;
                        if (chargeDir == 1)
                        {
                            chargeConst = 0;
                        }
                        else if (chargeDir == -1)
                        {
                            chargeConst = 1;
                        }
                        startTimeCharge = Time.realtimeSinceStartup;
                    }
                    IT_Gesture.Charging(cInfo2);
                }
                else if (chargedValue < 1f)
                {
                    IT_Gesture.Charging(cInfo2);
                }
                else
                {
                    cInfo2.percent = 1f;
                    if (tapDetector.chargeMode == _ChargeMode.Once)
                    {
                        chargeState = _ChargeState.Charged;
                        IT_Gesture.ChargeEnd(cInfo2);
                        startTimeCharge = float.PositiveInfinity;
                    }
                    else if (tapDetector.chargeMode == _ChargeMode.Clamp)
                    {
                        chargeState = _ChargeState.Charged;
                        IT_Gesture.Charging(cInfo2);
                    }
                    else if (tapDetector.chargeMode == _ChargeMode.Loop)
                    {
                        chargeState = _ChargeState.Clear;
                        IT_Gesture.ChargeEnd(cInfo2);
                        startTimeCharge = Time.realtimeSinceStartup;
                    }
                }
            }
            if (!longTap && Time.realtimeSinceStartup - triggerTime > tapDetector.longTapTime && indexes.Count == count)
            {
                Vector2[] posList2 = new Vector2[positions.Count];
                positions.CopyTo(posList2);
                Tap tap = new Tap(1, count, posList2, indexList);
                IT_Gesture.LongTap(tap);
                longTap = true;
            }
            if (indexes.Count < count && (Time.realtimeSinceStartup - liftTime > 0.075f || indexes.Count == 0))
            {
                if (indexes.Count == 0 && liftTime - triggerTime < tapDetector.shortTapTime + 0.1f)
                {
                    Vector2[] posList = new Vector2[positions.Count];
                    positions.CopyTo(posList);
                    tapDetector.CheckMultiTapMFTouch(count, posList, indexList);
                }
                break;
            }
            yield return(null);
        }
        if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && tapDetector.chargeMode != 0))
        {
            ChargedInfo cInfo = new ChargedInfo(val: Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0f, 1f), p: posAvg, posL: this.posList, inds: indexList);
            IT_Gesture.ChargeEnd(cInfo);
        }
        routineEnded = true;
    }
Example #23
0
 public static void ChargeEnd(ChargedInfo cInfo)
 {
     //Debug.Log("charge end "+cInfo.percent);
     if(onChargeEndE!=null) onChargeEndE(cInfo);
 }
Example #24
0
    private IEnumerator MouseRoutine(int index)
    {
        mouseIndex.Add(index);
        float        startTime       = Time.realtimeSinceStartup;
        Vector2      startPos        = Input.mousePosition;
        Vector2      lastPos         = startPos;
        bool         longTap         = false;
        _ChargeState chargeState     = _ChargeState.Clear;
        int          chargeDir       = 1;
        float        chargeConst     = 0f;
        float        startTimeCharge = Time.realtimeSinceStartup;
        Vector2      startPosCharge  = Input.mousePosition;

        yield return(null);

        while (mouseIndex.Contains(index))
        {
            Vector2 curPos = Input.mousePosition;
            if (Time.realtimeSinceStartup - startTimeCharge > minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                float       chargedValue3 = Mathf.Clamp(chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f);
                ChargedInfo cInfo3        = new ChargedInfo(curPos, chargedValue3, index, im: true);
                IT_Gesture.ChargeStart(cInfo3);
                startPosCharge = curPos;
            }
            else if (chargeState == _ChargeState.Charging)
            {
                if (Vector3.Distance(curPos, startPosCharge) > tapPosDeviation)
                {
                    chargeState = _ChargeState.Clear;
                    float       chargedValue2 = Mathf.Clamp(chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f);
                    ChargedInfo cInfo2        = new ChargedInfo(lastPos, chargedValue2, index, im: true);
                    IT_Gesture.ChargeEnd(cInfo2);
                }
                else
                {
                    float       chargedValue = Mathf.Clamp(chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f);
                    ChargedInfo cInfo        = new ChargedInfo(curPos, chargedValue, index, im: true);
                    if (chargeMode == _ChargeMode.PingPong)
                    {
                        if (chargedValue == 1f || chargedValue == 0f)
                        {
                            chargeDir *= -1;
                            switch (chargeDir)
                            {
                            case 1:
                                chargeConst = 0f;
                                break;

                            case -1:
                                chargeConst = 1f;
                                break;
                            }
                            startTimeCharge = Time.realtimeSinceStartup;
                        }
                        IT_Gesture.Charging(cInfo);
                    }
                    else if (chargedValue < 1f)
                    {
                        IT_Gesture.Charging(cInfo);
                    }
                    else
                    {
                        cInfo.percent = 1f;
                        if (chargeMode == _ChargeMode.Once)
                        {
                            chargeState = _ChargeState.Charged;
                            IT_Gesture.ChargeEnd(cInfo);
                            startTimeCharge = float.PositiveInfinity;
                        }
                        else if (chargeMode == _ChargeMode.Clamp)
                        {
                            chargeState = _ChargeState.Charged;
                            IT_Gesture.Charging(cInfo);
                        }
                        else if (chargeMode == _ChargeMode.Loop)
                        {
                            chargeState = _ChargeState.Clear;
                            IT_Gesture.ChargeEnd(cInfo);
                            startTimeCharge = Time.realtimeSinceStartup;
                        }
                    }
                }
            }
            if (!longTap && Time.realtimeSinceStartup - startTime > longTapTime && Vector2.Distance(lastPos, startPos) < (float)maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor())
            {
                IT_Gesture.LongTap(new Tap(curPos, 1, index, im: true));
                longTap = true;
            }
            lastPos = curPos;
            yield return(null);
        }
        if (Time.realtimeSinceStartup - startTime <= shortTapTime && Vector2.Distance(lastPos, startPos) < (float)maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor())
        {
            CheckMultiTapMouse(index, startPos, lastPos);
        }
        switch (chargeState)
        {
        default:
            yield break;

        case _ChargeState.Charged:
            if (chargeMode == _ChargeMode.Once)
            {
                yield break;
            }
            break;

        case _ChargeState.Charging:
            break;
        }
        float       chargedValue4 = Mathf.Clamp(chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f);
        ChargedInfo cInfo4        = new ChargedInfo(lastPos, chargedValue4, index, im: true);

        IT_Gesture.ChargeEnd(cInfo4);
    }
Example #25
0
    private IEnumerator FingerRoutine(int index)
    {
        fingerIndex.Add(index);
        Touch        touch2          = IT_Gesture.GetTouch(index);
        float        startTime       = Time.realtimeSinceStartup;
        Vector2      startPos        = touch2.position;
        Vector2      lastPos         = startPos;
        bool         longTap         = false;
        _ChargeState chargeState     = _ChargeState.Clear;
        int          chargeDir       = 1;
        int          chargeConst     = 0;
        float        startTimeCharge = Time.realtimeSinceStartup;
        Vector2      startPosCharge  = touch2.position;

        while (true)
        {
            touch2 = IT_Gesture.GetTouch(index);
            if (touch2.position == Vector2.zero)
            {
                break;
            }
            Vector2 curPos = touch2.position;
            if (Time.realtimeSinceStartup - startTimeCharge > minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                float       chargedValue3 = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f);
                ChargedInfo cInfo3        = new ChargedInfo(curPos, chargedValue3, index, im: false);
                IT_Gesture.ChargeStart(cInfo3);
                startPosCharge = curPos;
            }
            else if (chargeState == _ChargeState.Charging)
            {
                if (Vector3.Distance(curPos, startPosCharge) > tapPosDeviation)
                {
                    chargeState = _ChargeState.Clear;
                    float       chargedValue2 = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f);
                    ChargedInfo cInfo2        = new ChargedInfo(lastPos, chargedValue2, index, im: false);
                    IT_Gesture.ChargeEnd(cInfo2);
                }
                else
                {
                    float       chargedValue = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f);
                    ChargedInfo cInfo        = new ChargedInfo(curPos, chargedValue, index, im: false);
                    if (chargeMode == _ChargeMode.PingPong)
                    {
                        if (chargedValue == 1f || chargedValue == 0f)
                        {
                            chargeDir *= -1;
                            switch (chargeDir)
                            {
                            case 1:
                                chargeConst = 0;
                                break;

                            case -1:
                                chargeConst = 1;
                                break;
                            }
                            startTimeCharge = Time.realtimeSinceStartup;
                        }
                        IT_Gesture.Charging(cInfo);
                    }
                    else if (chargedValue < 1f)
                    {
                        IT_Gesture.Charging(cInfo);
                    }
                    else
                    {
                        cInfo.percent = 1f;
                        if (chargeMode == _ChargeMode.Once)
                        {
                            chargeState = _ChargeState.Charged;
                            IT_Gesture.ChargeEnd(cInfo);
                            startTimeCharge = float.PositiveInfinity;
                        }
                        else if (chargeMode == _ChargeMode.Clamp)
                        {
                            chargeState = _ChargeState.Charged;
                            IT_Gesture.Charging(cInfo);
                        }
                        else if (chargeMode == _ChargeMode.Loop)
                        {
                            chargeState = _ChargeState.Clear;
                            IT_Gesture.ChargeEnd(cInfo);
                            startTimeCharge = Time.realtimeSinceStartup;
                        }
                    }
                }
            }
            if (!longTap && Time.realtimeSinceStartup - startTime > longTapTime && Vector2.Distance(lastPos, startPos) < (float)maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor())
            {
                IT_Gesture.LongTap(new Tap(curPos, 1, index, im: false));
                longTap = true;
            }
            lastPos = curPos;
            yield return(null);
        }
        if (Time.realtimeSinceStartup - startTime <= shortTapTime && Vector2.Distance(lastPos, startPos) < (float)maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor())
        {
            CheckMultiTapTouch(index, startPos, lastPos);
        }
        if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && chargeMode != 0))
        {
            float       chargedValue4 = Mathf.Clamp((float)chargeConst + (float)chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0f, 1f);
            ChargedInfo cInfo4        = new ChargedInfo(lastPos, chargedValue4, index, im: false);
            IT_Gesture.ChargeEnd(cInfo4);
        }
        fingerIndex.Remove(index);
    }
Example #26
0
 public static void Charging(ChargedInfo cInfo)
 {
     if(cInfo.fingerCount>1){
         if(cInfo.fingerCount==2) DFCharging(cInfo);
         if(onMFChargingE!=null) onMFChargingE(cInfo);
     }
     else{
         if(onChargingE!=null) onChargingE(cInfo);
     }
 }
Example #27
0
 public static void DFChargingEnd(ChargedInfo cInfo)
 {
     if(onDFChargeEndE!=null) onDFChargeEndE(cInfo);
 }
Example #28
0
    IEnumerator FingerRoutine(int index)
    {
        fingerIndex.Add(index);

        //init tap variables
        Touch   touch     = IT_Gesture.GetTouch(index);
        float   startTime = Time.realtimeSinceStartup;
        Vector2 startPos  = touch.position;
        Vector2 lastPos   = startPos;
        bool    longTap   = false;

        //init charge variables
        _ChargeState chargeState     = _ChargeState.Clear;
        int          chargeDir       = 1;
        int          chargeConst     = 0;
        float        startTimeCharge = Time.realtimeSinceStartup;
        Vector2      startPosCharge  = touch.position;

        //yield return null;

        bool inGroup = false;

        while (true)
        {
            touch = IT_Gesture.GetTouch(index);
            if (touch.position == Vector2.zero)
            {
                break;
            }

            Vector2 curPos = touch.position;

            if (Time.realtimeSinceStartup - startTimeCharge > minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1);
                ChargedInfo cInfo        = new ChargedInfo(curPos, chargedValue, index, false);
                IT_Gesture.ChargeStart(cInfo);

                startPosCharge = curPos;
            }
            else if (chargeState == _ChargeState.Charging)
            {
                if (Vector3.Distance(curPos, startPosCharge) > tapPosDeviation)
                {
                    chargeState = _ChargeState.Clear;
                    float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1);
                    ChargedInfo cInfo        = new ChargedInfo(lastPos, chargedValue, index, false);
                    IT_Gesture.ChargeEnd(cInfo);
                }
                else
                {
                    float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1);
                    ChargedInfo cInfo        = new ChargedInfo(curPos, chargedValue, index, false);

                    if (chargeMode == _ChargeMode.PingPong)
                    {
                        if (chargedValue == 1 || chargedValue == 0)
                        {
                            chargeDir *= -1;
                            if (chargeDir == 1)
                            {
                                chargeConst = 0;
                            }
                            else if (chargeDir == -1)
                            {
                                chargeConst = 1;
                            }
                            startTimeCharge = Time.realtimeSinceStartup;
                        }

                        IT_Gesture.Charging(cInfo);
                    }
                    else
                    {
                        if (chargedValue < 1.0f)
                        {
                            IT_Gesture.Charging(cInfo);
                        }
                        else
                        {
                            cInfo.percent = 1.0f;

                            if (chargeMode == _ChargeMode.Once)
                            {
                                chargeState = _ChargeState.Charged;
                                IT_Gesture.ChargeEnd(cInfo);
                                startTimeCharge = Mathf.Infinity;
                                chargedValue    = 0;
                            }
                            else if (chargeMode == _ChargeMode.Clamp)
                            {
                                chargeState = _ChargeState.Charged;
                                IT_Gesture.Charging(cInfo);
                            }
                            else if (chargeMode == _ChargeMode.Loop)
                            {
                                chargeState = _ChargeState.Clear;
                                IT_Gesture.ChargeEnd(cInfo);
                                startTimeCharge = Time.realtimeSinceStartup;
                            }
                        }
                    }
                }
            }

            if (!longTap && Time.realtimeSinceStartup - startTime > longTapTime && Vector2.Distance(lastPos, startPos) < maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor())
            {
                //new Tap(multiTapMFTouch[index].count, fCount, posL)
                //IT_Gesture.LongTap(new Tap(multiTapMFTouch[index].count, fCount, posL));
                IT_Gesture.LongTap(new Tap(curPos, 1, index, false));
                //IT_Gesture.LongTap(startPos);
                longTap = true;
            }

            lastPos = curPos;

            if (!inGroup)
            {
                inGroup = IndexInFingerGroup(index);
            }

            yield return(null);
        }

        //check for shortTap
        if (!inGroup)
        {
            if (Time.realtimeSinceStartup - startTime <= shortTapTime && Vector2.Distance(lastPos, startPos) < maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor())
            {
                CheckMultiTapTouch(index, startPos, lastPos);
            }
        }

        //check for charge
        if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && chargeMode != _ChargeMode.Once))
        {
            float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1);
            ChargedInfo cInfo        = new ChargedInfo(lastPos, chargedValue, index, false);
            IT_Gesture.ChargeEnd(cInfo);
        }

        fingerIndex.Remove(index);
    }
Example #29
0
    IEnumerator MouseRoutine(int index)
    {
        mouseIndex.Add(index);

        //init tap variables
        float   startTime = Time.realtimeSinceStartup;
        Vector2 startPos  = Input.mousePosition;
        Vector2 lastPos   = startPos;
        bool    longTap   = false;

        //init charge variables
        _ChargeState chargeState     = _ChargeState.Clear;
        int          chargeDir       = 1;
        float        chargeConst     = 0;
        float        startTimeCharge = Time.realtimeSinceStartup;
        Vector2      startPosCharge  = Input.mousePosition;

        yield return(null);

        while (mouseIndex.Contains(index))
        {
            Vector2 curPos = Input.mousePosition;

            if (Time.realtimeSinceStartup - startTimeCharge > minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1);
                ChargedInfo cInfo        = new ChargedInfo(curPos, chargedValue, index, true);
                IT_Gesture.ChargeStart(cInfo);

                startPosCharge = curPos;
            }
            else if (chargeState == _ChargeState.Charging)
            {
                if (Vector3.Distance(curPos, startPosCharge) > tapPosDeviation)
                {
                    chargeState = _ChargeState.Clear;
                    float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1);
                    ChargedInfo cInfo        = new ChargedInfo(lastPos, chargedValue, index, true);
                    IT_Gesture.ChargeEnd(cInfo);
                }
                else
                {
                    float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1);
                    ChargedInfo cInfo        = new ChargedInfo(curPos, chargedValue, index, true);

                    if (chargeMode == _ChargeMode.PingPong)
                    {
                        if (chargedValue == 1 || chargedValue == 0)
                        {
                            chargeDir *= -1;
                            if (chargeDir == 1)
                            {
                                chargeConst = 0;
                            }
                            else if (chargeDir == -1)
                            {
                                chargeConst = 1;
                            }
                            startTimeCharge = Time.realtimeSinceStartup;
                        }
                        IT_Gesture.Charging(cInfo);
                    }
                    else
                    {
                        if (chargedValue < 1.0f)
                        {
                            IT_Gesture.Charging(cInfo);
                        }
                        else
                        {
                            cInfo.percent = 1.0f;

                            if (chargeMode == _ChargeMode.Once)
                            {
                                chargeState = _ChargeState.Charged;
                                IT_Gesture.ChargeEnd(cInfo);
                                startTimeCharge = Mathf.Infinity;
                                chargedValue    = 0;
                            }
                            else if (chargeMode == _ChargeMode.Clamp)
                            {
                                chargeState = _ChargeState.Charged;
                                IT_Gesture.Charging(cInfo);
                            }
                            else if (chargeMode == _ChargeMode.Loop)
                            {
                                chargeState = _ChargeState.Clear;
                                IT_Gesture.ChargeEnd(cInfo);
                                startTimeCharge = Time.realtimeSinceStartup;
                            }
                        }
                    }
                }
            }

            if (!longTap && Time.realtimeSinceStartup - startTime > longTapTime && Vector2.Distance(lastPos, startPos) < maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor())
            {
                IT_Gesture.LongTap(new Tap(curPos, 1, index, true));
                longTap = true;
            }

            lastPos = curPos;

            yield return(null);
        }

        //check for shortTap
        if (Time.realtimeSinceStartup - startTime <= shortTapTime && Vector2.Distance(lastPos, startPos) < maxTapDisplacementAllowance * IT_Gesture.GetDPIFactor())
        {
            //IT_Gesture.ShortTap(startPos);
            CheckMultiTapMouse(index, startPos, lastPos);
        }

        //check for charge
        if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && chargeMode != _ChargeMode.Once))
        {
            float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / maxChargeTime), 0, 1);
            ChargedInfo cInfo        = new ChargedInfo(lastPos, chargedValue, index, true);
            IT_Gesture.ChargeEnd(cInfo);
        }
    }
Example #30
0
    public IEnumerator Routine(TapDetector tapD)
    {
        tapDetector = tapD;

        triggerTime     = Time.realtimeSinceStartup;
        startTimeCharge = Time.realtimeSinceStartup;

        yield return(new WaitForSeconds(0.075f));

        if (indexes.Count < 2)
        {
            routineEnded = true;
            yield break;
        }
        else
        {
            count = indexes.Count;

            posAvg = Vector2.zero;
            //foreach(Vector2 p in positions) posAvg+=p;
            for (int i = 0; i < positions.Count; i++)
            {
                posAvg += positions[i];
            }
            posAvg /= positions.Count;

            posList = new Vector2[positions.Count];
            positions.CopyTo(posList);
            indexList = new int[indexes.Count];
            indexes.CopyTo(indexList);
        }

        bool isOn = true;

        float liftTime = -1;

        int rand = Random.Range(0, 99999);

        while (isOn)
        {
            for (int i = 0; i < indexes.Count; i++)
            {
                Touch touch = IT_Gesture.GetTouch(indexes[i]);
                if (touch.phase == TouchPhase.Moved)
                {
                    isOn = false;
                }

                if (touch.position == Vector2.zero)
                {
                    if (indexes.Count == count)
                    {
                        liftTime = Time.realtimeSinceStartup;
                    }
                    indexes.RemoveAt(i);
                    i--;
                }
            }

            if (Time.realtimeSinceStartup - startTimeCharge > tapDetector.minChargeTime && chargeState == _ChargeState.Clear)
            {
                chargeState = _ChargeState.Charging;
                float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0, 1);
                ChargedInfo cInfo        = new ChargedInfo(posAvg, posList, chargedValue, indexList);
                IT_Gesture.ChargeStart(cInfo);
            }
            else if (chargeState == _ChargeState.Charging)
            {
                float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0, 1);
                ChargedInfo cInfo        = new ChargedInfo(posAvg, posList, chargedValue, indexList);

                if (tapDetector.chargeMode == _ChargeMode.PingPong)
                {
                    if (chargedValue == 1 || chargedValue == 0)
                    {
                        chargeDir *= -1;
                        if (chargeDir == 1)
                        {
                            chargeConst = 0;
                        }
                        else if (chargeDir == -1)
                        {
                            chargeConst = 1;
                        }
                        startTimeCharge = Time.realtimeSinceStartup;
                    }

                    IT_Gesture.Charging(cInfo);
                }
                else
                {
                    if (chargedValue < 1.0f)
                    {
                        IT_Gesture.Charging(cInfo);
                    }
                    else
                    {
                        cInfo.percent = 1.0f;

                        if (tapDetector.chargeMode == _ChargeMode.Once)
                        {
                            chargeState = _ChargeState.Charged;
                            IT_Gesture.ChargeEnd(cInfo);
                            startTimeCharge = Mathf.Infinity;
                            chargedValue    = 0;
                        }
                        else if (tapDetector.chargeMode == _ChargeMode.Clamp)
                        {
                            chargeState = _ChargeState.Charged;
                            IT_Gesture.Charging(cInfo);
                        }
                        else if (tapDetector.chargeMode == _ChargeMode.Loop)
                        {
                            chargeState = _ChargeState.Clear;
                            IT_Gesture.ChargeEnd(cInfo);
                            startTimeCharge = Time.realtimeSinceStartup;
                        }
                    }
                }
            }

            if (!longTap && Time.realtimeSinceStartup - triggerTime > tapDetector.longTapTime)
            {
                if (indexes.Count == count)
                {
                    Vector2[] posList = new Vector2[positions.Count];
                    positions.CopyTo(posList);

                    Tap tap = new Tap(1, count, posList, indexList);
                    IT_Gesture.LongTap(tap);
                    longTap = true;
                }
            }

            if (indexes.Count < count)
            {
                if (Time.realtimeSinceStartup - liftTime > 0.075f || indexes.Count == 0)
                {
                    if (indexes.Count == 0)
                    {
                        if (liftTime - triggerTime < tapDetector.shortTapTime + 0.1f)
                        {
                            Vector2[] posList = new Vector2[positions.Count];
                            positions.CopyTo(posList);
                            //Tap tap=new Tap(1, count, posList);
                            //IT_Gesture.MFShortTap(tap);
                            tapDetector.CheckMultiTapMFTouch(count, posList, indexList);
                        }
                    }
                    isOn = false;
                    break;
                }
            }

            yield return(null);
        }

        if (chargeState == _ChargeState.Charging || (chargeState == _ChargeState.Charged && tapDetector.chargeMode != _ChargeMode.Once))
        {
            float       chargedValue = Mathf.Clamp(chargeConst + chargeDir * ((Time.realtimeSinceStartup - startTimeCharge) / tapDetector.maxChargeTime), 0, 1);
            ChargedInfo cInfo        = new ChargedInfo(posAvg, posList, chargedValue, indexList);
            IT_Gesture.ChargeEnd(cInfo);
        }

        routineEnded = true;
    }
Example #31
0
	IEnumerator FingerRoutine(int index){
		fingerIndex.Add(index);
		
		//init tap variables
		Touch touch=IT_Gesture.GetTouch(index);
		float startTime=Time.realtimeSinceStartup;
		Vector2 startPos=touch.position;
		Vector2 lastPos=startPos;
		bool longTap=false;
		
		//init charge variables
		_ChargeState chargeState=_ChargeState.Clear;
		int chargeDir=1;
		int chargeConst=0;
		float startTimeCharge=Time.realtimeSinceStartup;
		Vector2 startPosCharge=touch.position;
		
		//yield return null;

		while(true){
			touch=IT_Gesture.GetTouch(index);
			if(touch.position==Vector2.zero) break;
			
			Vector2 curPos=touch.position;
			
			if(Time.realtimeSinceStartup-startTimeCharge>minChargeTime && chargeState==_ChargeState.Clear){
				chargeState=_ChargeState.Charging;
				float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/maxChargeTime), 0, 1);
				ChargedInfo cInfo=new ChargedInfo(curPos, chargedValue, index, false);
				IT_Gesture.ChargeStart(cInfo);
				
				startPosCharge=curPos;
			}
			else if(chargeState==_ChargeState.Charging){
				if(Vector3.Distance(curPos, startPosCharge)>tapPosDeviation){
					chargeState=_ChargeState.Clear;
					float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/maxChargeTime), 0, 1);
					ChargedInfo cInfo=new ChargedInfo(lastPos, chargedValue, index, false);
					IT_Gesture.ChargeEnd(cInfo);
				}
				else{
					float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/maxChargeTime), 0, 1);
					ChargedInfo cInfo=new ChargedInfo(curPos, chargedValue, index, false);
					
					if(chargeMode==_ChargeMode.PingPong){
						if(chargedValue==1 || chargedValue==0){
							chargeDir*=-1;
							if(chargeDir==1) chargeConst=0;
							else if(chargeDir==-1) chargeConst=1;
							startTimeCharge=Time.realtimeSinceStartup;
						}
						
						IT_Gesture.Charging(cInfo);
					}
					else{
						if(chargedValue<1.0f){
							IT_Gesture.Charging(cInfo);
						}
						else{
							cInfo.percent=1.0f;
							
							if(chargeMode==_ChargeMode.Once){
								chargeState=_ChargeState.Charged;
								IT_Gesture.ChargeEnd(cInfo);
								startTimeCharge=Mathf.Infinity;
								chargedValue=0;
							}
							else if(chargeMode==_ChargeMode.Clamp){
								chargeState=_ChargeState.Charged;
								IT_Gesture.Charging(cInfo);
							}
							else if(chargeMode==_ChargeMode.Loop){
								chargeState=_ChargeState.Clear;
								IT_Gesture.ChargeEnd(cInfo);
								startTimeCharge=Time.realtimeSinceStartup;
							}
						}
						
					}
				}
			}
			
			if(!longTap && Time.realtimeSinceStartup-startTime>longTapTime && Vector2.Distance(lastPos, startPos)<maxTapDisplacementAllowance){
				//new Tap(multiTapMFTouch[index].count, fCount, posL)
				//IT_Gesture.LongTap(new Tap(multiTapMFTouch[index].count, fCount, posL));
				IT_Gesture.LongTap(new Tap(curPos, 1, index, false));
				//IT_Gesture.LongTap(startPos);
				longTap=true;
			}
			
			lastPos=curPos;
			
			yield return null;
		}
		
		//check for shortTap
		if(Time.realtimeSinceStartup-startTime<=shortTapTime && Vector2.Distance(lastPos, startPos)<maxTapDisplacementAllowance){
		//if(Time.realtimeSinceStartup-startTime<=shortTapTime && ){
			CheckMultiTapTouch(index, startPos, lastPos);
		}
		
		//check for charge
		if(chargeState==_ChargeState.Charging || (chargeState==_ChargeState.Charged && chargeMode!=_ChargeMode.Once)){
			float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/maxChargeTime), 0, 1);
			ChargedInfo cInfo=new ChargedInfo(lastPos, chargedValue, index, false);
			IT_Gesture.ChargeEnd(cInfo);
		}
		
		fingerIndex.Remove(index);
	}
Example #32
0
    // Update is called once per frame
    void Update()
    {
        InputEvent inputEvent = new InputEvent();

        if (Input.touchCount == 1)
        {
            Touch       touch = Input.touches[0];
            _InputState state;
            if (touch.phase == TouchPhase.Began)
            {
                state = _InputState.Down;
            }
            else if (touch.phase == TouchPhase.Ended)
            {
                state = _InputState.Up;
            }
            else
            {
                state = _InputState.On;
            }
            inputEvent = new InputEvent(touch.position, _InputType.Touch, state);
        }
        else if (Input.touchCount == 0)
        {
            if (Input.GetMouseButtonDown(0))
            {
                inputEvent = new InputEvent(Input.mousePosition, _InputType.Mouse1, _InputState.Down);
            }
            else if (Input.GetMouseButton(0))
            {
                inputEvent = new InputEvent(Input.mousePosition, _InputType.Mouse1, _InputState.On);
            }
            else if (Input.GetMouseButtonUp(0))
            {
                inputEvent = new InputEvent(Input.mousePosition, _InputType.Mouse1, _InputState.Up);
            }
            else if (Input.GetMouseButtonDown(1))
            {
                inputEvent = new InputEvent(Input.mousePosition, _InputType.Mouse2, _InputState.Down);
            }
            else if (Input.GetMouseButton(1))
            {
                inputEvent = new InputEvent(Input.mousePosition, _InputType.Mouse2, _InputState.On);
            }
            else if (Input.GetMouseButtonUp(1))
            {
                inputEvent = new InputEvent(Input.mousePosition, _InputType.Mouse2, _InputState.Up);
            }
        }

        if (inputEvent.inputType != _InputType.None)
        {
            Vector2 curPos = inputEvent.pos;

            if (inputEvent.inputState == _InputState.Down)
            {
                tapStartTime = Time.time;
                startPos     = curPos;
                longTap      = false;
                posShifted   = false;
            }
            else if (inputEvent.inputState == _InputState.On)
            {
                if (Vector2.Distance(curPos, startPos) > maxLTapSpacing)
                {
                    posShifted = true;
                }

                if (Time.time - tapStartTime > minChargeTime)
                {
                    if (chargeState == _ChargeState.Clear)
                    {
                        chargeState = _ChargeState.Charged;
                    }
                    chargedValue = Mathf.Min(1, (Time.time - tapStartTime) / maxChargeTime);
                    ChargedInfo cInfo = new ChargedInfo(curPos, chargedValue);
                    Gesture.Charging(cInfo);
                }

                if (!longTap && !posShifted && Time.time - tapStartTime > 1f)
                {
                    longTap = true;
                    Gesture.LongTap(startPos);
                }

                lastPos = curPos;
            }
            else if (inputEvent.inputState == _InputState.Up)
            {
                if (Time.time - tapStartTime < shortTapTime)
                {
                    if (Time.time - lastShortTapTime < doubleTapTime)
                    {
                        if (dTapState == _DTapState.Clear)
                        {
                            dTapState = _DTapState.Tap1;
                        }
                        else if (dTapState == _DTapState.Tap1)
                        {
                            if (Vector2.Distance(lastPos, lastShortTapPos) < maxDTapPosSpacing)
                            {
                                dTapState = _DTapState.Clear;

                                Gesture.DoubleTap((startPos + lastShortTapPos) / 2);
                            }
                        }
                    }
                    else
                    {
                        dTapState = _DTapState.Tap1;
                    }

                    lastShortTapTime = Time.time;
                    lastShortTapPos  = lastPos;
                    Gesture.ShortTap(startPos);
                }

                if (chargeState == _ChargeState.Charged)
                {
                    ChargedInfo cInfo = new ChargedInfo(lastPos, chargedValue);
                    Gesture.ChargeEnd(cInfo);

                    chargedValue = 0;
                    chargeState  = _ChargeState.Clear;
                }
            }
        }

        /*
         #if UNITY_IPHONE || UNITY_ANDROID
         *      if(Input.touchCount==1){
         *              Vector2 touchPos=Input.touches[0].position;
         *
         *              //touch down
         *              if(firstTouch){
         *                      firstTouch=false;
         *                      tapStartTime=Time.time;
         *                      startPos=touchPos;
         *                      longTap=false;
         *                      posShifted=false;
         *              }
         *              //on touch
         *              else{
         *                      if(Vector2.Distance(Input.mousePosition, startPos)>maxLTapSpacing) posShifted=true;
         *
         *                      if(Time.time-tapStartTime>minChargeTime){
         *                              if(chargeState==_ChargeState.Clear) chargeState=_ChargeState.Charged;
         *                              chargedValue=Mathf.Min(1, (Time.time-tapStartTime)/maxChargeTime);
         *                              ChargedInfo cInfo=new ChargedInfo(touchPos, chargedValue);
         *                              Gesture.Charging(cInfo);
         *                      }
         *
         *                      if(!longTap && !posShifted && Time.time-tapStartTime>1f){
         *                              longTap=true;
         *                              Gesture.LongTap(startPos);
         *                      }
         *              }
         *
         *              lastTouchPos=touchPos;
         *      }
         *      else if(Input.touchCount==0){
         *              //touch up
         *              if(!firstTouch){
         *                      firstTouch=true;
         *                      if(Time.time-tapStartTime<shortTapTime){
         *                              if(Time.time-lastShortTapTime<doubleTapTime){
         *                                      if(dTapState==_DTapState.Clear){
         *                                              dTapState=_DTapState.Tap1;
         *                                      }
         *                                      else if(dTapState==_DTapState.Tap1){
         *                                              if(Vector2.Distance(lastTouchPos, lastShortTapPos)<maxDTapPosSpacing){
         *
         *                                                      dTapState=_DTapState.Clear;
         *
         *                                                      Gesture.DoubleTap((startPos+lastShortTapPos)/2);
         *                                              }
         *                                      }
         *                              }
         *                              else{
         *                                      dTapState=_DTapState.Tap1;
         *                              }
         *
         *                              lastShortTapTime=Time.time;
         *                              lastShortTapPos=lastTouchPos;
         *                              Gesture.ShortTap(startPos);
         *                      }
         *              }
         *
         *              if(chargeState==_ChargeState.Charged){
         *                      ChargedInfo cInfo=new ChargedInfo(lastTouchPos, chargedValue);
         *                      Gesture.ChargeEnd(cInfo);
         *
         *                      chargedValue=0;
         *                      chargeState=_ChargeState.Clear;
         *              }
         *      }
         #endif
         *
         #if (!UNITY_IPHONE && !UNITY_ANDROID) //|| UNITY_EDITOR
         *      if(Input.GetMouseButtonDown(0)){
         *              tapStartTime=Time.time;
         *              startPos=Input.mousePosition;
         *              longTap=false;
         *              posShifted=false;
         *      }
         *
         *      if(Input.GetMouseButton(0)){
         *
         *              if(Vector2.Distance(Input.mousePosition, startPos)>5) posShifted=true;
         *
         *              if(Time.time-tapStartTime>minChargeTime){
         *                      if(chargeState==_ChargeState.Clear) chargeState=_ChargeState.Charged;
         *                      chargedValue=Mathf.Min(1, (Time.time-tapStartTime)/maxChargeTime);
         *                      ChargedInfo cInfo=new ChargedInfo(Input.mousePosition, chargedValue);
         *                      Gesture.Charging(cInfo);
         *              }
         *
         *              if(!longTap && !posShifted && Time.time-tapStartTime>1f){
         *                      longTap=true;
         *                      Gesture.LongTap(startPos);
         *              }
         *
         *              lastTouchPos=Input.mousePosition;
         *      }
         *
         *      if(Input.GetMouseButtonUp(0)){
         *              if(Time.time-tapStartTime<shortTapTime){
         *
         *                      if(Time.time-lastShortTapTime<doubleTapTime){
         *                              if(dTapState==_DTapState.Clear){
         *                                      dTapState=_DTapState.Tap1;
         *                              }
         *                              else if(dTapState==_DTapState.Tap1){
         *                                      if(Vector2.Distance(lastTouchPos, lastShortTapPos)<10){
         *
         *                                              dTapState=_DTapState.Clear;
         *
         *                                              Gesture.DoubleTap((startPos+lastShortTapPos)/2);
         *
         *                                      }
         *                              }
         *                      }
         *                      else{
         *                              dTapState=_DTapState.Tap1;
         *                      }
         *
         *                      lastShortTapTime=Time.time;
         *                      lastShortTapPos=Input.mousePosition;
         *                      Gesture.ShortTap(startPos);
         *
         *              }
         *
         *              if(chargeState==_ChargeState.Charged){
         *                      ChargedInfo cInfo=new ChargedInfo(Input.mousePosition, chargedValue);
         *                      Gesture.ChargeEnd(cInfo);
         *
         *                      chargedValue=0;
         *                      chargeState=_ChargeState.Clear;
         *              }
         *      }
         #endif
         */
    }
Example #33
0
	public IEnumerator Routine(TapDetector tapD){
		tapDetector=tapD;
		
		triggerTime=Time.realtimeSinceStartup;
		startTimeCharge=Time.realtimeSinceStartup;
		
		yield return new WaitForSeconds(0.075f);
		if(indexes.Count<2){
			routineEnded=true;
			yield break;
		}
		else{
			count=indexes.Count;

			posAvg=Vector2.zero;
			//foreach(Vector2 p in positions) posAvg+=p;
			for(int i=0; i<positions.Count; i++) posAvg+=positions[i];
			posAvg/=positions.Count;
			
			posList = new Vector2[positions.Count];
  			positions.CopyTo( posList );
  			indexList = new int[indexes.Count];
  			indexes.CopyTo( indexList );		
		}
		
		bool isOn=true;
		
		float liftTime=-1;
		
		while(isOn){
			for(int i=0; i<indexes.Count; i++){
				Touch touch=IT_Gesture.GetTouch(indexes[i]);
				if(touch.phase==TouchPhase.Moved) isOn=false;
				
				if(touch.position==Vector2.zero){
					if(indexes.Count==count){
						liftTime=Time.realtimeSinceStartup;
					}
					indexes.RemoveAt(i);
					i--;
				}
			}
			
			if(Time.realtimeSinceStartup-startTimeCharge>tapDetector.minChargeTime && chargeState==_ChargeState.Clear){
				chargeState=_ChargeState.Charging;
				float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/tapDetector.maxChargeTime), 0, 1);
				ChargedInfo cInfo=new ChargedInfo(posAvg, posList, chargedValue, indexList);
				IT_Gesture.ChargeStart(cInfo);
			}
			else if(chargeState==_ChargeState.Charging){

				float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/tapDetector.maxChargeTime), 0, 1);
				ChargedInfo cInfo=new ChargedInfo(posAvg, posList, chargedValue, indexList);
				
				if(tapDetector.chargeMode==_ChargeMode.PingPong){
					if(chargedValue==1 || chargedValue==0){
						chargeDir*=-1;
						if(chargeDir==1) chargeConst=0;
						else if(chargeDir==-1) chargeConst=1;
						startTimeCharge=Time.realtimeSinceStartup;
					}
					
					IT_Gesture.Charging(cInfo);
				}
				else{
					if(chargedValue<1.0f){
						IT_Gesture.Charging(cInfo);
					}
					else{
						cInfo.percent=1.0f;
						
						if(tapDetector.chargeMode==_ChargeMode.Once){
							chargeState=_ChargeState.Charged;
							IT_Gesture.ChargeEnd(cInfo);
							startTimeCharge=Mathf.Infinity;
							chargedValue=0;
						}
						else if(tapDetector.chargeMode==_ChargeMode.Clamp){
							chargeState=_ChargeState.Charged;
							IT_Gesture.Charging(cInfo);
						}
						else if(tapDetector.chargeMode==_ChargeMode.Loop){
							chargeState=_ChargeState.Clear;
							IT_Gesture.ChargeEnd(cInfo);
							startTimeCharge=Time.realtimeSinceStartup;
						}
					}
				}

			}
			
			if(!longTap && Time.realtimeSinceStartup-triggerTime>tapDetector.longTapTime){
				if(indexes.Count==count){
					    
					Vector2[] posList = new Vector2[positions.Count];
  					positions.CopyTo( posList );
					
					Tap tap=new Tap(1, count, posList , indexList);
					IT_Gesture.LongTap(tap);
					longTap=true;
				}
			}
			
			if(indexes.Count<count){
				if(Time.realtimeSinceStartup-liftTime>0.075f || indexes.Count==0){
					if(indexes.Count==0){
						if(liftTime-triggerTime<tapDetector.shortTapTime+0.1f){
							Vector2[] posList = new Vector2[positions.Count];
		  					positions.CopyTo( posList );
							//Tap tap=new Tap(1, count, posList);
							//IT_Gesture.MFShortTap(tap);
							tapDetector.CheckMultiTapMFTouch(count, posList, indexList);
						}
					}
					isOn=false;
					break;
				}
			}
			
			yield return null;
		}
		
		if(chargeState==_ChargeState.Charging || (chargeState==_ChargeState.Charged && tapDetector.chargeMode!=_ChargeMode.Once)){
			float chargedValue=Mathf.Clamp(chargeConst+chargeDir*((Time.realtimeSinceStartup-startTimeCharge)/tapDetector.maxChargeTime), 0, 1);
			ChargedInfo cInfo=new ChargedInfo(posAvg, posList, chargedValue, indexList);
			IT_Gesture.ChargeEnd(cInfo);
		}
		
		routineEnded=true;
	}
Example #34
0
	// Update is called once per frame
	void Update () {
		#if UNITY_IPHONE || UNITY_ANDROID
			if(Input.touchCount==1){
				Vector2 touchPos=Input.touches[0].position;
				
				//touch down
				if(firstTouch){
					firstTouch=false;
					tapStartTime=Time.time;
					startPos=touchPos;
					longTap=false;
					posShifted=false;
				}
				//on touch
				else{
					if(Vector2.Distance(Input.mousePosition, startPos)>maxLTapSpacing) posShifted=true;
					
					if(Time.time-tapStartTime>minChargeTime){
						if(chargeState==_ChargeState.Clear) chargeState=_ChargeState.Charged;
						chargedValue=Mathf.Min(1, (Time.time-tapStartTime)/maxChargeTime);
						ChargedInfo cInfo=new ChargedInfo(touchPos, chargedValue);
						Gesture.Charging(cInfo);
					}
					
					if(!longTap && !posShifted && Time.time-tapStartTime>1f){
						longTap=true;
						Gesture.LongTap(startPos);
					}
				}
				
				lastTouchPos=touchPos;
			}
			else if(Input.touchCount==0){
				//touch up
				if(!firstTouch){
					firstTouch=true;
					if(Time.time-tapStartTime<shortTapTime){
						if(Time.time-lastShortTapTime<doubleTapTime){
							if(dTapState==_DTapState.Clear){
								dTapState=_DTapState.Tap1;
							}
							else if(dTapState==_DTapState.Tap1){
								if(Vector2.Distance(lastTouchPos, lastShortTapPos)<maxDTapPosSpacing){
					
									dTapState=_DTapState.Clear;
									
									Gesture.DoubleTap((startPos+lastShortTapPos)/2);
								}
							}
						}
						else{
							dTapState=_DTapState.Tap1;
						}
						
						lastShortTapTime=Time.time;
						lastShortTapPos=lastTouchPos;
						Gesture.ShortTap(startPos);
					}
				}
				
				if(chargeState==_ChargeState.Charged){
					ChargedInfo cInfo=new ChargedInfo(lastTouchPos, chargedValue);
					Gesture.ChargeEnd(cInfo);
					
					chargedValue=0;
					chargeState=_ChargeState.Clear;
				}
			}
		#endif
			
		#if (!UNITY_IPHONE && !UNITY_ANDROID) //|| UNITY_EDITOR
			if(Input.GetMouseButtonDown(0)){
				tapStartTime=Time.time;
				startPos=Input.mousePosition;
				longTap=false;
				posShifted=false;
			}
			
			if(Input.GetMouseButton(0)){
				
				if(Vector2.Distance(Input.mousePosition, startPos)>5) posShifted=true;
				
				if(Time.time-tapStartTime>minChargeTime){
					if(chargeState==_ChargeState.Clear) chargeState=_ChargeState.Charged;
					chargedValue=Mathf.Min(1, (Time.time-tapStartTime)/maxChargeTime);
					ChargedInfo cInfo=new ChargedInfo(Input.mousePosition, chargedValue);
					Gesture.Charging(cInfo);
				}
				
				if(!longTap && !posShifted && Time.time-tapStartTime>1f){
					longTap=true;
					Gesture.LongTap(startPos);
				}
				
				lastTouchPos=Input.mousePosition;
			}
			
			if(Input.GetMouseButtonUp(0)){
				if(Time.time-tapStartTime<shortTapTime){
						
					if(Time.time-lastShortTapTime<doubleTapTime){
						if(dTapState==_DTapState.Clear){
							dTapState=_DTapState.Tap1;
						}
						else if(dTapState==_DTapState.Tap1){
							if(Vector2.Distance(lastTouchPos, lastShortTapPos)<10){
				
								dTapState=_DTapState.Clear;
								
								Gesture.DoubleTap((startPos+lastShortTapPos)/2);
								
							}
						}
					}
					else{
						dTapState=_DTapState.Tap1;
					}
					
					lastShortTapTime=Time.time;
					lastShortTapPos=Input.mousePosition;
					Gesture.ShortTap(startPos);
					
				}
				
				if(chargeState==_ChargeState.Charged){
					ChargedInfo cInfo=new ChargedInfo(Input.mousePosition, chargedValue);
					Gesture.ChargeEnd(cInfo);
					
					chargedValue=0;
					chargeState=_ChargeState.Clear;
				}
			}
		#endif
	}
    void Update()
    {
        if (Input.touchCount == 2)
        {
            Touch touch1 = Input.touches[0];
            Touch touch2 = Input.touches[1];

            Vector2 pos1 = touch1.position;
            Vector2 pos2 = touch2.position;

            Vector2 delta1 = pos1 - lastTouchPos1;
            Vector2 delta2 = pos2 - lastTouchPos2;


            if (firstTouch)
            {
                firstTouch = false;

                //for rotate
                initPos1     = pos1;
                initPos2     = pos2;
                initGradient = (pos1 - pos2).normalized;

                float curX      = pos1.x - pos2.x;
                float curY      = pos1.y - pos2.y;
                float prevAngle = Gesture.VectorToAngle(new Vector2(curX, curY));

                //for tap
                tapStartTime = Time.time;
                startPos     = (pos1 + pos2) / 2;
                longTap      = false;
                posShifted   = false;
            }
            else
            {
                if (Vector2.Distance(Input.mousePosition, startPos) > 5)
                {
                    posShifted = true;
                }

                if (Time.time - tapStartTime > minChargeTime)
                {
                    charged = true;
                    float       chargeValue = Mathf.Min(1, (Time.time - tapStartTime) / maxChargeTime);
                    ChargedInfo cInfo       = new ChargedInfo((pos1 + pos2) / 2, chargeValue);
                    Gesture.DFCharging(cInfo);
                }

                if (!longTap && !posShifted && Time.time - tapStartTime > 1f)
                {
                    longTap = true;
                    Gesture.DFLongTap((pos1 + pos2) / 2);
                }
            }


            if (touch1.phase == TouchPhase.Moved && touch2.phase == TouchPhase.Moved)
            {
                float dot = Vector2.Dot(delta1, delta2);
                if (dot < 0)
                {
                    Vector2 grad1 = (pos1 - initPos1).normalized;
                    Vector2 grad2 = (pos2 - initPos2).normalized;

                    float dot1 = Vector2.Dot(grad1, initGradient);
                    float dot2 = Vector2.Dot(grad2, initGradient);

                    //rotate
                    if (dot1 < 0.7f && dot2 < 0.7f)
                    {
                        float curX     = pos1.x - pos2.x;
                        float curY     = pos1.y - pos2.y;
                        float curAngle = Gesture.VectorToAngle(new Vector2(curX, curY));
                        float val      = Mathf.DeltaAngle(curAngle, prevAngle);

                        if (Mathf.Abs(val) > 0)
                        {
                            AddRotVal(val);
                        }
                        float valueAvg = GetAverageValue();

                        Gesture.Rotate(valueAvg);

                        prevAngle = curAngle;
                    }
                    //pinch
                    else
                    {
                        Vector2 curDist  = pos1 - pos2;
                        Vector2 prevDist = (pos1 - delta1) - (pos2 - delta2);
                        float   pinch    = prevDist.magnitude - curDist.magnitude;

                        Gesture.Pinch(pinch);
                    }
                }

                //drag
                if (dot > 2)
                {
                    dragging = true;

                    Vector2  posAvg   = (pos1 + pos2) / 2;
                    Vector2  dir      = (delta1 + delta2) / 2;
                    DragInfo dragInfo = new DragInfo(-1, posAvg, dir);
                    Gesture.DualFingerDragging(dragInfo);
                }
            }

            lastTouchPos1 = pos1;
            lastTouchPos2 = pos2;
        }
        else if (Input.touchCount == 0)
        {
            //~ if(!firstTouch){
            //~ firstTouch=true;
            //~ }

            if (!firstTouch)
            {
                firstTouch = true;

                //for tap
                if (Time.time - tapStartTime < shortTapTime)
                {
                    if (Time.time - lastShortTapTime < doubleTapTime)
                    {
                        if (dTapState == _DTapState.Clear)
                        {
                            dTapState = _DTapState.Tap1;
                        }
                        else if (dTapState == _DTapState.Tap1)
                        {
                            if (Vector2.Distance(lastTouchPos1, lastShortTapPos) < maxDTapPosSpacing)
                            {
                                dTapState = _DTapState.Clear;

                                Gesture.DFDoubleTap((startPos + lastShortTapPos) / 2);
                            }
                        }
                    }
                    else
                    {
                        dTapState = _DTapState.Tap1;
                    }

                    lastShortTapTime = Time.time;
                    lastShortTapPos  = (lastTouchPos1 + lastTouchPos2) / 2;
                    Gesture.DFShortTap(startPos);
                }

                if (dragging)
                {
                    dragging = false;
                    Gesture.DualFingerDraggingEnd((lastTouchPos1 + lastTouchPos2) / 2);
                }

                if (charged)
                {
                    charged = false;
                    float       chargeValue = Mathf.Min(1, (Time.time - tapStartTime) / maxChargeTime);
                    ChargedInfo cInfo       = new ChargedInfo((lastTouchPos1 + lastTouchPos2) / 2, chargeValue);
                    Gesture.DFChargeEnd(cInfo);
                }
            }
        }
    }
Example #36
0
 public static void Charging(ChargedInfo cInfo)
 {
     //Debug.Log("charging "+chargePercent);
     if(onChargingE!=null) onChargingE(cInfo);
 }