Пример #1
0
    public TouchInputManager()
    {
        SetupPlatform();
        if (instance != this)
        {
            instance = this;
        }
        //Sets default as iPhone control wrapper
        playerControl = new IphoneTouchWrapper();

        Debug.Log("Touch Input Manager Instantiated");
    }
Пример #2
0
    public override bool Equals(object other)
    {
        // Null check
        if (other == null)
        {
            return(false);
        }

        // Casts the object as TouchInputWrapper then null tests
        TouchInputWrapper test = other as TouchInputWrapper;

        if ((System.Object)test == null)
        {
            return(false);
        }

        return(false);
    }
Пример #3
0
    void TakeSample()
    {
        TouchData data;

        if (m_TouchData.Count < 20)
        {
            data = new TouchData();
        }
        else
        {
            data = m_TouchData[m_TouchData.Count - 1];
            m_TouchData.RemoveAt(m_TouchData.Count - 1);
        }

        data.m_Position = TouchInputWrapper.GetTouchPosition(m_TouchID);
        data.m_Time     = Time.realtimeSinceStartup;

        m_TouchData.Insert(0, data);
    }
Пример #4
0
    public void Update()
    {
                #if !UNITY_EDITOR
        if (Input.touchCount <= m_TouchID)
        {
            return;
        }
                #endif

        if (m_TouchDidBegin && m_NumberOfTouches != Input.touchCount)
        {
            //Reset
            m_LastPosition = TouchInputWrapper.GetTouchPosition(m_TouchID);
        }


        if (GetTouchBegan())
        {
            m_TouchDidMove   = false;
            m_TouchDidBegin  = true;
            m_TouchBeganTime = Time.realtimeSinceStartup;
            m_LastPosition   = TouchInputWrapper.GetTouchPosition(m_TouchID);
        }
        else if (GetTouchEnded())
        {
            m_TouchDidMove  = false;
            m_TouchDidBegin = false;
        }
        else if (GetTouchMoved())
        {
//			Debug.Log("GetTouchMoved");
            m_TouchDidMove = true;
            //sample data
            TakeSample();
            m_LastPosition = TouchInputWrapper.GetTouchPosition(m_TouchID);
        }
        else if (GetTouchStationary())
        {
        }

        m_NumberOfTouches = Input.touchCount;
    }
Пример #5
0
 // Registers a new player touch controller
 public void RegisterPlayerTouch(TouchInputWrapper tiw)
 {
     playerControl = tiw;
     Debug.Log(tiw.GetType().ToString() + ": Registered");
 }
Пример #6
0
 // Clears the active player touch controller
 public void ClearPlayer()
 {
     playerControl = null;
 }
Пример #7
0
 public Vector2 GetPosition()
 {
     return(TouchInputWrapper.GetTouchPosition(m_TouchID));
 }