示例#1
0
    IEnumerator EndAnimations()
    {
        yield return(new WaitForSeconds(0.06f));

        AnimatorBehaviour.GetAnimator(PlayerController._instance.animator);
        AnimatorBehaviour.StopShootingAnimations(PlayerController._instance.movementVector);
    }
示例#2
0
 void Start()
 {
     character        = GetComponent <CharacterRaycaster>();
     timeSinceJumped  = 10f;
     jumpsAllowedLeft = maxJumpsAllowed;
     AnimatorBehaviour.GetAnimator(animator);
 }
示例#3
0
        private void OnEnable()
        {
            if (EditorApplication.isPlaying)
            {
                return;
            }

            AnimatorBehaviour targetBehaviour = serializedObject.targetObject as AnimatorBehaviour;

            AnimatorBehaviour[] behaviours = targetBehaviour.gameObject.GetComponents <AnimatorBehaviour>();

            DisallowAttribute attribute = Attribute.GetCustomAttribute(targetBehaviour.GetType(), typeof(DisallowAttribute)) as DisallowAttribute;

            if (attribute != null)
            {
                foreach (AnimatorBehaviour behaviour in behaviours)
                {
                    foreach (Type disallowed in attribute.components)
                    {
                        if (behaviour.GetType() == disallowed)
                        {
                            EditorUtility.DisplayDialog(
                                "Invalid operation.",
                                "Specific animators cannot coexist with K-Animator!",
                                "OK"
                                );

                            DestroyImmediate(targetBehaviour);
                            return;
                        }
                    }
                }
            }
        }
示例#4
0
 void PostMovementJumpUpdate()
 {
     if (isGrounded)
     {
         AnimatorBehaviour.CancelJumpAnimations();
         isJumping        = false;
         jumpsAllowedLeft = maxJumpsAllowed;
     }
 }
示例#5
0
 void TryJump()
 {
     if (jumpsAllowedLeft == 0)
     {
         return;
     }
     if (hasBag)
     {
         return;
     }
     jumpsAllowedLeft--;
     StartJump();
     AnimatorBehaviour.JumpAnimations(movementVector);
 }
示例#6
0
        /// <summary>
        /// Gets all the animators from the children of this game object
        /// with the same type as this animator.
        /// </summary>
        /// <returns>The animators from the children of this game object
        /// with the same type as this animator.</returns>
        protected override AnimatorBehaviour[] GetChildAnimators()
        {
            AnimatorBehaviour[] childrenWithParent = gameObject.transform.GetComponentsInChildren <KAnimator>();
            AnimatorBehaviour[] children           = new AnimatorBehaviour[childrenWithParent.Length - 1];
            int i = 0;

            foreach (AnimatorBehaviour child in childrenWithParent)
            {
                if (child.gameObject.GetInstanceID() != gameObject.GetInstanceID())
                {
                    children[i] = child;
                    i++;
                }
            }

            return(children);
        }
示例#7
0
    void Move(Vector3 movement)
    {
        /*      if (movement.x > 0) raycaster.flags.left = false;
         *    if (movement.x < 0) raycaster.flags.right = false;
         *    if (movement.y > 0) raycaster.flags.below = false;
         *    if (movement.y < 0) raycaster.flags.above = false;
         *
         */
        if (Mathf.Abs(movement.y) < movementThreshold)
        {
            movement.y = 0;
        }


        character.Move(movement);

        AnimatorBehaviour.MovementAnimations(movement);
    }
示例#8
0
    void JumpUpdate()
    {
        movementVector.y = gravity * -1f;

        if (!isJumping)
        {
            return;
        }

        float releaseMultiplier = jumpKey ? 1 : jumpReleaseMultiplier;

        timeSinceJumped += Time.deltaTime * releaseMultiplier;

        float gravityMultiplier = jumpCurve.Evaluate(timeSinceJumped);

        movementVector.y *= -1 * gravityMultiplier;

        if (timeSinceJumped > jumpCurve.keys[jumpCurve.keys.Length - 1].time)
        {
            isJumping = false;
            AnimatorBehaviour.CancelJumpAnimations();
        }
    }
示例#9
0
        /// <summary>
        /// Sets the alpha value of any graphic component added to the given game object.
        /// </summary>
        /// <param name="transform">The transform of the game object.</param>
        /// <param name="fade">The new fade value.</param>
        /// <param name="shouldFadeChildren">Whether the new alpha value should be applied
        /// to the children of the given game object.</param>
        private void Fade(Transform transform, float fade, bool shouldFadeChildren)
        {
            bool isAnimatingChild = false;

            if (gameObject.transform != transform)
            {
                AnimatorBehaviour animator = transform.GetComponent <AnimatorBehaviour>();

                if (animator != null)
                {
                    if (inAnimation.IsEnabled && inAnimation.HasBegan)
                    {
                        isAnimatingChild = true;
                    }
                    else if (outAnimation.IsEnabled && outAnimation.HasBegan)
                    {
                        isAnimatingChild = true;
                    }
                }
            }

            if (!isAnimatingChild)
            {
                Image image = transform.gameObject.GetComponent <Image>();

                if (image != null)
                {
                    image.color = new Color(image.color.r, image.color.g, image.color.b, fade);
                }

                Text text = transform.gameObject.GetComponent <Text>();

                if (text != null)
                {
                    text.color = new Color(text.color.r, text.color.g, text.color.b, fade);
                }

                RawImage rawImage = transform.gameObject.GetComponent <RawImage>();

                if (rawImage != null)
                {
                    rawImage.color = new Color(rawImage.color.r, rawImage.color.g, rawImage.color.b, fade);
                }

                SpriteRenderer sprite = transform.gameObject.GetComponent <SpriteRenderer>();

                if (sprite != null)
                {
                    sprite.color = new Color(sprite.color.r, sprite.color.g, sprite.color.b, fade);
                }

                CanvasGroup canvasGroup = transform.gameObject.GetComponent <CanvasGroup>();

                if (canvasGroup != null)
                {
                    canvasGroup.alpha = fade;
                }

                MeshRenderer meshRenderer = transform.gameObject.GetComponent <MeshRenderer>();

                if (meshRenderer != null)
                {
                    meshRenderer.material.color = new Color(
                        meshRenderer.material.color.r,
                        meshRenderer.material.color.g,
                        meshRenderer.material.color.b, fade
                        );
                }
            }

            if (shouldFadeChildren)
            {
                foreach (Transform childTransform in transform)
                {
                    if (childTransform.gameObject.activeSelf)
                    {
                        Fade(childTransform.transform, fade, shouldFadeChildren);
                    }
                }
            }
        }
示例#10
0
    private void Update()
    {
        if (Input.GetKeyUp(KeyCode.U))
        {
            Time.timeScale = 1f;
        }

        if (PlayerController._instance)
        {
            if (Mathf.Abs(PlayerController._instance.movementVector.x) > 0f)
            {
                shootingLeft = PlayerController._instance.movementVector.x < 0f ? true : false;
            }
        }



        if (Input.GetMouseButtonDown(1))
        {
            RollPastaSelection(true);
            return;
        }

        if (reloadCount > 0f)
        {
            reloadCount -= Time.deltaTime;
            if (reloadCount <= 0f)
            {
                reloadCount = 0f;
            }
        }

        if (PastaManager.Instance.pastaAmounts[currentSelectedPasta] <= 0)
        {
            return;
        }

        if (cooking)
        {
            cookingCount += Time.deltaTime;
            if (cookingCount >= PastaManager.Instance.pastas[currentSelectedPasta].config.cookingSpeed)
            {
                cookedReady = true;
            }

            if (reloadCount <= 0f)
            {
                if (Input.GetMouseButtonUp(0))
                {
                    if (PlayerController._instance)
                    {
                        if (PlayerController._instance.movementVector.x != 0)
                        {
                            Shoot();
                            AnimatorBehaviour.MovingAndShootingAnimations(PlayerController._instance.movementVector);
                        }
                        else
                        {
                            Shoot();
                            AnimatorBehaviour.ShootingAnimations(PlayerController._instance.movementVector);
                        }
                    }
                    else
                    {
                        Shoot();
                    }



                    StartCoroutine("EndAnimations");
                }
            }
        }
        else
        {
            cookedReady  = false;
            cookingCount = 0f;
        }

        if (Input.GetMouseButton(0))
        {
            cooking = true;
            return;
        }
        else
        {
            cookedReady = false;
            cooking     = false;
        }
    }
示例#11
0
    void Start()
    {
        this.animatorBehaviour = GetComponent<AnimatorBehaviour>();
        this.lifeBehaviour = GetComponent<LifeBehaviour>();

        //add content
        this.lifeBehaviour.life = life;
        this.lifeBehaviour.currentLife = this.lifeBehaviour.life;
        this.velocity = Random.Range(1.8f, 2.2f);
    }