Ejemplo n.º 1
0
 private float getIncreasedFallVell(PlayerValues.inputState currentInputState)
 {
     if (_rigidbody.velocity.y < 0)
     {
         if (currentInputState == PlayerValues.inputState.Fall)
         {
             return(1.02f);
         }
         else if (currentInputState == PlayerValues.inputState.Float)
         {
             return(.99f);
         }
         else
         {
             return(1f);
         }
     }
     else
     {
         if (currentInputState == PlayerValues.inputState.Fall)
         {
             return(.98f);
         }
         else if (currentInputState == PlayerValues.inputState.Float)
         {
             return(1.02f);
         }
         else
         {
             return(1f);
         }
     }
 }
Ejemplo n.º 2
0
    /***LOGIC METHODS ***/

    private float getMoveVel(PlayerValues.inputState currentInputState)
    {
        switch (currentInputState)
        {
        case PlayerValues.inputState.WalkLeft: {
            return(-values.walkVel);
        }

        case PlayerValues.inputState.WalkRight: {
            return(values.walkVel);
        }

        case PlayerValues.inputState.RunLeft: {
            return(-values.runVel);
        }

        case PlayerValues.inputState.RunRight: {
            return(values.runVel);
        }

        case PlayerValues.inputState.None:
        default:
            return(0f);
        }
    }
Ejemplo n.º 3
0
    public void updateInput()
    {
        attack = PlayerValues.inputState.None;
        middle = Screen.currentResolution.width / 2;

        r = 0; l = 0;
        foreach (Touch tut in Input.touches)
        {
            float x       = tut.position.x;
            bool  isRight = x > middle;


            if (isRight)
            {
                r++;

                if (initRight)
                {
                    if (Right.fingerId == tut.fingerId)
                    {
                        Right = tut;

                        TouchPhase phase = Right.phase;
                        //could be a swipe!!!

                        if (phase == TouchPhase.Canceled ||
                            phase == TouchPhase.Ended)
                        {
                            float swipeTime = Time.time - rstartTime;
                            float swipeDist = (Right.position.y - RightStart.y);
                            //calculateSwipeVals(  swipeDist, swipeTime);
                            if (swipeTime > minSwipeTime &&
                                swipeTime < maxSwipeTime &&
                                swipeDist > minSwipeDist &&
                                swipeDist < maxSwipeDist)
                            {
                                playerVal.setJumps(PlayerValues.inputState.Jump);
                                attack = PlayerValues.inputState.None;
                            }
                            else
                            {
                                attack = PlayerValues.inputState.HitMain;
                                playerVal.setJumps(PlayerValues.inputState.None);
                            }
                        }

                        //TODO check for holding for shield
                    }
                    else if (initLeft && Left.fingerId == tut.fingerId)
                    {
                        endLeft();
                    }
                    else
                    {
                        //drop this toutch it is an extra one we don't care about
                    }
                }
                else if (!(initLeft && Left.fingerId == tut.fingerId))
                {
                    Right      = tut;
                    initRight  = true;
                    RightStart = Right.position;
                    rstartTime = Time.time;
                }
                else
                {
                    endLeft();
                }
            }
            else
            {
                l++;
                if (initLeft)
                {
                    if (Left.fingerId == tut.fingerId)
                    {
                        Left = tut;

                        float ldeltx = Left.position.x - LeftStart.x;
                        float ldelty = Left.position.y - LeftStart.y;
                        float dist   = Mathf.Abs(Vector2.Distance(Left.position, LeftStart));


                        if (dist > nullarea)
                        {
                            if (ldeltx < -nullarea)
                            {
                                playerVal.setDirectionalX(PlayerValues.inputState.WalkLeft);
                                playerVal.setFacing(PlayerValues.facing.Left);
                            }
                            else if (ldeltx > nullarea)
                            {
                                playerVal.setFacing(PlayerValues.facing.Right);
                                playerVal.setDirectionalX(PlayerValues.inputState.WalkRight);
                            }

                            if (ldelty > nullarea)
                            {
                                playerVal.setDirectionalY(PlayerValues.inputState.Float);
                            }
                            else if (ldelty < -nullarea)
                            {
                                playerVal.setDirectionalY(PlayerValues.inputState.Fall);
                            }
                        }
                        else
                        {
                            playerVal.setDirectionalX(PlayerValues.inputState.None);
                            playerVal.setDirectionalY(PlayerValues.inputState.None);
                        }
                    }
                    else if (!(initRight && Right.fingerId == tut.fingerId))
                    {
                        endRight();
                    }
                    else
                    {
                        //drop this toutch it is an extra one we don't care about
                    }
                }
                else if (!(initRight && Right.fingerId == tut.fingerId))
                {
                    Left      = tut;
                    initLeft  = true;
                    LeftStart = Left.position;
                }
                else
                {
                    endRight();
                }
            }
        }
        if (l == 0 || !initLeft)
        {
            endLeft();
        }
        if (r == 0 || !initRight)
        {
            endRight();
        }
        playerVal.setAttack(attack);

//		gui.text = touchinfo;
    }
Ejemplo n.º 4
0
    public void updateInput()
    {
        attack = PlayerValues.inputState.None;
        middle =  Screen.currentResolution.width/2;

        r = 0; l = 0;
        foreach(Touch tut in Input.touches)
        {
            float x = tut.position.x;
            bool isRight = x > middle;

            if(isRight){
                r++;

                if(initRight)
                {

                    if(Right.fingerId == tut.fingerId)
                    {

                        Right = tut;

                        TouchPhase phase = Right.phase;
                        //could be a swipe!!!

                        if(phase == TouchPhase.Canceled ||
                           phase == TouchPhase.Ended)
                        {

                            float swipeTime = Time.time - rstartTime;
                            float swipeDist = (Right.position.y - RightStart.y);
                            //calculateSwipeVals(  swipeDist, swipeTime);
                            if(swipeTime > minSwipeTime &&
                               swipeTime < maxSwipeTime &&
                               swipeDist > minSwipeDist &&
                               swipeDist < maxSwipeDist)
                            {
                                playerVal.setJumps(PlayerValues.inputState.Jump);
                                attack = PlayerValues.inputState.None;

                            }
                            else
                            {
                                attack = PlayerValues.inputState.HitMain;
                                playerVal.setJumps(PlayerValues.inputState.None);
                            }
                        }

                        //TODO check for holding for shield

                    }
                    else if(initLeft && Left.fingerId == tut.fingerId)
                    {
                        endLeft();
                    }
                    else
                    {
                        //drop this toutch it is an extra one we don't care about
                    }
                }
                else if(!(initLeft && Left.fingerId == tut.fingerId))
                {
                    Right = tut;
                    initRight = true;
                    RightStart = Right.position;
                    rstartTime = Time.time;
                }
                else
                {
                    endLeft();
                }

            }
            else
            {
                l++;
                if(initLeft)
                {
                    if(Left.fingerId == tut.fingerId)
                    {
                        Left = tut;

                        float ldeltx = Left.position.x - LeftStart.x;
                        float ldelty = Left.position.y - LeftStart.y;
                        float dist = Mathf.Abs(Vector2.Distance(Left.position , LeftStart));

                        if(dist > nullarea)
                        {

                            if(ldeltx < -nullarea)
                            {
                                playerVal.setDirectionalX(PlayerValues.inputState.WalkLeft);
                                playerVal.setFacing(PlayerValues.facing.Left);
                            }
                            else if(ldeltx > nullarea)
                            {
                                playerVal.setFacing(PlayerValues.facing.Right);
                                playerVal.setDirectionalX(PlayerValues.inputState.WalkRight);
                            }

                            if(ldelty > nullarea )
                            {

                                playerVal.setDirectionalY(PlayerValues.inputState.Float);
                            }
                            else if(ldelty < -nullarea )
                            {

                                playerVal.setDirectionalY(PlayerValues.inputState.Fall);
                            }

                        }
                        else
                        {
                            playerVal.setDirectionalX (PlayerValues.inputState.None);
                            playerVal.setDirectionalY (PlayerValues.inputState.None);

                        }
                    }
                    else if(!(initRight && Right.fingerId == tut.fingerId))
                    {
                        endRight();
                    }
                    else
                    {
                        //drop this toutch it is an extra one we don't care about
                    }
                }
                else if(!(initRight && Right.fingerId == tut.fingerId))
                {
                    Left = tut;
                    initLeft = true;
                    LeftStart = Left.position;
                }
                else
                {
                    endRight();
                }

            }

        }
        if (l == 0 || !initLeft) endLeft ();
        if (r == 0 || !initRight) endRight ();
        playerVal.setAttack(attack);

        //		gui.text = touchinfo;
    }