Exemplo n.º 1
0
    private IEnumerator TransitionLaserOff()
    {
        GetComponent <Collider>().enabled = false;
        float elapsedTime = 0;
        float ratio       = elapsedTime / duration;


        while (ratio < 1f)
        {
            elapsedTime += Time.deltaTime;
            ratio        = elapsedTime / duration;
            float value = Mathf.Lerp(0f, 1f, TweeningFunctions.EaseOut(ratio));
            material.SetFloat("_TransitionState", value);

            yield return(new WaitForFixedUpdate());
        }

        //mRenderer.enabled = false;
    }
Exemplo n.º 2
0
    private IEnumerator OutputVolumeRoutineOff()
    {
        var start   = _volume;
        var end     = 0f;
        var elapsed = 0f;
        var ratio   = 0f;

        while (elapsed < routineDuration)
        {
            yield return(null);

            elapsed += Time.deltaTime;
            ratio    = elapsed / routineDuration;

            _volume = TweeningFunctions.EaseOut(Mathf.Lerp(start, end, ratio));
        }

        _volume    = end;
        _coroutine = null;
    }
Exemplo n.º 3
0
    IEnumerator TurnToLook(GameObject targetObject)
    {
        state = DroneState.Waiting;

        float      ratio    = 0;
        float      duration = waitDuration;
        float      elapsed  = 0;
        Quaternion begin    = transform.rotation;

        transform.LookAt(targetObject.transform);
        transform.eulerAngles = new Vector3(0, transform.eulerAngles.y, transform.eulerAngles.z);

        Quaternion end = transform.rotation;

        transform.rotation = begin;

        while (ratio < 1)
        {
            yield return(null);

            elapsed += Time.deltaTime;
            ratio    = elapsed / duration;

            transform.rotation = Quaternion.Slerp(begin, end, TweeningFunctions.EaseOut(ratio));
        }

        if (targetObject.GetComponent <SpawnableMutation>())
        {
            state = DroneState.Approaching;

            target = targetObject.GetComponent <SpawnableMutation>();
        }
        else
        {
            state = DroneState.Patrolling;
        }
    }
Exemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        switch (lifePhase)
        {
        case LifeCycle.Waiting:
            if (waitingProgress < waitLength)
            {
                waitingProgress += Time.deltaTime;
            }
            else
            {
                lifePhase = LifeCycle.Growth;
                PrepareAudioLife(GetComponent <AudioSource>());
                scale(startScale);
            }

            break;

        case LifeCycle.Growth:
            if (growthProgess < growthLength)
            {
                float ratio = growthProgess / growthLength;
                scale(Mathf.Lerp(startScale, targetScale, TweeningFunctions.EaseOut(ratio)));

                //using transition state b to change color over grown phase
                //using one minus to go from satring in laser color to landing in real
                mRenderer.GetPropertyBlock(propBlock);
                propBlock.SetFloat("_BeginToBase", TweeningFunctions.EaseOut(ratio));
                mRenderer.SetPropertyBlock(propBlock);

                growthProgess += Time.deltaTime;
            }
            else
            {
                //move to next phase
                lifePhase    = LifeCycle.Life;
                coll.enabled = true;
                movement.Activate();
            }
            break;

        case LifeCycle.Life:
/*
 *              if(lifeProgress < lifeLength)
 *              {
 *                  lifeProgress += Time.deltaTime;
 *              } else
 *              {
 *                  //move to next phase
 *                  lifePhase = LifeCycle.Death;
 *              }
 */
            break;

        case LifeCycle.Death:
            PrepareAudioDeath(GetComponent <AudioSource>());
            movement.Deactivate();
            if (deathProgress < deathLength)
            {
                float ratio = deathProgress / deathLength;
                float scale = Mathf.Lerp(targetScale, 0f, TweeningFunctions.EaseOut(ratio));

                transform.localScale = new Vector3(scale, scale, scale);

                mRenderer.GetPropertyBlock(propBlock);
                propBlock.SetFloat("_BaseToDeath", TweeningFunctions.EaseOut(ratio));
                mRenderer.SetPropertyBlock(propBlock);


                deathProgress += Time.deltaTime;
            }
            else
            {
                this.gameObject.SetActive(false);
            }

            break;
        }
    }