예제 #1
0
        private void playAudio()
        {
            tempCount = (tempCount + 1) % 2;
            switch (animQueue.Peek())
            {
            case "slash":
                audioComponent.PlaySound2D("attack1");
                break;

            case "slashR":
                audioComponent.PlaySound2D("attack2");
                break;

            case "slashL":
                audioComponent.PlaySound2D("attack3");
                break;

            case "throw":
                audioComponent.PlaySound2D("attack4");
                break;

            case "spin":
                audioComponent.PlaySound2D("laughter");
                break;

            case "wbicie":
                audioComponent.PlaySound("attack5");
                break;

            case "baczek":
                if (tempCount == 0)
                {
                    audioComponent.Volume = audioComponent.Volume * 0.5f;
                    audioComponent.PlaySound2D("woosh");
                    audioComponent.Volume = audioComponent.Volume * 2f;
                }
                break;

            default:
                break;
            }
        }
예제 #2
0
 public override void ReceiveHit()
 {
     base.ReceiveHit();
     audioComponent.PlaySound2D("damage");
 }
예제 #3
0
        private void PlayerMovement()
        {
            Vector3 movement = new Vector3();

            if (inputManager.Keyboard[Keys.W])
            {
                movement.Z += playerSpeed;
            }

            if (inputManager.Keyboard[Keys.S])
            {
                movement.Z += -playerSpeed;
            }

            if (inputManager.Keyboard[Keys.A])
            {
                movement.X += -playerSpeed;
            }

            if (inputManager.Keyboard[Keys.D])
            {
                movement.X += playerSpeed;
            }

            if (parentGameObject.isGrounded && inputManager.Keyboard[Keys.Space] && playerHat.GetComponent <AnimationManager>().isReady)
            {
                if (!isJumping)
                {
                    audioComponent?.PlaySound2D("jump");
                    isJumping = true;
                    playerLeg.GetComponent <AnimationManager>().SetPlaybackMultiplier(0.9f);
                    playerHat.GetComponent <AnimationManager>().SetPlaybackMultiplier(0.9f);
                    playerLeg.GetComponent <AnimationManager>().PlayAnimation("jumpStart", true);
                    playerHat.GetComponent <AnimationManager>().PlayAnimation("jumpStart", true);
                    playerLeg.GetComponent <AnimationManager>().SetPlaybackMultiplier(0.9f);
                    playerHat.GetComponent <AnimationManager>().SetPlaybackMultiplier(0.9f);
                    playerLeg.GetComponent <AnimationManager>().PlayAnimation("jumpLand");
                    playerHat.GetComponent <AnimationManager>().PlayAnimation("jumpLand");
                }
            }


            if (!isJumping && parentGameObject.isGrounded)
            {
                if (movement != Vector3.Zero)
                {
                    if (playerHat.GetComponent <AnimationManager>().defaultKey != "walk")
                    {
                        playerHat.GetComponent <AnimationManager>().SetDefaultAnimation("walk");
                        playerLeg.GetComponent <AnimationManager>().SetDefaultAnimation("walk");
                    }
                }
                else
                {
                    if (playerHat.GetComponent <AnimationManager>().defaultKey != "idle")
                    {
                        playerHat.GetComponent <AnimationManager>().SetDefaultAnimation("idle");
                        playerLeg.GetComponent <AnimationManager>().SetDefaultAnimation("idle");
                    }
                }
            }
            else
            {
                //TODO: FIX JUMP FALLING ANIMATION OR LEAVE IT IN PEACE
                //if (playerHat.GetComponent<AnimationManager>().defaultKey != "jumpFall")
                //{
                //    playerHat.GetComponent<AnimationManager>().SetDefaultAnimation("jumpFall");
                //    playerLeg.GetComponent<AnimationManager>().SetDefaultAnimation("jumpFall");
                //}

                if (playerHat.GetComponent <AnimationManager>().defaultKey != "idle")
                {
                    playerHat.GetComponent <AnimationManager>().SetDefaultAnimation("idle");
                    playerLeg.GetComponent <AnimationManager>().SetDefaultAnimation("idle");
                }

                if (parentGameObject.isGrounded)
                {
                    //playerLeg.GetComponent<AnimationManager>().SetPlaybackMultiplier(0.8f);
                    //playerHat.GetComponent<AnimationManager>().SetPlaybackMultiplier(0.8f);
                    //playerLeg.GetComponent<AnimationManager>().PlayAnimation("jumpLand");
                    //playerHat.GetComponent<AnimationManager>().PlayAnimation("jumpLand");
                }
            }

            Move(movement);

            Rotate(ShroomGame.mouseXAxis * inputManager.Mouse.PositionsDelta.X * 0.01f);
        }