IEnumerator EndAnimations() { yield return(new WaitForSeconds(0.06f)); AnimatorBehaviour.GetAnimator(PlayerController._instance.animator); AnimatorBehaviour.StopShootingAnimations(PlayerController._instance.movementVector); }
void Start() { character = GetComponent <CharacterRaycaster>(); timeSinceJumped = 10f; jumpsAllowedLeft = maxJumpsAllowed; AnimatorBehaviour.GetAnimator(animator); }
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; } } } } }
void PostMovementJumpUpdate() { if (isGrounded) { AnimatorBehaviour.CancelJumpAnimations(); isJumping = false; jumpsAllowedLeft = maxJumpsAllowed; } }
void TryJump() { if (jumpsAllowedLeft == 0) { return; } if (hasBag) { return; } jumpsAllowedLeft--; StartJump(); AnimatorBehaviour.JumpAnimations(movementVector); }
/// <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); }
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); }
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(); } }
/// <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); } } } }
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; } }
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); }