public insert ( float startTime, AbstractGoTween, tween ) : GoTweenFlow, | ||
startTime | float | |
tween | AbstractGoTween, | |
Résultat | GoTweenFlow, |
void Start() { // create a TweenConfig that we will use on all 4 cubes var config = new GoTweenConfig() .setEaseType( GoEaseType.QuadIn ) // set the ease type for the tweens .materialColor( Color.magenta ) // tween the material color to magenta .eulerAngles( new Vector3( 0, 360, 0 ) ) // do a 360 rotation .position( new Vector3( 2, 8, 0 ), true ) // relative position tween so it will be starting from the current location .setIterations( 2, GoLoopType.PingPong ); // 2 iterations with a PingPong loop so we go out and back // create the flow and set it to have 2 iterations var flow = new GoTweenFlow( new GoTweenCollectionConfig().setIterations( 2 ) ); // add a completion handler for the chain flow.setOnCompleteHandler( c => Debug.Log( "flow complete" ) ); // create a Tween for each cube and add it to the flow var startTime = 0f; foreach( var cube in cubes ) { var tween = new GoTween( cube, 0.5f, config ); flow.insert( startTime, tween ); // increment our startTime so that the next tween starts when this one is halfway done startTime += 1.0f; var tweenTwo = new GoTween( cube, 0.5f, config ); flow.insert( startTime, tweenTwo ); startTime += 0.25f; } _tween = flow; }
void Start() { // create a TweenConfig that we will use on all 4 cubes var config = new GoTweenConfig() .setEaseType(GoEaseType.QuadIn) // set the ease type for the tweens .materialColor(Color.magenta) // tween the material color to magenta .eulerAngles(new Vector3(0, 360, 0)) // do a 360 rotation .position(new Vector3(2, 8, 0), true) // relative position tween so it will be start from the current location .setIterations(2, GoLoopType.PingPong); // 2 iterations with a PingPong loop so we go out and back; // create the flow and set it to have 2 iterations var flow = new GoTweenFlow(new GoTweenCollectionConfig().setIterations(2)); // add a completion handler for the chain flow.setOnCompleteHandler(c => Debug.Log("flow complete")); // create a Tween for each cube and it to the flow var startTime = 0f; foreach (var cube in cubes) { var tween = new GoTween(cube, 0.5f, config); flow.insert(startTime, tween); // increment our startTime so that the next tween starts when this one is halfway done startTime += 0.25f; } _tween = flow; }
static AbstractGoTween alphaTween(this GameObject self, bool directionTo, float duration, float endValue, GoEaseType easeType, float delay) { List <GameObject> all = self.GetChilds(GetChildOption.FullHierarchy); all.Add(self); AbstractGoTween tween = null; GoTweenFlow tweens = null; foreach (var v in all) { Renderer r = v.GetComponent <Renderer>(); if (r != null) { Material m = r.material; if (m != null) { if (tween != null) { if (tweens == null) { tweens = new GoTweenFlow(); tweens.insert(0, tween); } } if (directionTo) { tween = m.alphaTo(duration, endValue).eases(easeType); } else { tween = m.alphaFrom(duration, endValue).eases(easeType); } if (tweens != null) { tweens.insert(0, tween); } } } } if (tweens != null) { tweens.delays(delay); Go.addTween(tweens); return(tweens); } else { if (tween != null) { tween.delays(delay); } return(tween); } }
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); }
static public int insert(IntPtr l) { try { GoTweenFlow self = (GoTweenFlow)checkSelf(l); System.Single a1; checkType(l, 2, out a1); AbstractGoTween a2; checkType(l, 3, out a2); var ret = self.insert(a1, a2); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
public static AbstractGoTween colorTo(this GameObject self, float duration, Color endValue, GoEaseType easeType = GoEaseType.Linear) { List <GameObject> all = self.GetChilds(GetChildOption.FullHierarchy); all.Add(self); AbstractGoTween tween = null; GoTweenFlow tweens = null; foreach (var v in all) { if (v.GetComponent <Renderer>() != null) { if (v.GetComponent <Renderer>().material != null) { if (tween != null) { if (tweens == null) { tweens = new GoTweenFlow(); tweens.insert(0, tween); } } tween = v.GetComponent <Renderer>().material.colorTo(duration, endValue); if (tweens != null) { tweens.insert(0, tween); } } } } if (tweens != null) { Go.addTween(tweens); return(tweens); } else { return(tween); } }
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 ); }