Ejemplo n.º 1
0
	public static TouchContent CreateFromTouch(MyTouch[] touch)
	{
		if (touch.Length == 2)
		{
			return new TouchContent (touch);
		}
		return null;
	}
Ejemplo n.º 2
0
	private List<MyTouch> BuildTouch(MyTouch[] touch)
	{
		var list = new List<MyTouch> ( touch );
		list.Sort ((MyTouch a, MyTouch b) =>
		{
			return a.fingerId < b.fingerId ? -1 : 1;
		});
		return list;
	}
Ejemplo n.º 3
0
	public bool Test(MyTouch[] touch)
	{
		if (touch.Length != 2)
		{
			return false;
		}
		var newTouchGroup = BuildTouch (touch);
		if (touchs [0].fingerId != newTouchGroup [0].fingerId
			|| touchs [1].fingerId != newTouchGroup [1].fingerId)
		{
			return false;
		}

		touchs = newTouchGroup;
		return true;
	}
Ejemplo n.º 4
0
    public void update()
    {
        myTouches_ = new MyTouch[Input.touchCount];
        if( Input.touchCount != 0){
            tmpSwypeCenter_ = Vector2.zero;
            for( int ii = 0; ii < Input.touchCount; ++ii ){
                Touch tw = Input.touches[ii];
                myTouches_[ii] = new MyTouch(tw.fingerId,tw.position,tw.deltaPosition,tw.deltaTime,tw.tapCount,tw.phase);
                tmpSwypeCenter_ += tw.position;
            }
            tmpSwypeCenter_ /= Input.touchCount;
        }else{
            tmpSwypeCenter_ = Input.mousePosition;
            wheelMove_ = (Input.GetAxis("Mouse ScrollWheel")!=0.0f) ? Input.GetAxis("Mouse ScrollWheel") : wheelMove_*0.5f;
            if((Mathf.Abs(wheelMove_)>0.001f)||(Input.GetMouseButton(2))){
                if(Input.GetMouseButton(2)){ // swype,zoom,pinch
                    touchCkSize_ = Mathf.Clamp(touchCkSize_ + wheelMove_*0.5f,0.1f,0.9f);
                }else{
                    touchCkAng_ += wheelMove_*0.5f;
                }
                myTouches_ = new MyTouch[2];
                Vector2 tmpPos = new Vector2(-touchCkSize_*0.5f,0.0f);
                tmpPos.y = Mathf.Sin(touchCkAng_)*tmpPos.x;
                tmpPos.x = Mathf.Cos(touchCkAng_)*tmpPos.x;
                myTouches_[0] = new MyTouch(0,new Vector2(moveMax*(0.5f + tmpPos.x),moveMax*(0.5f + tmpPos.y)));
                myTouches_[1] = new MyTouch(1,new Vector2(moveMax*(0.5f - tmpPos.x),moveMax*(0.5f - tmpPos.y)));
            }else{
                touchCkSize_ = 0.5f;
                touchCkAng_ = 0.0f;
            }

        }
        if( myTouches_.Length >= 2){
            Vector2 vec = myTouches_[1].position - myTouches_[0].position;
            touchOldAng_ = touchAng_;
            touchAng_ = Mathf.Atan2(vec.y,vec.x);
            if(touchSttAng_ == float.MaxValue){
                touchSttAng_ = touchAng_;
                touchOldAng_ = touchAng_;
            }
            touchOldSize_ = touchSize_;
            touchSize_ = vec.magnitude / moveMax;
            if(touchSttSize_ == float.MaxValue){
                touchSttSize_ = touchSize_;
                touchOldSize_ = touchSize_;
            }
            swypeOldPos_ = swypePos_;
            swypePos_ = tmpSwypeCenter_;
            if(swypeSttPos_.x == float.MaxValue){
                swypeSttPos_ = swypePos_;
                swypeOldPos_ = swypePos_;
            }
            // for debug
            if(myTouches_.Length >= 2){
                Vector3 v0 = Camera.main.ScreenToWorldPoint(new Vector3(myTouches_[0].position.x,myTouches_[0].position.y,-Camera.main.transform.position.z));
                Vector3 v1 = Camera.main.ScreenToWorldPoint(new Vector3(myTouches_[1].position.x,myTouches_[1].position.y,-Camera.main.transform.position.z));
                Debug.DrawLine(v0,v1,((deltaSize<0.0f) ? Color.red : ((deltaSize>0.0f) ? Color.blue : Color.white)));
            }
        }else{
            touchSttSize_ = float.MaxValue;
            touchOldSize_ = float.MaxValue;
            touchSttAng_ = float.MaxValue;
            touchOldAng_ = float.MaxValue;
            swypeSttPos_ = new Vector2(float.MaxValue,float.MaxValue);
            swypeOldPos_ = new Vector2(float.MaxValue,float.MaxValue);
        //			tmpSwypeCenter_ = new Vector2(Screen.width*0.5f,Screen.height*0.5f);
        }

        isDoubleTap_ = doubleTapCheck();
    }
Ejemplo n.º 5
0
	private void VirtualTouch()
	{
		if (Input.GetMouseButtonDown (1))
		{
			Debug.Log ("MouseButtonDown");
			m_beginPosition = Input.mousePosition;
			m_touched = true;
		}
		if (Input.GetMouseButtonUp (1))
		{
			m_touched = false;
			currentTouchs = new MyTouch[0];
		}
		if (m_touched)
		{
			currentTouchs = new MyTouch[2];
			Vector3 dir = Input.mousePosition - m_beginPosition;

			currentTouchs [0] = new MyTouch ();
			currentTouchs [0].fingerId = 0;
			currentTouchs [0].position = m_beginPosition + dir;
			currentTouchs [1] = new MyTouch ();
			currentTouchs [1].fingerId = 1;
			currentTouchs [1].position = m_beginPosition - dir;
		}
	}
Ejemplo n.º 6
0
	public TouchContent(MyTouch[] touch)
	{
		touchs.AddRange( touch );
	}
Ejemplo n.º 7
0
	void Update()
	{
		currentTouchs = new MyTouch[Input.touches.Length];
		for (int i = 0; i < currentTouchs.Length; ++i)
		{
			currentTouchs [i] = new MyTouch( Input.touches [i] );
		}

		VirtualTouch ();


		if (m_content == null)
		{
			m_content = TouchContent.CreateFromTouch (currentTouchs);
			if (m_content != null)
			{
				Open ();
				Sync ();
				isMultiTouch = true;
			}
		}
		else
		{
			if (m_content.Test (currentTouchs))
			{
				Sync ();
			}
			else
			{
				m_content = null;
				Close ();
				isMultiTouch = false;
			}
		}
	}