示例#1
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();
        }
示例#2
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;
            }
        }
示例#3
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;
            }
        }
示例#4
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();
        }
示例#5
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;
            }
        }