Exemplo n.º 1
0
        /// <summary>
        /// Allow the player to move around in the scene
        /// </summary>
        void PlayerMovement()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.JoystickLeft(Player))
                {
                    RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.left);
                }

                if (ArcadeControls.JoystickRight(Player))
                {
                    RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.right);
                }

                if (ArcadeControls.JoystickUp(Player))
                {
                    RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.up);
                }

                if (ArcadeControls.JoystickDown(Player))
                {
                    RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.down);
                }

                if (ArcadeControls.JoystickNorthEast(Player))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                }

                if (ArcadeControls.JoystickNorthWest(Player))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                }

                if (ArcadeControls.JoystickSouthEast(Player))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                }

                if (ArcadeControls.JoystickSouthWest(Player))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                }

                if (ArcadeControls.JoystickNone(Player))
                {
                    RB.velocity = Vector2.zero;
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ControllerLeft(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.left);
                }

                if (ControllerControls.ControllerRight(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.right);
                }

                if (ControllerControls.ControllerUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.up);
                }

                if (ControllerControls.ControllerDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.down);
                }

                if (ControllerControls.ControllerLeftUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                }

                if (ControllerControls.ControllerRightUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                }

                if (ControllerControls.ControllerLeftDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                }

                if (ControllerControls.ControllerRightDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                }

                if (ControllerControls.ControllerNone(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.zero;
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.KeyboardLeft(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.left);
                }
                if (KeyboardControls.KeyboardRight(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.right);
                }
                if (KeyboardControls.KeyboardUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                    // UpdateGunshipDirection(Vector2.up);
                }
                if (KeyboardControls.KeyboardDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                    //UpdateGunshipDirection(Vector2.down);
                }
                if (KeyboardControls.KeyboardLeftUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                }
                if (KeyboardControls.KeyboardRightUp(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                }
                if (KeyboardControls.KeyboardLeftDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                }
                if (KeyboardControls.KeyboardRightDown(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                    UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                }
                if (KeyboardControls.KeyboardNone(ConvertToPlayers()))
                {
                    RB.velocity = Vector2.zero;
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (ConvertToPlayers() == Players.P1)
                {
                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.left);
                    }
                    if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.right);
                    }
                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                        //UpdateGunshipDirection(Vector2.up);
                    }
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                        //UpdateGunshipDirection(Vector2.down);
                    }
                    if (KeyboardControls.KeyboardLeftUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                    }
                    if (KeyboardControls.KeyboardRightUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                    }
                    if (KeyboardControls.KeyboardLeftDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                    }
                    if (KeyboardControls.KeyboardRightDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                    }
                    if (KeyboardControls.KeyboardNone(Players.P1))
                    {
                        RB.velocity = Vector2.zero;
                    }
                }
                else
                {
                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.left);
                    }

                    if (ControllerControls.ControllerRight(Players.P1))
                    {
                        RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.right);
                    }

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                        //UpdateGunshipDirection(Vector2.up);
                    }

                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                        //UpdateGunshipDirection(Vector2.down);
                    }

                    if (ControllerControls.ControllerLeftUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                    }

                    if (ControllerControls.ControllerRightUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                    }

                    if (ControllerControls.ControllerLeftDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                    }

                    if (ControllerControls.ControllerRightDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                    }

                    if (ControllerControls.ControllerNone(Players.P1))
                    {
                        RB.velocity = Vector2.zero;
                    }
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ConvertToPlayers() == Players.P2)
                {
                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.left);
                    }
                    if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.right);
                    }
                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.up);
                    }
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.down);
                    }
                    if (KeyboardControls.KeyboardLeftUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                    }
                    if (KeyboardControls.KeyboardRightUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                    }
                    if (KeyboardControls.KeyboardLeftDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                    }
                    if (KeyboardControls.KeyboardRightDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                    }
                    if (KeyboardControls.KeyboardNone(Players.P1))
                    {
                        RB.velocity = Vector2.zero;
                    }
                }
                else
                {
                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        RB.velocity = Vector2.left * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.left);
                    }

                    if (ControllerControls.ControllerRight(Players.P1))
                    {
                        RB.velocity = Vector2.right * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.right);
                    }

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        RB.velocity = Vector2.up * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.up);
                    }

                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        RB.velocity = Vector2.down * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.down);
                    }

                    if (ControllerControls.ControllerLeftUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.right, 1f));
                    }

                    if (ControllerControls.ControllerRightUp(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.up + Vector2.left, 1f));
                    }

                    if (ControllerControls.ControllerLeftDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.right, 1f));
                    }

                    if (ControllerControls.ControllerRightDown(Players.P1))
                    {
                        RB.velocity = Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f) * MoveSpd * Time.deltaTime;
                        UpdateGunshipDirection(Vector2.ClampMagnitude(Vector2.down + Vector2.left, 1f));
                    }

                    if (ControllerControls.ControllerNone(Players.P1))
                    {
                        RB.velocity = Vector2.zero;
                    }
                }

                break;

            default:
                break;
            }
        }
Exemplo n.º 2
0
        protected override void Update()
        {
            // The base update
            base.Update();

            JumpSmoothing();

            if (!JumpCoolRunning)
            {
                if (Physics.Linecast(transform.position, transform.position + new Vector3(0, -1.5f, 0), 1 << LayerMask.NameToLayer("Quacking:Ground")))
                {
                    CanDuckJump = true;
                }
                else
                {
                    CanDuckJump = false;
                }
            }

            switch (Power)
            {
            case Powerups.Explodie:
                MoveSpd = 8;
                PowerupLock.SetActive(false);
                PowerupSpd.SetActive(false);
                LockHex = false;
                break;

            case Powerups.Speedie:
                MoveSpd = 12;
                PowerupLock.SetActive(false);
                PowerupSpd.SetActive(true);
                LockHex = false;

                if (!IsSpeedie)
                {
                    StartCoroutine(SpdDuration());
                }

                mapController.SetControlledHexagonsToUnlocked(Ducks);

                break;

            case Powerups.Lockie:
                MoveSpd = 8;
                LockHex = true;
                PowerupLock.SetActive(true);
                PowerupSpd.SetActive(false);
                break;

            case Powerups.None:
                MoveSpd = 8;
                LockHex = false;
                PowerupLock.SetActive(false);
                PowerupSpd.SetActive(false);
                break;

            default:
                break;
            }

            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (ArcadeControls.JoystickUp(Joysticks.White))
                    {
                        GoFoward();
                    }
                    else if (ArcadeControls.JoystickDown(Joysticks.White))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ArcadeControls.ButtonPress(Joysticks.White, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P2:

                    if (ArcadeControls.JoystickUp(Joysticks.Black))
                    {
                        GoFoward();
                    }
                    else if (ArcadeControls.JoystickDown(Joysticks.Black))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ArcadeControls.ButtonPress(Joysticks.Black, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            case SupportedControllers.GamePadBoth:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (ControllerControls.ControllerDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P2:

                    if (ControllerControls.ControllerUp(Players.P2))
                    {
                        GoFoward();
                    }
                    else if (ControllerControls.ControllerDown(Players.P2))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ControllerControls.ButtonPress(Players.P2, ControllerButtons.A)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardBoth:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P2:

                    if (KeyboardControls.KeyboardUp(Players.P2))
                    {
                        GoFoward();
                    }
                    else if (KeyboardControls.KeyboardDown(Players.P2))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((KeyboardControls.ButtonPress(Players.P2, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                switch (Ducks)
                {
                case DuckPlayers.P1:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P2:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (ControllerControls.ControllerDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                switch (Ducks)
                {
                case DuckPlayers.P2:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((KeyboardControls.ButtonPress(Players.P1, Buttons.B1)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;

                case DuckPlayers.P1:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        GoFoward();
                    }
                    else if (ControllerControls.ControllerDown(Players.P1))
                    {
                        GoBackwards();
                    }
                    else
                    {
                        GoNowhere();
                    }

                    if ((ControllerControls.ButtonPress(Players.P1, ControllerButtons.A)) && (CanDuckJump))
                    {
                        am.PlayFromTime("Jump", .05f);
                        GetComponent <Rigidbody>().AddForce(transform.up * JumpHeight, ForceMode.Impulse);
                        StartCoroutine(JumpCooldown());
                    }

                    break;
                }

                break;

            default:
                break;
            }

            RotatePlayer();
        }
Exemplo n.º 3
0
        protected override void Update()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.JoystickUp(Joysticks.White))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (ArcadeControls.JoystickDown(Joysticks.White))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ControllerUp(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (ControllerControls.ControllerDown(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.KeyboardUp(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (KeyboardControls.KeyboardDown(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (KeyboardControls.KeyboardUp(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (KeyboardControls.KeyboardDown(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ControllerControls.ControllerUp(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition += 1f * Time.deltaTime;
                }
                else if (ControllerControls.ControllerDown(Players.P1))
                {
                    scrollRect.verticalNormalizedPosition -= 1f * Time.deltaTime;
                }

                break;

            default:
                break;
            }


            base.Update();
        }
Exemplo n.º 4
0
        protected override void Update()
        {
            base.Update();

            // If the joystick is pressed down
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.JoystickDown(ThisPlayer))
                {
                    FlipBoth();
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ControllerDown(ConvertToPlayers()))
                {
                    FlipBoth();
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.KeyboardDown(ConvertToPlayers()))
                {
                    FlipBoth();
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (ConvertToPlayers() == Players.P1)
                {
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        FlipBoth();
                    }
                }
                else
                {
                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        FlipBoth();
                    }
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ConvertToPlayers() == Players.P2)
                {
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        FlipBoth();
                    }
                }
                else
                {
                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        FlipBoth();
                    }
                }

                break;

            default:
                break;
            }
        }
Exemplo n.º 5
0
        public void MoveUD()
        {
            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if ((ArcadeControls.JoystickUp(Joysticks.White)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((ArcadeControls.JoystickDown(Joysticks.White)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            case SupportedControllers.GamePadBoth:

                if ((ControllerControls.ControllerUp(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((ControllerControls.ControllerDown(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if ((KeyboardControls.KeyboardUp(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((KeyboardControls.KeyboardDown(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if ((KeyboardControls.KeyboardUp(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((KeyboardControls.KeyboardDown(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if ((ControllerControls.ControllerUp(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(-1));
                }
                if ((ControllerControls.ControllerDown(Players.P1)) && (!isCoR))
                {
                    StartCoroutine(MoveAround(1));
                }

                break;

            default:
                break;
            }
        }
Exemplo n.º 6
0
        private void Update()
        {
            if (!SelectionPopupMenu.activeInHierarchy)
            {
                UpdateDisplay();

                if ((ArcadeControls.JoystickLeft(Joysticks.White)) && (IsAbleToSwitch))
                {
                    if (Hovered == 0)
                    {
                        Hovered = (MaxSelections);
                    }
                    else
                    {
                        --Hovered;
                    }

                    UpdateDisplay();
                    StartCoroutine(DelayToChange());
                }

                if ((ArcadeControls.JoystickRight(Joysticks.White)) && (IsAbleToSwitch))
                {
                    if (Hovered == (MaxSelections))
                    {
                        Hovered = 0;
                    }
                    else
                    {
                        ++Hovered;
                    }

                    UpdateDisplay();
                    StartCoroutine(DelayToChange());
                }

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                {
                    RunSelection();
                }

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                {
                    SelectionPopupMenu.SetActive(false);
                }
            }
            else
            {
                // Replay with different (Open menu)

                if (!SelectionMade)
                {
                    UpdateTextDisplayOnPopup();

                    if ((ArcadeControls.JoystickDown(Joysticks.White)) && (IsAbleToSwitch))
                    {
                        if (Hovered == (MaxSelections))
                        {
                            Hovered = 0;
                        }
                        else
                        {
                            ++Hovered;
                        }

                        UpdateTextDisplayOnPopup();
                        StartCoroutine(DelayToChange());
                    }

                    if ((ArcadeControls.JoystickUp(Joysticks.White)) && (IsAbleToSwitch))
                    {
                        if (Hovered == 0)
                        {
                            Hovered = (MaxSelections);
                        }
                        else
                        {
                            --Hovered;
                        }

                        UpdateTextDisplayOnPopup();
                        StartCoroutine(DelayToChange());
                    }

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                    {
                        NewMode       = (GameManager.GameTypes)(Hovered + 1);
                        SelectionMade = true;
                    }

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                    {
                        SelectionPopupMenu.SetActive(false);
                    }

                    HowManyText.enabled       = false;
                    HowManyNumberText.enabled = false;
                    DefaultNumberValue        = false;
                }

                // lives, timer or score selected....
                else
                {
                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B1))
                    {
                        ++SelectionInt;
                    }

                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B2))
                    {
                        --SelectionInt;
                    }


                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B7))
                    {
                        SelectionMade = false;
                    }

                    HowManyText.enabled       = true;
                    HowManyNumberText.enabled = true;

                    // Update text & diaply of text while it is still been changed


                    switch (NewMode)
                    {
                    case GameManager.GameTypes.Lives:

                        if (!DefaultNumberValue)
                        {
                            SelectionInt       = 3;
                            DefaultNumberValue = true;
                        }


                        HowManyText.text = "How Many Lives?";

                        HowManyNumberText.text = SelectionInt.ToString();

                        break;

                    case GameManager.GameTypes.Timer:

                        if (!DefaultNumberValue)
                        {
                            SelectionInt       = 60;
                            DefaultNumberValue = true;
                        }

                        HowManyText.text = "How Long?";

                        string Mins = (SelectionInt / 60).ToString("00");
                        string Sec  = (SelectionInt % 60).ToString("00");

                        HowManyNumberText.text = Mins + ":" + Sec;

                        break;

                    case GameManager.GameTypes.SetScore:

                        if (!DefaultNumberValue)
                        {
                            SelectionInt       = 1000;
                            DefaultNumberValue = true;
                        }

                        HowManyText.text = "Target Score?";

                        HowManyNumberText.text = SelectionInt.ToString();

                        break;

                    default:
                        break;
                    }



                    // if confirm pressed - send info and reload scene
                    if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                    {
                        switch (NewMode)
                        {
                        case GameManager.GameTypes.Lives:
                            PlayerPrefs.SetFloat("Pinball-Lives", SelectionInt);
                            SelectionInt  = 0;
                            SelectionMade = false;
                            SelectionPopupMenu.SetActive(false);
                            PlayerPrefs.SetInt("Pinball-Gametype", (int)GameManager.GameTypes.Lives);
                            SceneManager.LoadSceneAsync("BallGame");
                            break;

                        case GameManager.GameTypes.Timer:
                            PlayerPrefs.SetFloat("Pinball-Timer", SelectionInt);
                            SelectionInt  = 0;
                            SelectionMade = false;
                            SelectionPopupMenu.SetActive(false);
                            PlayerPrefs.SetInt("Pinball-Gametype", (int)GameManager.GameTypes.Timer);
                            SceneManager.LoadSceneAsync("BallGame");
                            break;

                        case GameManager.GameTypes.SetScore:
                            PlayerPrefs.SetFloat("Pinball-SetScore", SelectionInt);
                            SelectionInt  = 0;
                            SelectionMade = false;
                            SelectionPopupMenu.SetActive(false);
                            PlayerPrefs.SetInt("Pinball-Gametype", (int)GameManager.GameTypes.SetScore);
                            SceneManager.LoadSceneAsync("BallGame");
                            break;

                        default:
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        void MenuInput_MultiOption()
        {
            switch (InputDir)
            {
            case Directions.Hoz:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.JoystickLeft(Joysticks.White))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ArcadeControls.JoystickRight(Joysticks.White))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ControllerControls.ControllerRight(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (KeyboardControls.KeyboardLeft(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (KeyboardControls.KeyboardRight(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ControllerControls.ControllerLeft(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ControllerControls.ControllerRight(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                default:
                    break;
                }

                break;

            case Directions.Ver:

                switch (ControllerType)
                {
                case SupportedControllers.ArcadeBoard:

                    if (ArcadeControls.JoystickUp(Joysticks.White))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ArcadeControls.JoystickDown(Joysticks.White))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.GamePadBoth:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardBoth:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardP1ControllerP2:

                    if (KeyboardControls.KeyboardUp(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (KeyboardControls.KeyboardDown(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                case SupportedControllers.KeyboardP2ControllerP1:

                    if (ControllerControls.ControllerUp(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(-1));
                    }
                    if (ControllerControls.ControllerDown(Players.P1))
                    {
                        StartCoroutine(MoveAroundMenu(1));
                    }

                    break;

                default:
                    break;
                }

                break;
            }

            switch (ControllerType)
            {
            case SupportedControllers.ArcadeBoard:

                if (ArcadeControls.ButtonPress(Joysticks.White, Buttons.B8))
                {
                    RunEvent();
                }

                break;

            case SupportedControllers.GamePadBoth:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm))
                {
                    RunEvent();
                }

                break;

            case SupportedControllers.KeyboardBoth:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    RunEvent();
                }

                break;

            case SupportedControllers.KeyboardP1ControllerP2:

                if (KeyboardControls.ButtonPress(Players.P1, Buttons.B8))
                {
                    RunEvent();
                }

                break;

            case SupportedControllers.KeyboardP2ControllerP1:

                if (ControllerControls.ButtonPress(Players.P1, ControllerButtons.Confirm))
                {
                    RunEvent();
                }

                break;

            default:
                break;
            }
        }