Beispiel #1
0
    void Update()
    {
        // If the game has started
        if (game)
        {
            // Find current direction of controls
            float horizontal = Input.GetAxis(controlHorizontal);
            float vertical   = Input.GetAxis(controlVertical);

            // Set current direction into vector3
            Vector3 moveDirection = new Vector3(horizontal, 0.0f, vertical);

            //Rotation thing CC
            float rightHorizontal = Input.GetAxis(controlRightHorizontal);
            float rightVertical   = Input.GetAxis(controlRightVertical);

            // Set rotation into Vector3
            Vector3 rotationDirection = new Vector3(rightHorizontal, 0.0f, rightVertical);

            // check if jump button is used
            bool jumping = false;
            if (Input.GetButtonDown(controlJump))
            {
                jumping = true;
            }

            // Move and rotate character
            character.MovingCharacter(moveDirection, jumping);
            character.RotateCharacter(rotationDirection);


            if (Math.Abs(rightHorizontal) + Math.Abs(rightVertical) > 0.9f)
            {
                character.HoldBasic(true);
                shootingUpdate = true;
            }
            else
            {
                if (shootingUpdate)
                {
                    character.HoldBasic(false);
                    shootingUpdate = false;
                }
            }

            // Check if any buttons are used
            if (Input.GetButtonDown(controlBasic))
            {
                character.HoldBasic(true);
            }
            if (Input.GetButtonUp(controlBasic))
            {
                character.HoldBasic(false);
            }
            if (Input.GetButtonDown(controlRightStick))
            {
                Debug.Log("Right Stick clicked");
            }
            if (Input.GetButtonUp(controlRightStick))
            {
                rotStickTapCount += 1f;
                Debug.Log("Right Stick released");
            }
            if (Input.GetButtonDown(controlCC))
            {
                character.UseCCAttack();
            }
            if (Input.GetButtonDown(controlUltimate))
            {
                character.UseUltimateAttack();
            }

            if (rotStickTapCount > 0 && rotStickTimeDelay < 0.75f)
            {
                rotStickTimeDelay += Time.deltaTime;
            }

            if (rotStickTapCount > 1 && rotStickTimeDelay < 0.75f)
            {
                if (Math.Abs(rightHorizontal) + Math.Abs(rightVertical) > 0.8f)
                {
                    Debug.Log("CCAttack Used");
                    character.UseCCAttack();
                    rotStickTimeDelay = 0f;
                    rotStickTapCount  = 0f;
                }
            }
            if (rotStickTimeDelay > 0.75f)
            {
                rotStickTimeDelay = 0f;
                rotStickTapCount  = 0f;
            }
        }

        // If the controller has to be in the menu state
        if (menu)
        {
            // If character has not been chosen yet
            if (canChoose)
            {
                // Check if the player uses the controller to go to the last or next character
                if (Input.GetAxis(controlHorizontal) < 0)
                {
                    if (!stickDownLast)
                    {
                        menuCharacter.LastItem();
                    }

                    stickDownLast = true;
                }
                else if (Input.GetAxis(controlHorizontal) > 0)
                {
                    if (!stickDownLast)
                    {
                        menuCharacter.NextItem();
                    }
                    stickDownLast = true;
                }
                else
                {
                    stickDownLast = false;
                }
            }

            // If the player uses the confirm button
            if (Input.GetButtonDown(controlJump))
            {
                Confirm();
            }
            // If the player uses the cancel button
            if (Input.GetButtonDown(controlCC))
            {
                Cancel();
            }
        }
    }