示例#1
0
    void Update()
    {
        _rb.velocity = Vector3.zero;

        if (!_isInDialogue)
        {
            _rb.velocity = (transform.forward * Input.GetAxis("Vertical") + transform.right * Input.GetAxis("Horizontal")) * playerSpeed;

            if (_rb.velocity.x != 0 || _rb.velocity.z != 0)
            {
                _sprite.SetFloat("LastX", _rb.velocity.normalized.x);
                _sprite.SetFloat("LastZ", _rb.velocity.normalized.z);
            }
        }

        if (Input.GetButtonDown("Interact"))
        {
            //print("Interact");
            if (_canInteract && !_isInDialogue)
            {
                _isInDialogue = true;
                StartCoroutine(dialogueCanvasGroup.Fade(0.5f, true));
                dialogueSystem.SetDialogueToRun(_interactableNPC.dialogue);
                dialogueSystem.RunDialogue();
                StartCoroutine(WaitForDialogueEndAndFade());
            }
        }
    }
示例#2
0
        public void OnPointerEnter(PointerEventData eventData)
        {
            if (eventData.button != PointerEventData.InputButton.Left)
            {
                return;
            }

            StopAllCoroutines();
            StartCoroutine(m_CanvasGroup.Fade(OnHoverAlpha, FadeTime));
            m_OnHover.Invoke();
        }
示例#3
0
    // Kill me now!
    IEnumerator Animate(AnswerData result)
    {
        Result.GetOrAddComponent <CanvasGroup>().Fade(0f, 1f, 0.5f);

        yield return(new WaitForSeconds(TimeBeforeShowAnswer));

        Answer.gameObject.SetActive(true);
        Answer.text = string.Format("{0}", result.Answer);

        yield return(new WaitForSeconds(TimeBeforeShowChosenBy));

        Divider.gameObject.SetActive(true);
        Divider.Fade(0f, 1f, 0.1f);
        ChosenBy.gameObject.SetActive(true);
        ChosenBy.gameObject.GetOrAddComponent <CanvasGroup>().Fade(0f, 1f, 0.1f);

        yield return(new WaitForSeconds(TimeBeforePlayersReveal));

        float revealTime = TimeToRevealPlayers / result.Choosers.Count;

        foreach (var player in result.Choosers)
        {
            yield return(new WaitForSeconds(revealTime));

            var instance = UiUtility.AddChild(Rows, RowPrototype, true);
            instance.PlayerName.text = player.Name;
            instance.gameObject.GetOrAddComponent <CanvasGroup>().Scale(Vector3.one * 5, Vector3.one, 0.2f);
            resultViews.Add(instance.gameObject);
        }

        if (result.Type != GameAnswerType.ActualAnswer)
        {
            yield return(new WaitForSeconds(TimeBeforeAuthorReveal));
        }
        else
        {
            yield return(new WaitForSeconds(TimeBeforeActualAnswerReveal));
        }

        Author.gameObject.SetActive(true);
        Author.gameObject.GetOrAddComponent <CanvasGroup>().Fade(0f, 1f, TimeAuthorFade);
        Author.gameObject.GetOrAddComponent <CanvasGroup>().Scale(new Vector3(5f, 5f, 1f), Vector3.one, TimeAuthorScale);

        if (result.Type == GameAnswerType.Player)
        {
            Author.text = string.Format(Strings.Result.PlayerAnswer, result.Author.Name);
            yield return(new WaitForSeconds(TimeBeforeScoreReveal));

            Points.gameObject.SetActive(true);
            Points.text = string.Format("+{0}", result.Points.ToString());
            Points.gameObject.GetOrAddComponent <CanvasGroup>().Fade(0f, 1f, TimeScoreFade);
            Points.gameObject.GetOrAddComponent <CanvasGroup>().Scale(new Vector3(5f, 5f, 1f), Vector3.one, TimeScoreScale);
        }
        else if (result.Type == GameAnswerType.Decoy)
        {
            Author.text = Strings.Result.Decoy;
            yield return(new WaitForSeconds(TimeBeforeScoreReveal));
        }
        else
        {
            Author.text = string.Format(Strings.Result.ActualAnswer);
            yield return(new WaitForSeconds(TimeBeforeScoreReveal));
        }

        if (result.Type != GameAnswerType.ActualAnswer)
        {
            yield return(new WaitForSeconds(TimeBeforeShowNextResult));
        }
        else
        {
            yield return(new WaitForSeconds(TimeAfterActualAnswerReveal));
        }

        Result.GetOrAddComponent <CanvasGroup>().Fade(1f, 0f, TimeFadeAfterResult);

        yield return(new WaitForSeconds(TimeFadeAfterResult));

        if (OnFinishedShowingResult != null)
        {
            OnFinishedShowingResult();
        }

        yield return(0);
    }
 public override BaseTween Play()
 {
     return(cg.Fade(targetAlpha, time).SetEase(ease));
 }
示例#5
0
 /// <summary>
 /// Adds a UIFadeAnimation to the collection using a CanvasGroup
 /// </summary>
 /// <param name="animationCollection">The animation collection to add to</param>
 /// <param name="canvasGroup">The CanvasGroup who's alpha will be faded</param>
 /// <param name="from">The start alpha value of the fade</param>
 /// <param name="to">The end alpha value of the fade</param>
 /// <param name="duration">The duration of the animation in seconds, defaults to 1f</param>
 /// <param name="easingFunction">The easing function that will be used to interpolate with</param>
 /// <returns>Returns this AnimationCollection to comply with fluent interface</returns>
 public static AnimationCollection Fade(this AnimationCollection animationCollection, CanvasGroup canvasGroup, float from, float to, float duration = 1f, Func <float, float> easingFunction = null)
 {
     return(animationCollection.Add(canvasGroup.Fade(from, to, duration, easingFunction)));
 }