예제 #1
0
 void Start()
 {
     instance = this;
     frostieAnimationManager = GetComponent <FrostieAnimationManager>();
     foreach (Transform childTransform in transform)
     {
         foreach (Transform child in childTransform)
         {
             if (child.name.Contains("Head"))
             {
                 head = child;
             }
             else if (child.name.Contains("Middle"))
             {
                 middlePart = child;
             }
             else if (child.name.Contains("Base"))
             {
                 basePart = child;
             }
         }
     }
     frostieParent       = transform.parent;
     frostieBase         = GetComponent <PlayerMovement>();
     activePart          = frostieBase.gameObject;
     activePartIndex     = 1;
     cameraScript.target = activePart.transform;
 }
예제 #2
0
        public void jump()
        {
            FrostieAnimationManager frostieAnimationManager = GetComponent <FrostieAnimationManager>();

            if (frostieAnimationManager != null)
            {
                frostieAnimationManager.animateJump();
            }
            else
            {
                GetComponentInChildren <Animator>().SetTrigger("Jump");
            }
        }
예제 #3
0
        public void move(float inputX)
        {
            viewDirection = transform.localScale.x / Mathf.Abs(transform.localScale.x);

            if (viewDirection * inputX < 0)
            {
                Vector3 scale = transform.localScale;
                scale.x *= -1;
                transform.localScale = scale;
                viewDirection       *= -1;
            }

            movement = speed * inputX;

            bool value = (movement != 0.0f);

            if (isWalking != value)
            {
                isWalking = value;

                FrostieAnimationManager frostieAnimationManager = GetComponent <FrostieAnimationManager>();
                if (frostieAnimationManager != null)
                {
                    frostieAnimationManager.animateWalking(isWalking);
                }
                else
                {
                    Animator animator = GetComponentInChildren <Animator>();
                    animator.SetBool("IsWalking", isWalking);
                }
            }

            FrostieSoundManager frostieSoundManager = GetComponent <FrostieSoundManager>();

            if (frostieSoundManager != null)
            {
                frostieSoundManager.playWalkingSound(movement);
            }
        }