private IEnumerator ChargePush_Coroutine(Vector3 direction) { _chargePush = true; GameObject punch = GameObject.CreatePrimitive(PrimitiveType.Cube); punch.GetComponent <MeshRenderer>().material = attackMaterial; punch.transform.position = transform.position + direction; punch.transform.localScale = Vector3.one; float speed = chargePushFXSpeed; bool tweenPlaying = true; float time = 0; Vector3 dirToPush = direction + (Vector3.down * 0.25f); dirToPush.Normalize(); Quaternion rot = Quaternion.LookRotation(dirToPush); GoTweenFlow flow = new GoTweenFlow(); GoTween punchTween = Go.to(punch.transform, chargePushFXDuration, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn).onComplete(c => tweenPlaying = false)); flow.insert(0, punchTween); Go.killAllTweensWithTarget(body); GoTween rotationTween = new GoTween(body, chargePushFXDuration * 0.15f, new GoTweenConfig().rotation(rot).setEaseType(GoEaseType.ExpoOut).setIterations(2, GoLoopType.PingPong)); flow.insert(0, rotationTween); flow.play(); while (tweenPlaying) { time += Time.deltaTime; punch.transform.position += direction * speed * Time.deltaTime; speed *= chargePunchFXSpeedIncrement; yield return(null); } yield return(new WaitForSeconds(chargePushRecoverTime)); Go.to(body.GetChild(0).GetComponent <MeshRenderer>(), 0.2f, new GoTweenConfig().materialColor(new Color(62f / 255f, 1f, 0))); body.transform.localPosition = Vector3.zero; Destroy(punch); _chargePush = false; }
private IEnumerator Punch_Coroutine(Vector3 direction) { GameObject punch = GameObject.CreatePrimitive(PrimitiveType.Cube); punch.GetComponent <MeshRenderer>().material = attackMaterial; punch.transform.position = transform.position + ((_right ? body.TransformDirection(Vector3.right) : body.TransformDirection(Vector3.left)) * 0.35f); punch.transform.localScale = Vector3.one * 0.5f; float speed = punchFXSpeed; bool tweenPlaying = true; _right = !_right; Vector3 dirToPunch = body.transform.TransformDirection(Vector3.forward) + ((_right ? body.TransformDirection(Vector3.right) : body.TransformDirection(Vector3.left)) * 0.25f); dirToPunch.y = 0; dirToPunch.Normalize(); Quaternion rot = Quaternion.LookRotation(dirToPunch); GoTweenFlow flow = new GoTweenFlow(); GoTween punchTween = Go.to(punch.transform, punchFXDuration, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn).onComplete(c => tweenPlaying = false)); flow.insert(0, punchTween); Go.killAllTweensWithTarget(body); GoTween rotationTween = new GoTween(body, punchFXDuration * 0.4f, new GoTweenConfig().rotation(rot).setEaseType(GoEaseType.ExpoOut).setIterations(2, GoLoopType.PingPong)); flow.insert(0, rotationTween); flow.play(); while (tweenPlaying) { punch.transform.position += direction * speed * Time.deltaTime; speed *= punchFXSpeedIncrement; yield return(null); } Destroy(punch); }
private IEnumerator ChargePunch_Coroutine(Vector3 direction) { _chargePunch = true; GameObject punch = GameObject.CreatePrimitive(PrimitiveType.Cube); punch.GetComponent <MeshRenderer>().material = attackMaterial; punch.transform.position = transform.position + direction; punch.transform.localScale = Vector3.one * 0.75f; float speed = chargePunchFXSpeed; bool tweenPlaying = true; bool atTop = false; bool falling = false; float time = 0; Vector3 dirToPunch = direction + (Vector3.up * 0.25f); dirToPunch.Normalize(); Quaternion rot = Quaternion.LookRotation(dirToPunch); GoTweenFlow flow = new GoTweenFlow(); GoTween punchTween = Go.to(punch.transform, chargePunchFXDuration, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn).onComplete(c => tweenPlaying = false)); flow.insert(0, punchTween); Go.killAllTweensWithTarget(body); GoTween rotationTween = new GoTween(body, chargePunchFXDuration * 0.3f, new GoTweenConfig().rotation(rot).setEaseType(GoEaseType.ExpoOut).setIterations(2, GoLoopType.PingPong)); GoTween jumpTween = new GoTween(body, chargePunchFXDuration * 0.6f, new GoTweenConfig().localPosition(Vector3.up * 1.5f, true).setEaseType(GoEaseType.BackOut)); GoTween landTween = new GoTween(body, chargePunchFXDuration * 0.15f, new GoTweenConfig().localPosition(Vector3.down * 1.5f, true).setEaseType(GoEaseType.QuadIn).onBegin(c => falling = true)); flow.insert(0, rotationTween); flow.insert(0, jumpTween); flow.insert(chargePunchFXDuration * 0.85f, landTween); flow.play(); while (tweenPlaying) { time += Time.deltaTime; punch.transform.position += Vector3.up * speed * Time.deltaTime; speed *= chargePunchFXSpeedIncrement; if (time > chargePunchFXDuration * 0.5f) { atTop = true; } if (!_chargeStomp && atTop && !falling && Input.GetMouseButtonDown(1)) { Go.killAllTweensWithTarget(body); StartCoroutine(ChargeStomp_Coroutine(direction)); } yield return(null); } yield return(new WaitForSeconds(chargePunchRecoverTime)); if (!_chargeStomp) { Go.to(body.GetChild(0).GetComponent <MeshRenderer>(), 0.2f, new GoTweenConfig().materialColor(new Color(62f / 255f, 1f, 0))); body.transform.localPosition = Vector3.zero; } Destroy(punch); _chargePunch = false; }
private IEnumerator ChargePush_Coroutine ( Vector3 direction ) { _chargePush = true; GameObject punch = GameObject.CreatePrimitive( PrimitiveType.Cube ); punch.GetComponent<MeshRenderer>().material = attackMaterial; punch.transform.position = transform.position + direction; punch.transform.localScale = Vector3.one; float speed = chargePushFXSpeed; bool tweenPlaying = true; float time = 0; Vector3 dirToPush = direction + ( Vector3.down * 0.25f ); dirToPush.Normalize(); Quaternion rot = Quaternion.LookRotation( dirToPush ); GoTweenFlow flow = new GoTweenFlow(); GoTween punchTween = Go.to( punch.transform , chargePushFXDuration , new GoTweenConfig().scale( Vector3.zero ).setEaseType( GoEaseType.ExpoIn ).onComplete( c => tweenPlaying = false ) ); flow.insert( 0 , punchTween ); Go.killAllTweensWithTarget( body ); GoTween rotationTween = new GoTween( body , chargePushFXDuration * 0.15f , new GoTweenConfig().rotation( rot ).setEaseType( GoEaseType.ExpoOut ).setIterations( 2 , GoLoopType.PingPong ) ); flow.insert( 0 , rotationTween ); flow.play(); while ( tweenPlaying ) { time += Time.deltaTime; punch.transform.position += direction * speed * Time.deltaTime; speed *= chargePunchFXSpeedIncrement; yield return null; } yield return new WaitForSeconds( chargePushRecoverTime ); Go.to( body.GetChild( 0 ).GetComponent<MeshRenderer>() , 0.2f , new GoTweenConfig().materialColor( new Color( 62f / 255f , 1f , 0 ) ) ); body.transform.localPosition = Vector3.zero; Destroy( punch ); _chargePush = false; }
private IEnumerator ChargePunch_Coroutine ( Vector3 direction ) { _chargePunch = true; GameObject punch = GameObject.CreatePrimitive( PrimitiveType.Cube ); punch.GetComponent<MeshRenderer>().material = attackMaterial; punch.transform.position = transform.position + direction; punch.transform.localScale = Vector3.one * 0.75f; float speed = chargePunchFXSpeed; bool tweenPlaying = true; bool atTop = false; bool falling = false; float time = 0; Vector3 dirToPunch = direction + ( Vector3.up * 0.25f ); dirToPunch.Normalize(); Quaternion rot = Quaternion.LookRotation( dirToPunch ); GoTweenFlow flow = new GoTweenFlow(); GoTween punchTween = Go.to( punch.transform , chargePunchFXDuration , new GoTweenConfig().scale( Vector3.zero ).setEaseType( GoEaseType.ExpoIn ).onComplete( c => tweenPlaying = false ) ); flow.insert( 0 , punchTween ); Go.killAllTweensWithTarget( body ); GoTween rotationTween = new GoTween( body , chargePunchFXDuration * 0.3f , new GoTweenConfig().rotation( rot ).setEaseType( GoEaseType.ExpoOut ).setIterations( 2 , GoLoopType.PingPong ) ); GoTween jumpTween = new GoTween( body , chargePunchFXDuration * 0.6f , new GoTweenConfig().localPosition( Vector3.up * 1.5f , true ).setEaseType( GoEaseType.BackOut ) ); GoTween landTween = new GoTween( body , chargePunchFXDuration * 0.15f , new GoTweenConfig().localPosition( Vector3.down * 1.5f , true ).setEaseType( GoEaseType.QuadIn ).onBegin( c => falling = true ) ); flow.insert( 0 , rotationTween ); flow.insert( 0 , jumpTween ); flow.insert( chargePunchFXDuration * 0.85f , landTween ); flow.play(); while ( tweenPlaying ) { time += Time.deltaTime; punch.transform.position += Vector3.up * speed * Time.deltaTime; speed *= chargePunchFXSpeedIncrement; if ( time > chargePunchFXDuration * 0.5f ) atTop = true; if ( !_chargeStomp && atTop && !falling && Input.GetMouseButtonDown( 1 ) ) { Go.killAllTweensWithTarget( body ); StartCoroutine( ChargeStomp_Coroutine( direction ) ); } yield return null; } yield return new WaitForSeconds( chargePunchRecoverTime ); if ( !_chargeStomp ) { Go.to( body.GetChild( 0 ).GetComponent<MeshRenderer>() , 0.2f , new GoTweenConfig().materialColor( new Color( 62f / 255f , 1f , 0 ) ) ); body.transform.localPosition = Vector3.zero; } Destroy( punch ); _chargePunch = false; }
private IEnumerator Punch_Coroutine ( Vector3 direction ) { GameObject punch = GameObject.CreatePrimitive( PrimitiveType.Cube ); punch.GetComponent<MeshRenderer>().material = attackMaterial; punch.transform.position = transform.position + ( ( _right ? body.TransformDirection( Vector3.right ) : body.TransformDirection( Vector3.left ) ) * 0.35f ); punch.transform.localScale = Vector3.one * 0.5f; float speed = punchFXSpeed; bool tweenPlaying = true; _right = !_right; Vector3 dirToPunch = body.transform.TransformDirection( Vector3.forward ) + ( ( _right ? body.TransformDirection( Vector3.right ) : body.TransformDirection( Vector3.left ) ) * 0.25f ); dirToPunch.y = 0; dirToPunch.Normalize(); Quaternion rot = Quaternion.LookRotation( dirToPunch ); GoTweenFlow flow = new GoTweenFlow(); GoTween punchTween = Go.to( punch.transform , punchFXDuration , new GoTweenConfig().scale( Vector3.zero ).setEaseType( GoEaseType.ExpoIn ).onComplete( c => tweenPlaying = false ) ); flow.insert( 0 , punchTween ); Go.killAllTweensWithTarget( body ); GoTween rotationTween = new GoTween( body , punchFXDuration * 0.4f , new GoTweenConfig().rotation( rot ).setEaseType( GoEaseType.ExpoOut ).setIterations( 2 , GoLoopType.PingPong ) ); flow.insert( 0 , rotationTween ); flow.play(); while ( tweenPlaying ) { punch.transform.position += direction * speed * Time.deltaTime; speed *= punchFXSpeedIncrement; yield return null; } Destroy( punch ); }