/// <summary>
 /// Do the fade out. Can be called manually or if fadeOnTrigger is true when the trigger is hit.
 /// </summary>
 public void DoFade()
 {
     StartCoroutine(CoroutineFactory.Create(duration, time =>
     {
         targetCanvasGroup.alpha = time;
     }));
 }
示例#2
0
 private IEnumerator MoveElevator(int i, int currentFloor)
 {
     return(CoroutineFactory.Create(Mathf.Abs(i - currentFloor) * duration, time =>
     {
         transform.position = Vector3.Lerp(startPosition, endPosition, time);
     }));
 }
示例#3
0
    public void DoFadeOut()
    {
        var            curve       = CurveFactory.Create(1f, 0f);
        Action <float> fadeOut     = (t) => canvasGroup.alpha = curve.Evaluate(t);
        Action <float> scaleCanvas = (t) => obj.transform.localScale = new Vector3(curve.Evaluate(t), curve.Evaluate(t), curve.Evaluate(t));
        Action <float> combined    = fadeOut + scaleCanvas;

        StartCoroutine(CoroutineFactory.Create(duration, combined));
    }
    void Update()
    {
        if (insideHitBox && !elevatorCalled && Input.GetButtonUp("Fire1"))
        {
            elevatorCalled = true;

            elevator.MoveElevator();
            StartCoroutine(CoroutineFactory.Create(1f, time =>
            {
                infoText.alpha = 1f - time;
            }));
        }
    }
    void OnTriggerExit(Collider other)
    {
        if (elevatorCalled)
        {
            return;
        }

        insideHitBox = false;
        StartCoroutine(CoroutineFactory.Create(0.25f, time =>
        {
            infoText.alpha = 1f - time;
        }));
    }
    public void Shake()
    {
        button.interactable = false;
        phraseBox.text      = phrases.Random();

        var alphaFade = CurveFactory.Create(0f, 1f);
        var scaleFade = CurveFactory.Create(0.5f, 1f);

        Action <float> alphaTick = (t) => phraseBox.SetAlpha(alphaFade.Evaluate(t));
        Action <float> scaleTick = (t) => phraseBox.SetScale(scaleFade.Evaluate(t));


        StartCoroutine(CoroutineFactory.Create(1f, alphaTick + scaleTick, () => button.interactable = true));
    }
    private IEnumerator MoveElevator(bool onGroundFloor)
    {
        Vector3 start = onGroundFloor ? startPostion : endPostion;
        Vector3 end   = onGroundFloor ? endPostion : startPostion;

        running = true;

        return(CoroutineFactory.Create(duration, time =>
        {
            transform.position = Vector3.Lerp(start, end, time);
        },
                                       () =>
        {
            running = false;
            this.onStartFloor = !this.onStartFloor;
        }));
    }