示例#1
0
//	void OnGUI() {
//		//GUI.Label( new Rect( 0.0f, 0.0f, 200.0f, 200.0f ), m_enCurrentDirection.ToString() );
////		GUI.Box( new Rect( Screen.width * 0.5f - 125.0f, 5.0f, 250.0f, 30.0f ), m_enCurrentDirection.ToString() );
////		m_bMobileBased = GUI.Toggle( new Rect( Screen.width * 0.5f - 125.0f, 45.0f, 250.0f, 30.0f ), m_bMobileBased, "Touch Input for Mobile ( BETA! )" );
////		m_bVisualFeedback = GUI.Toggle( new Rect( Screen.width * 0.5f - 125.0f, 85.0f, 250.0f, 30.0f ), m_bVisualFeedback, "Visual Feedback" );
//
//		string direction8 = "8 directions";
//
//		if ( !m_b8Direction ) {
//			direction8 = "4 directions";
//			GameObject.Find( "SwipeController" ).GetComponent<SwipeControl>().m_stSwipeType = SwipeControl.SWIPE_TYPE.ST_4_DIRECTION;
//		}
//		else {
//			GameObject.Find( "SwipeController" ).GetComponent<SwipeControl>().m_stSwipeType = SwipeControl.SWIPE_TYPE.ST_8_DIRECTION;
//		}
//
////		m_b8Direction = GUI.Toggle( new Rect( Screen.width * 0.5f - 125.0f, 125.0f, 250.0f, 30.0f ), m_b8Direction, direction8 );
//
//		GameObject.Find( "SwipeController" ).GetComponent<SwipeControl>().m_bActiveVisualFeedback = m_bVisualFeedback;
//		GameObject.Find( "SwipeController" ).GetComponent<SwipeControl>().m_bMobileTouchBased = m_bMobileBased;
//
//
//	}

    private void MyCallbackMethod(SwipeControl.SWIPE_DIRECTION iDirection)
    {
        m_enCurrentDirection = iDirection;

        //this.transform.rotation = Quaternion.identity;
//		m_fSpeed = 600.0f;

        switch (iDirection)
        {
        case SwipeControl.SWIPE_DIRECTION.SD_UP:
            // GameManager.piecewiseStep++;
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_DOWN:
            // GameManager.piecewiseStep++;
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_LEFT:
            GameManager.piecewiseStep++;
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_RIGHT:
            GameManager.piecewiseStep++;
            break;
        }
        print(m_enCurrentDirection + " " + GameManager.piecewiseStep);
    }
示例#2
0
    private void SwipeCallBack(SwipeControl.SWIPE_DIRECTION iDirection)
    {
        if (CancelSwipe)
        {
            return;
        }

        switch (iDirection)
        {
        case SwipeControl.SWIPE_DIRECTION.SD_UP:     //This is a swipe up
            print("Swipe Up");
            if (notifySwipeUp != null)
            {
                notifySwipeUp();
            }
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_DOWN:
            print("Swipe Down");
            if (notifySwipeDown != null)
            {
                notifySwipeDown();
            }
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_LEFT:
            print("Swipe Left");
            if (notifySwipeLeft != null)
            {
                notifySwipeLeft();
            }
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_RIGHT:
            print("Swipe Right");
            if (notifySwipeRight != null)
            {
                notifySwipeRight();
            }
            break;

        //case SwipeControl.SWIPE_DIRECTION.SD_UP_RIGHT:
        //    break;
        //case SwipeControl.SWIPE_DIRECTION.SD_DOWN_RIGHT:
        //    break;
        //case SwipeControl.SWIPE_DIRECTION.SD_DOWN_LEFT:
        //    break;
        //case SwipeControl.SWIPE_DIRECTION.SD_UP_LEFT:
        //    break;
        case SwipeControl.SWIPE_DIRECTION.SD_TOUCH:
            print("Hice Tap");
            break;
        }
    }
示例#3
0
 /// <summary>
 /// Detects the input if it's a mobile device
 /// </summary>
 private void DetectInputFromMobile(SwipeControl.SWIPE_DIRECTION iDirection)
 {
     if (iDirection == SwipeControl.SWIPE_DIRECTION.SD_RIGHT)
     {
         UpdatePaddlePosition(true);
     }
     else if (iDirection == SwipeControl.SWIPE_DIRECTION.SD_LEFT)
     {
         UpdatePaddlePosition(false);
     }
 }
示例#4
0
public void MyCallbackMethod(SwipeControl.SWIPE_DIRECTION iDirection)
{
    Debug.Log(iDirection);
    switch (iDirection)
    {
        /*
         * Tomake sure we detecting touch:
         *  - Touch
         * 
         * To make sure we detecting swipe atleast the condition that make sense are:
         *  - Down_Left
         *  - Down Right
         *  - Left
         *  - Right
         *  - Up Left
         *  - Up Right
         *  -------------------------------------------------------------------------
         */

        case SwipeControl.SWIPE_DIRECTION.SD_DOWN:
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_DOWN_LEFT:
            print("Detecting: Swipe");
            isSwipe = true;
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_DOWN_RIGHT:
            print("Detecting: Swipe");
            isSwipe = true;
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_LEFT:
            print("Detecting: Swipe");
            isSwipe = true;
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_RIGHT:
            print("Detecting: Swipe");
            isSwipe = true;
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_TOUCH:
            print("Detecting Touch");
            isSwipe = false;
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_UP:
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_UP_LEFT:
            print("Detecting Swipe");
            isSwipe = true;
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_UP_RIGHT:
            print("Detecting Swipe");
            isSwipe = true;
            break;
    }
}
示例#5
0
    private void MyCallbackMethod(SwipeControl.SWIPE_DIRECTION iDirection)
    {
        m_enCurrentDirection = iDirection;

        //this.transform.rotation = Quaternion.identity;
        m_fSpeed = 600.0f;

        switch (iDirection)
        {
        case SwipeControl.SWIPE_DIRECTION.SD_UP:
            m_vRotationDirection = new Vector3(1.0f, 0.0f, 0.0f);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_DOWN:
            m_vRotationDirection = new Vector3(-1.0f, 0.0f, 0.0f);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_LEFT:
            m_vRotationDirection = new Vector3(0.0f, 1.0f, 0.0f);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_RIGHT:
            m_vRotationDirection = new Vector3(0.0f, -1.0f, 0.0f);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_DOWN_LEFT:
            m_vRotationDirection = new Vector3(-1.0f, 1.0f, 0.0f);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_DOWN_RIGHT:
            m_vRotationDirection = new Vector3(-1.0f, -1.0f, 0.0f);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_UP_LEFT:
            m_vRotationDirection = new Vector3(1.0f, 1.0f, 0.0f);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_UP_RIGHT:
            m_vRotationDirection = new Vector3(1.0f, -1.0f, 0.0f);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_TOUCH:
            m_vRotationDirection = new Vector3(0.0f, 0.0f, 0.0f);
            break;
        }
    }
示例#6
0
    //Touch Controls
    private void MyCallbackMethod(SwipeControl.SWIPE_DIRECTION iDirection)
    {
        switch (iDirection)
        {
        case SwipeControl.SWIPE_DIRECTION.SD_LEFT:
            if (_lane != -1)
            {
                gameObject.GetComponent <AudioSource>().PlayOneShot(LaneChange);
                gameObject.transform.Translate(-1.5f, 0, 0);
                _lane -= 1;
            }
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_RIGHT:
            if (_lane != 1)
            {
                gameObject.GetComponent <AudioSource>().PlayOneShot(LaneChange);
                gameObject.transform.Translate(1.5f, 0, 0);
                _lane += 1;
            }
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_TOUCH:
            _animator = gameObject.GetComponent <Animator>();
            _animator.SetTrigger("Attack");
            Collider2D[] CollidersInFront = Physics2D.OverlapAreaAll(new Vector2(transform.position.x - 0.3f, transform.position.y), new Vector2(transform.position.x + 0.5f, transform.position.y + 1.5f));
            foreach (Collider2D collided in CollidersInFront)
            {
                if (collided.gameObject.tag == "Enemy")
                {
                    gameObject.GetComponent <AudioSource>().PlayOneShot(SwordHit);
                    //ParticleSystem blood = Instantiate(bloodEffect) as ParticleSystem;
                    ParticleSystem blood = ParticlePooler.current.GetPooledParticle();
                    blood.transform.position = collided.transform.position;
                    blood.Play();
                    Invoke("ParticlePooler.current.DestroyParticle(blood)", 2f);
                    Destroy(collided.gameObject);
                    _killedEnemies += 1;
                }
            }
            break;
        }
    }
    void ReadCommands(SwipeControl.SWIPE_DIRECTION iDirection)
    {
        switch (iDirection)
        {
        case SwipeControl.SWIPE_DIRECTION.SD_UP:
            EventManager.Instance.PostNotification(EVENT_TYPE.PLAYER_TURN_UP, this, gameObject);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_DOWN:
            EventManager.Instance.PostNotification(EVENT_TYPE.PLAYER_TURN_DOWN, this, gameObject);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_LEFT:
            EventManager.Instance.PostNotification(EVENT_TYPE.PLAYER_TURN_LEFT, this, gameObject);
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_RIGHT:
            EventManager.Instance.PostNotification(EVENT_TYPE.PLAYER_TURN_RIGHT, this, gameObject);
            break;
        }
    }
示例#8
0
    private void MyCallbackMethod( SwipeControl.SWIPE_DIRECTION iDirection )
    {
        m_enCurrentDirection = iDirection;

        //this.transform.rotation = Quaternion.identity;
        m_fSpeed = 600.0f;

        switch ( iDirection ) {
        case SwipeControl.SWIPE_DIRECTION.SD_UP:
            m_vRotationDirection = new Vector3( 1.0f, 0.0f, 0.0f );
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_DOWN:
            m_vRotationDirection = new Vector3( -1.0f, 0.0f, 0.0f );
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_LEFT:
            m_vRotationDirection = new Vector3( 0.0f, 1.0f, 0.0f );
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_RIGHT:
            m_vRotationDirection = new Vector3( 0.0f, -1.0f, 0.0f );
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_DOWN_LEFT:
            m_vRotationDirection = new Vector3( -1.0f, 1.0f, 0.0f );
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_DOWN_RIGHT:
            m_vRotationDirection = new Vector3( -1.0f, -1.0f, 0.0f );
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_UP_LEFT:
            m_vRotationDirection = new Vector3( 1.0f, 1.0f, 0.0f );
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_UP_RIGHT:
            m_vRotationDirection = new Vector3( 1.0f, -1.0f, 0.0f );
            break;
        case SwipeControl.SWIPE_DIRECTION.SD_TOUCH:
            m_vRotationDirection = new Vector3( 0.0f, 0.0f, 0.0f );
            break;
        }
    }
示例#9
0
    private void SwipeDetection(SwipeControl.SWIPE_DIRECTION iDirection)
    {
        Debug.Log(iDirection);
        switch (iDirection)
        {
        case SwipeControl.SWIPE_DIRECTION.SD_DOWN:
            if (animCollision.GetBool("isFinished"))
            {
                if (LastDirection == Direction.Bawah)
                {
                    break;
                }
                else
                {
                    pDirection = Direction.Bawah;

                    rgbd2D.constraints = RigidbodyConstraints2D.FreezePositionX;
                    rgbd2D.constraints = RigidbodyConstraints2D.FreezeRotation;
                    Terbang(pDirection);
                    animPlayer.SetBool("isFinished", false);
                    animCollision.SetBool("isFinished", false);
                    addStep();
                    audio.clip = SwipeClip;
                    audio.Play();
                }
            }

            //what to do buat Bawah
            //ganti gravity jadi ke bawah
            //ganti animasi jadi ke bawah pake coroutine.
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_LEFT:
            if (animCollision.GetBool("isFinished"))
            {
                if (LastDirection == Direction.Kiri)
                {
                    break;
                }
                else
                {
                    pDirection = Direction.Kiri;

                    rgbd2D.constraints = RigidbodyConstraints2D.FreezePositionY;
                    rgbd2D.constraints = RigidbodyConstraints2D.FreezeRotation;
                    Terbang(pDirection);
                    animPlayer.SetBool("isFinished", false);
                    animCollision.SetBool("isFinished", false);
                    addStep();
                    audio.clip = SwipeClip;
                    audio.Play();
                }
            }

            //what to do buat Kiri
            //ganti gravity jadi ke kiri
            //ganti animasi jadi ke kiri pake coroutine.
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_RIGHT:
            if (animCollision.GetBool("isFinished"))
            {
                if (LastDirection == Direction.Kanan)
                {
                    break;
                }
                else
                {
                    pDirection = Direction.Kanan;

                    rgbd2D.constraints = RigidbodyConstraints2D.FreezePositionY;
                    rgbd2D.constraints = RigidbodyConstraints2D.FreezeRotation;

                    Terbang(pDirection);
                    animPlayer.SetBool("isFinished", false);
                    animCollision.SetBool("isFinished", false);
                    addStep();
                    audio.clip = SwipeClip;
                    audio.Play();
                }
            }

            //what to do buat Kanan
            //ganti gravity jadi ke kanan
            //ganti animasi jadi ke kanan pake coroutine
            break;

        case SwipeControl.SWIPE_DIRECTION.SD_UP:
            if (animCollision.GetBool("isFinished"))
            {
                if (LastDirection == Direction.Atas)
                {
                    break;
                }
                else
                {
                    pDirection         = Direction.Atas;
                    rgbd2D.constraints = RigidbodyConstraints2D.FreezePositionX;
                    rgbd2D.constraints = RigidbodyConstraints2D.FreezeRotation;

                    Terbang(pDirection);
                    animPlayer.SetBool("isFinished", false);
                    animCollision.SetBool("isFinished", false);
                    addStep();
                    audio.clip = SwipeClip;
                    audio.Play();
                }
            }

            /*
             * if (animPlayer.GetBool("isFinished") == true)
             * {
             *  Terbang(pDirection);
             * }*/
            //Animation

            //what to do buat Atas
            //ganti gravity jadi ke atas
            //ganti animasi jadi ke atas pake coroutine.
            break;
        }
    }