Example #1
0
    private IEnumerator ChargeStomp_Coroutine(Vector3 direction)
    {
        _chargeStomp = true;
        bool         effect = false;
        GoTweenChain chain  = new GoTweenChain();
        GameObject   stomp  = GameObject.CreatePrimitive(PrimitiveType.Cube);

        stomp.GetComponent <MeshRenderer>().material = attackMaterial;
        stomp.transform.localScale = Vector3.zero;

        Go.to(body, chargeStompFXDuration * 0.3f, new GoTweenConfig().localPosition(Vector3.up * 0.5f, true).setEaseType(GoEaseType.BackOut));
        Go.to(body, chargePunchFXDuration * 0.3f, new GoTweenConfig().rotation(Quaternion.LookRotation(direction)));

        yield return(new WaitForSeconds(chargeStompFXDuration * 0.3f));

        Go.to(body, chargeStompFXDuration * 0.7f, new GoTweenConfig().localPosition(Vector3.zero).setEaseType(GoEaseType.BackOut));
        float time = 0;

        while (chargeStompFXDuration * 0.7f > time)
        {
            if (!effect && time > chargeStompFXDuration * 0.2f)
            {
                effect = true;
                stomp.transform.position = transform.position + (Vector3.down * 0.25f);

                GoTween effectGrow   = new GoTween(stomp.transform, 0.2f, new GoTweenConfig().scale(new Vector3(3, 0.5f, 3)).setEaseType(GoEaseType.BackOut));
                GoTween effectShrink = new GoTween(stomp.transform, 1f, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn));
                chain.append(effectGrow);
                chain.append(effectShrink);
                chain.play();
            }

            time += Time.deltaTime;
            yield return(null);
        }

        yield return(chain.waitForCompletion());

        Destroy(stomp);

        yield return(new WaitForSeconds(chargeStompRecoverTime));

        Go.to(body.GetChild(0).GetComponent <MeshRenderer>(), 0.2f, new GoTweenConfig().materialColor(new Color(62f / 255f, 1f, 0)));
        _chargeStomp = false;
    }
Example #2
0
    private IEnumerator ChargeStomp_Coroutine ( Vector3 direction )
    {
        _chargeStomp = true;
        bool effect = false;
        GoTweenChain chain = new GoTweenChain();
        GameObject stomp = GameObject.CreatePrimitive( PrimitiveType.Cube );
        stomp.GetComponent<MeshRenderer>().material = attackMaterial;
        stomp.transform.localScale = Vector3.zero;

        Go.to( body , chargeStompFXDuration * 0.3f , new GoTweenConfig().localPosition( Vector3.up * 0.5f , true ).setEaseType( GoEaseType.BackOut ) );
        Go.to( body , chargePunchFXDuration * 0.3f , new GoTweenConfig().rotation( Quaternion.LookRotation( direction ) ) );

        yield return new WaitForSeconds( chargeStompFXDuration * 0.3f );

        Go.to( body , chargeStompFXDuration * 0.7f , new GoTweenConfig().localPosition( Vector3.zero ).setEaseType( GoEaseType.BackOut ) );
        float time = 0;

        while ( chargeStompFXDuration * 0.7f > time )
        {
            if ( !effect && time > chargeStompFXDuration * 0.2f )
            {
                effect = true;
                stomp.transform.position = transform.position + ( Vector3.down * 0.25f );

                GoTween effectGrow = new GoTween( stomp.transform , 0.2f , new GoTweenConfig().scale( new Vector3( 3 , 0.5f , 3 ) ).setEaseType( GoEaseType.BackOut ) );
                GoTween effectShrink = new GoTween( stomp.transform , 1f , new GoTweenConfig().scale( Vector3.zero ).setEaseType( GoEaseType.ExpoIn ) );
                chain.append( effectGrow );
                chain.append( effectShrink );
                chain.play();
            }

            time += Time.deltaTime;
            yield return null;
        }

        yield return chain.waitForCompletion();
        Destroy( stomp );

        yield return new WaitForSeconds( chargeStompRecoverTime );
        Go.to( body.GetChild( 0 ).GetComponent<MeshRenderer>() , 0.2f , new GoTweenConfig().materialColor( new Color( 62f / 255f , 1f , 0 ) ) );
        _chargeStomp = false;
    }