void GotoNextPoint() { destPoint = Random.Range(0, 3); if (points.Length == 0) { return; } if (checkForCheater == 0) { agent.destination = points[destPoint].position; } else if (checkForCheater == 1) { GoTween t1 = new GoTween(dangerIndicator.transform, 0.7f, new GoTweenConfig().scale(new Vector3(40f, 0.001f, 40f))); GoTween t2 = new GoTween(dangerIndicator.transform, 0.7f, new GoTweenConfig().scale(new Vector3(0.2f, 0.001f, 0.2f))); GoTweenChain chain = new GoTweenChain().append(t1).append(t2); chain.play(); agent.destination = points[destPoint].position; checkForCheater = 0; } checkForCheater = Random.Range(0, 2); }
public void TweenText(Transform t) { Debug.Log("Tweening text " + t.name); GoTweenChain chain = new GoTweenChain(); chain.append(Go.to(t, 0.5f, new GoTweenConfig().position(Vector3.down * 5, true).setEaseType(GoEaseType.QuadInOut))); chain.appendDelay(1); chain.append(Go.to(t, 0.5f, new GoTweenConfig().position(Vector3.up * 5, true).setEaseType(GoEaseType.QuadInOut))); chain.play(); }
private IEnumerator Blink_Coroutine(Vector3 direction, Vector3 mousePos, bool charge) { _blink = true; Vector3 pos = transform.position; pos.y = 0; mousePos.y = 0; Vector3 bodyScale = body.localScale; float yPos = transform.position.y; Go.to(body, 0.25f, new GoTweenConfig().scale(Vector3.one * 0.25f).setEaseType(GoEaseType.BackIn)); yield return(new WaitForSeconds(0.25f)); Vector3 newPos = mousePos; newPos.y = yPos; Go.to(transform, 0.5f, new GoTweenConfig().position(newPos).setEaseType(GoEaseType.BackInOut)); yield return(new WaitForSeconds(0.5f)); transform.position = newPos; Go.to(body, 0.25f, new GoTweenConfig().scale(bodyScale).setEaseType(GoEaseType.BackOut)); if (charge) { GameObject punch = GameObject.CreatePrimitive(PrimitiveType.Cube); punch.GetComponent <MeshRenderer>().material = attackMaterial; punch.transform.position = transform.position; punch.transform.localScale = Vector3.zero; GoTweenChain chain = new GoTweenChain(); GoTween growTween = Go.to(punch.transform, chargeBlinkFXTime * 0.25f, new GoTweenConfig().scale(Vector3.one * 3).setEaseType(GoEaseType.BackOut)); GoTween shrinkTween = Go.to(punch.transform, chargeBlinkFXTime * 0.75f, new GoTweenConfig().scale(Vector3.zero).setEaseType(GoEaseType.ExpoIn)); chain.append(growTween); chain.append(shrinkTween); chain.play(); yield return(new WaitForSeconds(chargeBlinkFXTime)); yield return(new WaitForSeconds(blinkRecoverTime)); } else { yield return(new WaitForSeconds(0.25f)); } Go.killAllTweensWithTarget(body.GetChild(0).GetComponent <MeshRenderer>()); Go.to(body.GetChild(0).GetComponent <MeshRenderer>(), 0.2f, new GoTweenConfig().materialColor(new Color(62f / 255f, 1f, 0))); _blink = false; }
void playSounds(List <KeyValuePair <string, int> > sortedSounds, List <AudioClip> clips) { AudioSource[] src = this.gameObject.GetComponents <AudioSource> (); audioGtc = new GoTweenChain(); audioGtc.autoRemoveOnComplete = true; float accTime = 0; _curClipIndex = 0; for (int i = 0; i < sortedSounds.Count; ++i) { var sd = sortedSounds [i]; float delay = sd.Value / 24.0f - accTime; if (delay > 0) { audioGtc.appendDelay(delay); } var cbcon = new GoTweenConfig(); audioGtc.append(new GoTween( gameObject.transform, 0.01f, cbcon.onComplete(delegate(AbstractGoTween obj) { int ri = _curClipIndex % maxChannels; src [ri].clip = clips [_curClipIndex]; src [ri].loop = false; src [ri].spatialBlend = 0; src [ri].Play(); ++_curClipIndex; }) )); accTime += delay; } // for some reason the last play callback // is not invoked, so I add one more tween // to ensure the last sound is played. audioGtc.appendDelay(0.5f); GoTweenConfig gtcfg = new GoTweenConfig(); audioGtc.append(new GoTween( gameObject.transform, 0.01f, gtcfg.onComplete(delegate(AbstractGoTween obj) { }) )); audioGtc.play(); }
public void MoveWindow(int easeType) { switch (easeType) { case 0: Go.defaultEaseType = GoEaseType.Linear; break; case 1: Go.defaultEaseType = GoEaseType.BackOut; break; case 2: Go.defaultEaseType = GoEaseType.BounceOut; break; case 3: Go.defaultEaseType = GoEaseType.CircInOut; break; case 4: Go.defaultEaseType = GoEaseType.SineOut; break; default: Go.defaultEaseType = GoEaseType.Linear; break; } float move = 0; if (goScreen) { move = -length; } else { move = length; } var moveUpConfig = new GoTweenConfig().position(new Vector3(move, 0), true); moveUpConfig.onComplete(orginalTween => Done()); var tweenOne = new GoTween(this.transform, duration, moveUpConfig); var chain = new GoTweenChain(); chain.append(tweenOne); chain.play(); }
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; }
internal static GoTweenChain animateJellyInfinite(this Transform transform, float time, float value, GoEaseType ease = GoEaseType.QuadInOut) { GoTweenChain chain = new GoTweenChain(); Vector3 scaleAtStart = transform.localScale; Vector3 target = new Vector3(scaleAtStart.x - value, scaleAtStart.y + value, scaleAtStart.z); transform.localScale = target; target = new Vector3(scaleAtStart.x + value, scaleAtStart.y - value, scaleAtStart.z); chain.append(transform.scaleTo(time, target).eases(ease)); target = new Vector3(scaleAtStart.x - value, scaleAtStart.y + value, scaleAtStart.z); chain.append(transform.scaleTo(time, target).eases(ease)); chain.loopCount = -1; chain.play(); return(chain); }
IEnumerator DoEffect() { while (base.isActive()) { float lightningDuration = Random.Range(m_minFlashDuration, m_maxFlashDuration ); float delayUntilNextFlash = Random.Range(0.21f, 1.5f); gtc = new GoTweenChain(); gtc.append(Go.to(m_lightningSprite, lightningDuration, new GoTweenConfig().colorProp("color", new Color(1, 1, 1, Random.Range(m_minLightningOpacity, m_maxLightningOpacity))))); gtc.append(Go.to(m_lightningSprite, lightningDuration, new GoTweenConfig().colorProp("color", new Color(1, 1, 1, 0)))); gtc.autoRemoveOnComplete = true; lightningDuration = (2*lightningDuration ) + delayUntilNextFlash; gtc.appendDelay(delayUntilNextFlash); gtc.play(); //Go.to(m_lightningSprite, 0, new GoTweenConfig().colorProp("color", new Color(1, 1, 1, Random.Range(m_minLightningOpacity, m_maxLightningOpacity)))); //m_lightningSprite //transform.shake(shakeDuration, new Vector3(m_shakeAmount, m_shakeAmount)); yield return new WaitForSeconds(lightningDuration); } }
internal static GoTweenChain animateJelly(this Transform transform, float time, float value, int repeatCount = 1, GoEaseType ease = GoEaseType.QuadInOut) { Vector3 scaleAtStart = transform.localScale; GoTweenChain chain = new GoTweenChain(); for (int i = repeatCount; i > 0; i--) { float factor = ((float)i) / repeatCount; Vector3 target = new Vector3(scaleAtStart.x + (value * factor), scaleAtStart.y - (value * factor), scaleAtStart.z); chain.append(transform.scaleTo(time * factor, target).eases(ease)); target = new Vector3(scaleAtStart.x - (value * factor), scaleAtStart.y + (value * factor), scaleAtStart.z); chain.append(transform.scaleTo(time * factor, target).eases(ease)); } chain.append(transform.scaleTo(time / repeatCount, scaleAtStart).eases(ease)); chain.play(); return(chain); }
IEnumerator SwimAway() { anim.SetBool("TurnBool", true); anim.SetBool("SwimmingBool", false); yield return(new WaitForSeconds(2f)); var config = new GoTweenConfig().localPosition(origPosition); var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1)); chain.setOnCompleteHandler( c => MoveBack()); var tween = new GoTween(transform, 4f, config); chain.append(tween); chain.play(); MonsterStabbed.Invoke(); }
private static void TweenLetter(GameObject letter, Vector3 location, float initialDelay) { float y = location.y; float z = location.z; Vector3 start = new Vector3(-15.0f, y + Random.Range(-2.0f, 2.0f), z); Vector3 end = new Vector3(15.0f, y + Random.Range(-2.0f, 2.0f), z); letter.transform.position = start; var tweenIn = new GoTween(letter.transform, 0.5f, new GoTweenConfig().position(location)); var tweenOut = new GoTween(letter.transform, 0.5f, new GoTweenConfig().position(end)); var chain = new GoTweenChain(); chain.appendDelay(initialDelay) .append(tweenIn) .appendDelay(1.0f) .append(tweenOut); chain.play(); }
public void ScaleWindow() { if (goScreen) { Go.defaultEaseType = GoEaseType.BounceOut; scale = Vector3.one; } else { Go.defaultEaseType = GoEaseType.BounceIn; scale = Vector3.zero; } var scaleConfig = new GoTweenConfig().scale(scale, false); scaleConfig.onComplete(orginalTween => ScaleDone()); var tweenOne = new GoTween(this.transform, duration, scaleConfig); var chain = new GoTweenChain(); chain.append(tweenOne); chain.play(); }
public void PerformAttack(int attackIndex) { if (glorten.ReadyToAttack) { int[] damages = glorten.PerformAttack(attackIndex); bossFight.currentAttackDamage = Random.Range(damages[0], damages[1] + 1); //special cases switch (attackIndex) { case 0: //normal attack Vector3 attackBossPosition = new Vector3(glorten.transform.localPosition.x, glorten.transform.localPosition.y, 1.0f); //move Go.to(glorten.transform, 0.4f, new GoTweenConfig() .localPosition(attackBossPosition) .setEaseType(GoEaseType.Linear) .setIterations(2, GoLoopType.PingPong) .onIterationEnd(tween => { if (tween.completedIterations < 2) { bossFight.DamageBoss(null); } } ) .onComplete(bossFight.ChangeTurn)); break; case 1: //heal Transform healSpell = glorten.transform.Find("HealSpell"); //make decal appear Transform Decal = healSpell.Find("Decal"); if (Decal != null) { SpriteRenderer sr = Decal.gameObject.GetComponent <SpriteRenderer>(); sr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); sr.transform.localScale = new Vector3(0.4f, 0.4f, 1.0f); Go.to(sr, 5.0f, new GoTweenConfig() .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f)) .setEaseType(GoEaseType.SineOut) .onComplete(tween => { Go.to(sr, 0.5f, new GoTweenConfig() .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 0.0f)) .setEaseType(GoEaseType.SineIn) ); Go.to(sr.transform, 0.5f, new GoTweenConfig() .scale(new Vector3(0.1f, 0.1f, 1.0f)) .setEaseType(GoEaseType.SineIn) ); bossFight.HealPlayer(null); bossFight.ChangeTurn(null); }) ); } //launch particles ParticleSystem[] particles = healSpell.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem ps in particles) { ps.Play(); } //rotate whole group healSpell.localScale = new Vector3(0.6f, 1.0f, 0.6f); Go.to(healSpell, 5.0f, new GoTweenConfig() .localRotation(new Vector3(0, 1440f, 0), true) .scale(1.0f) .setEaseType(GoEaseType.Linear)); break; case 2: //fire attack Transform fireSpell = glorten.transform.Find("FireSpell"); //rotate fireSpell Go.to(fireSpell, 10.0f, new GoTweenConfig() .localRotation(new Vector3(0, 1440f, 0), true) .scale(1.0f) .setEaseType(GoEaseType.Linear)); //make decal appear Transform fireDecal = fireSpell.Find("Decal"); if (fireDecal != null) { SpriteRenderer sr = fireDecal.gameObject.GetComponent <SpriteRenderer>(); sr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); sr.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f); Go.to(sr, 10.0f, new GoTweenConfig() .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f)) .setEaseType(GoEaseType.SineOut) .onComplete(tween => { Go.to(sr, 0.5f, new GoTweenConfig() .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 0.0f)) .setEaseType(GoEaseType.SineIn) ); Go.to(sr.transform, 0.5f, new GoTweenConfig() .scale(new Vector3(0.1f, 0.1f, 1.0f)) .setEaseType(GoEaseType.SineIn) .onComplete(bossFight.ChangeTurn) ); }) ); } //launch particles ParticleSystem[] fireParticles = fireSpell.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem ps in fireParticles) { ps.Play(); } int fireball1Damage = (bossFight.currentAttackDamage / 7) * 1; int fireball2Damage = (bossFight.currentAttackDamage / 7) * 2; int fireball3Damage = (bossFight.currentAttackDamage / 7) * 4; //fireball1 Transform fireBall1 = fireSpell.Find("FireBall1"); fireBall1.localPosition = new Vector3(0.0f, fireBall1.localPosition.y, 0.0f); GoTween fb1tw = new GoTween(fireBall1, 1.0f, new GoTweenConfig() .position(new Vector3(0, 0, 5f), true) .setEaseType(GoEaseType.Linear) .onComplete(tweenfb1 => { bossFight.currentAttackDamage = fireball1Damage; bossFight.DamageBoss(null); })); //fireball2 Transform fireBall2 = fireSpell.Find("FireBall2"); fireBall2.localPosition = new Vector3(0.0f, fireBall2.localPosition.y, 0.0f); GoTween fb2tw = new GoTween(fireBall2, 1.0f, new GoTweenConfig() .position(new Vector3(0, 0, 5f), true) .setEaseType(GoEaseType.Linear) .onComplete(tweenfb2 => { bossFight.currentAttackDamage = fireball2Damage; bossFight.DamageBoss(null); })); //fireball3 Transform fireBall3 = fireSpell.Find("FireBall3"); fireBall3.localPosition = new Vector3(0.0f, fireBall3.localPosition.y, 0.0f); GoTween fb3tw = new GoTween(fireBall3, 1.0f, new GoTweenConfig() .position(new Vector3(0, 0, 5f), true) .setEaseType(GoEaseType.Linear) .onComplete(tweenfb3 => { bossFight.currentAttackDamage = fireball3Damage; bossFight.DamageBossBig(null); })); GoTweenChain chain = new GoTweenChain(); chain.appendDelay(3f).append(fb1tw).appendDelay(0.5f).append(fb2tw).appendDelay(0.3f).append(fb3tw); chain.play(); break; case 3: //hearthquake Transform earthSpell = glorten.transform.Find("EarthSpell"); //rotate spell Go.to(earthSpell, 9.0f, new GoTweenConfig() .localRotation(new Vector3(0, 1440f, 0), true) .scale(1.0f) .setEaseType(GoEaseType.Linear)); //make decal appear Transform earthDecal = earthSpell.Find("Decal"); if (earthDecal != null) { SpriteRenderer sr = earthDecal.gameObject.GetComponent <SpriteRenderer>(); sr.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); sr.transform.localScale = new Vector3(0.4f, 0.4f, 0.4f); Go.to(sr, 9.0f, new GoTweenConfig() .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 1.0f)) .setEaseType(GoEaseType.SineOut) .onComplete(tween => { Go.to(sr, 0.5f, new GoTweenConfig() .colorProp("color", new Vector4(1.0f, 1.0f, 1.0f, 0.0f)) .setEaseType(GoEaseType.SineIn) ); Go.to(sr.transform, 0.5f, new GoTweenConfig() .scale(new Vector3(0.1f, 0.1f, 1.0f)) .setEaseType(GoEaseType.SineIn) .onComplete(bossFight.ChangeTurn) ); }) ); } //launch particles ParticleSystem[] earthParticles = earthSpell.GetComponentsInChildren <ParticleSystem>(); foreach (ParticleSystem ps in earthParticles) { ps.Play(); } //earthquake rocks Transform movingRocks = earthSpell.Find("MovingRocks"); movingRocks.localPosition = new Vector3(0.0f, 0.0f, 1.56f); Go.to(movingRocks, 1.0f, new GoTweenConfig() .position(new Vector3(0, 0, 5f), true) .setEaseType(GoEaseType.Linear) .setDelay(5.0f) .onComplete(bossFight.DamageBossBig)); break; } } }
void applyJumpSkillMove(List <Dictionary <string, string> > boxDataDict) { var rigidBody = gameObject.GetComponent <Rigidbody>(); //rigidBody.velocity = testVelocity; gtc = new GoTweenChain(); gtc.autoRemoveOnComplete = true; List <Dictionary <string, float> > atkOffsets = new List <Dictionary <string, float> >(); int bi = 0; foreach (var boxData in boxDataDict) { if (boxData["self_aff"] != "跳跃") { break; } char[] delimiterChars = { ',' }; string[] sdata = boxData["self_param"].Split(delimiterChars); if (sdata.Length < 3) { break; } List <float> fdata = new List <float>(); foreach (string s in sdata) { fdata.Add(Convert.ToSingle(s)); } float startTime = fdata[0]; float angle = fdata[1]; float speed = fdata[2]; float vx = speed * Mathf.Cos(Mathf.Deg2Rad * angle); float vy = speed * Mathf.Sin(Mathf.Deg2Rad * angle); Dictionary <string, float> offsetData = new Dictionary <string, float>(); offsetData["startTime"] = startTime; offsetData["velocityX"] = vx; offsetData["velocityY"] = vy; atkOffsets.Add(offsetData); var curData = atkOffsets[bi]; if (bi >= 1) { var preData = atkOffsets[bi - 1]; curData["delay"] = startTime - preData["startTime"]; } else { if (startTime > 0) { curData["delay"] = startTime; } } ++bi; } foreach (var v in atkOffsets) { if (v.ContainsKey("delay")) { var gtconfig = new GoTweenConfig(); gtc.append(new GoTween( gameObject.transform, v["delay"], gtconfig.onComplete(delegate(AbstractGoTween obj) { rigidBody.velocity = new Vector3(v["velocityX"], v["velocityY"], 0.0f); }) )); } } var cbcon = new GoTweenConfig(); gtc.append(new GoTween( gameObject.transform, 0.01f, cbcon.onComplete(delegate(AbstractGoTween obj) { //DestroyEfx (); }) )); gtc.appendDelay(2.0f); var con = new GoTweenConfig(); gtc.append(new GoTween( gameObject.transform, 0.01f, con.position(Vector3.zero, false).setEaseType(GoEaseType.Linear).setUpdateType(GoUpdateType.FixedUpdate) )); gtc.play(); }
void applyNonJumpSkillMove(List <Dictionary <string, string> > boxDataDict) { gtc = new GoTweenChain(); gtc.autoRemoveOnComplete = true; List <Dictionary <string, float> > atkOffsets = new List <Dictionary <string, float> >(); int bi = 0; foreach (var boxData in boxDataDict) { if (boxData["self_aff"] != "位移") { break; } char[] delimiterChars = { ',' }; string[] sdata = boxData["self_param"].Split(delimiterChars); if (sdata.Length < 3) { break; } List <float> fdata = new List <float>(); foreach (string s in sdata) { fdata.Add(Convert.ToSingle(s)); } float startTime = fdata[0] / 24; float speed = fdata[1]; float dist = fdata[2]; float duration = Mathf.Abs(dist / speed); speed = dist / duration; Dictionary <string, float> offsetData = new Dictionary <string, float>(); offsetData["startTime"] = startTime; offsetData["endTime"] = startTime + duration; offsetData["curTime"] = 0; offsetData["totalTime"] = duration; offsetData["speed"] = speed; atkOffsets.Add(offsetData); if (bi >= 1) { var preData = atkOffsets[bi - 1]; if (preData["endTime"] > startTime) { preData["endTime"] = startTime; preData["totalTime"] = startTime - preData["startTime"]; } else { preData["delay"] = startTime - preData["endTime"]; } } else { var curData = atkOffsets[bi]; if (startTime > 0) { curData["delay"] = startTime; } } ++bi; } foreach (var v in atkOffsets) { if (v.ContainsKey("delay")) { gtc.appendDelay(v["delay"]); } var gtconfig = new GoTweenConfig(); if (v["totalTime"] > 0) { var dirInc = new Vector3(v["speed"] * v["totalTime"], 0, 0); gtc.append(new GoTween( gameObject.transform, v["totalTime"], gtconfig.position(dirInc, true).setEaseType(GoEaseType.Linear).setUpdateType(GoUpdateType.FixedUpdate) )); } } var cbcon = new GoTweenConfig(); gtc.append(new GoTween( gameObject.transform, 0.01f, cbcon.onComplete(delegate(AbstractGoTween obj) { //DestroyEfx (); }) )); gtc.appendDelay(2.0f); var con = new GoTweenConfig(); gtc.append(new GoTween( gameObject.transform, 0.01f, con.position(Vector3.zero, false).setEaseType(GoEaseType.Linear).setUpdateType(GoUpdateType.FixedUpdate) )); gtc.play(); }
private void Move(Transform target, Vector3 to, Vector3 back, float duration) { animationReady = false; Go.defaultEaseType = GoEaseType.Linear; var moveUpConfig = new GoTweenConfig().position( to, true ); var moveBackConfig = new GoTweenConfig().position( -back, true ); moveBackConfig.onComplete(orginalTween => Done()); var tweenOne = new GoTween( target, duration, moveUpConfig); var tweenTwo = new GoTween( target, duration, moveBackConfig); var chain = new GoTweenChain(); chain.append(tweenOne).append(tweenTwo); chain.play(); }
public void go(FSprite node, float period, float toAlpha ) { Cancel (node); chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(-1,GoLoopType.PingPong)); chain.autoRemoveOnComplete=true; //chain.setIterations( -1, LoopType.PingPong ); GoTweenConfig config0=new GoTweenConfig(); config0.floatProp("alpha",toAlpha); config0.setEaseType(GoEaseType.SineInOut); chain.append( new GoTween( node, period, config0 ) ); chain.play(); memoAlpha=node.alpha; pendings.Add(node,this); }
internal static GoTweenChain animateJelly( this Transform transform, float time, float value, int repeatCount = 1, GoEaseType ease = GoEaseType.QuadInOut ) { Vector3 scaleAtStart = transform.localScale; GoTweenChain chain = new GoTweenChain (); for ( int i = repeatCount; i > 0; i-- ) { float factor = ( (float)i ) / repeatCount; Vector3 target = new Vector3 ( scaleAtStart.x + ( value * factor ), scaleAtStart.y - ( value * factor ), scaleAtStart.z ); chain.append ( transform.scaleTo ( time * factor, target ).eases ( ease ) ); target = new Vector3 ( scaleAtStart.x - ( value * factor ), scaleAtStart.y + ( value * factor ), scaleAtStart.z ); chain.append ( transform.scaleTo ( time * factor, target ).eases ( ease ) ); } chain.append ( transform.scaleTo ( time / repeatCount, scaleAtStart ).eases ( ease ) ); chain.play (); return chain; }
private IEnumerator Blink_Coroutine ( Vector3 direction , Vector3 mousePos , bool charge ) { _blink = true; Vector3 pos = transform.position; pos.y = 0; mousePos.y = 0; Vector3 bodyScale = body.localScale; float yPos = transform.position.y; Go.to( body , 0.25f , new GoTweenConfig().scale( Vector3.one * 0.25f ).setEaseType( GoEaseType.BackIn ) ); yield return new WaitForSeconds( 0.25f ); Vector3 newPos = mousePos; newPos.y = yPos; Go.to( transform , 0.5f , new GoTweenConfig().position( newPos ).setEaseType( GoEaseType.BackInOut ) ); yield return new WaitForSeconds( 0.5f ); transform.position = newPos; Go.to( body , 0.25f , new GoTweenConfig().scale( bodyScale ).setEaseType( GoEaseType.BackOut ) ); if ( charge ) { GameObject punch = GameObject.CreatePrimitive( PrimitiveType.Cube ); punch.GetComponent<MeshRenderer>().material = attackMaterial; punch.transform.position = transform.position; punch.transform.localScale = Vector3.zero; GoTweenChain chain = new GoTweenChain(); GoTween growTween = Go.to( punch.transform , chargeBlinkFXTime * 0.25f , new GoTweenConfig().scale( Vector3.one * 3 ).setEaseType( GoEaseType.BackOut ) ); GoTween shrinkTween = Go.to( punch.transform , chargeBlinkFXTime * 0.75f , new GoTweenConfig().scale( Vector3.zero ).setEaseType( GoEaseType.ExpoIn ) ); chain.append( growTween ); chain.append( shrinkTween ); chain.play(); yield return new WaitForSeconds( chargeBlinkFXTime ); yield return new WaitForSeconds( blinkRecoverTime ); } else yield return new WaitForSeconds( 0.25f ); Go.killAllTweensWithTarget( body.GetChild( 0 ).GetComponent<MeshRenderer>() ); Go.to( body.GetChild( 0 ).GetComponent<MeshRenderer>() , 0.2f , new GoTweenConfig().materialColor( new Color( 62f / 255f , 1f , 0 ) ) ); _blink = false; }
IEnumerator AnimateItems(IEnumerable <ItemMovementDetails> movementDetails) { List <GameObject> objectsToDestroy = new List <GameObject>(); foreach (var item in movementDetails) { //calculate the new position in the world space var newGoPosition = new Vector3(item.NewColumn + item.NewColumn * distance, item.NewRow + item.NewRow * distance, ZIndex); //move it there var tween = item.GOToAnimatePosition.transform.positionTo(Globals.AnimationDuration, newGoPosition); tween.autoRemoveOnComplete = true; //the scale is != null => this means that this item will also move and duplicate if (item.GOToAnimateScale != null) { var duplicatedItem = matrix[item.NewRow, item.NewColumn]; UpdateScore(duplicatedItem.Value); //check if the item is 2048 => game has ended if (duplicatedItem.Value == 2048) { gameState = GameState.Won; yield return(new WaitForEndOfFrame()); } //create the duplicated item var newGO = Instantiate(GetGOBasedOnValue(duplicatedItem.Value), newGoPosition, Quaternion.identity) as GameObject; //make it small in order to animate it newGO.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); newGO.transform.scaleTo(Globals.AnimationDuration, 1.0f); //assign it to the proper position in the array matrix[item.NewRow, item.NewColumn].GO = newGO; //we need two animations to happen in chain //first, the movement animation var moveTween = new GoTween(item.GOToAnimateScale.transform, Globals.AnimationDuration, new GoTweenConfig().position(newGoPosition)); //then, the scale one var scaleTween = new GoTween(item.GOToAnimateScale.transform, Globals.AnimationDuration, new GoTweenConfig().scale(0.1f)); var chain = new GoTweenChain(); chain.autoRemoveOnComplete = true; chain.append(moveTween).appendDelay(Globals.AnimationDuration).append(scaleTween); chain.play(); //destroy objects after the animations have ended objectsToDestroy.Add(item.GOToAnimateScale); objectsToDestroy.Add(item.GOToAnimatePosition); } } CreateNewItem(); //hold on till the animations finish yield return(new WaitForSeconds(Globals.AnimationDuration * movementDetails.Count() * 3)); foreach (var go in objectsToDestroy) { Destroy(go); } }
public void go(FNode node, float period, float ampX, float ampY) { Cancel (node); chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(-1,GoLoopType.PingPong)); chain.autoRemoveOnComplete=true; //chain.setIterations( -1, LoopType.PingPong ); GoTweenConfig config0=new GoTweenConfig(); if (ampX!=0) config0.floatProp( "x", node.x+ampX ); if (ampY!=0) config0.floatProp( "y", node.y+ampY ); config0.setEaseType(GoEaseType.SineInOut); chain.append( new GoTween( node, period, config0 ) ); chain.play(); pendings.Add(node,this); }
public void go(FNode node, float period, float scaleX, float scaleY) { Cancel (node); chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(-1,GoLoopType.PingPong)); chain.autoRemoveOnComplete=true; //chain.setIterations( -1, LoopType.PingPong ); GoTweenConfig config0=new GoTweenConfig(); if (scaleX!=node.scaleX) config0.floatProp( "scaleX", scaleX ); if (scaleY!=node.scaleY) config0.floatProp( "scaleY", scaleY ); config0.setEaseType(GoEaseType.SineInOut); chain.append( new GoTween( node, period, config0 ) ); chain.play(); memoScaleX=node.scaleX; memoScaleY=node.scaleY; pendings.Add(node,this); }
public void go(FSprite node, float period, Color toColor ) { Cancel (node); //Debug.Log ("OscilColorUtil node="+node); chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(-1,GoLoopType.PingPong)); chain.autoRemoveOnComplete=true; //chain.setIterations( -1, LoopType.PingPong ); GoTweenConfig config0=new GoTweenConfig(); config0.colorProp("color",toColor); config0.setEaseType(GoEaseType.SineInOut); chain.append( new GoTween( node, period, config0 ) ); chain.play(); memoColor=node.color; pendings.Add(node,this); }
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; }
public void go(FNode node,System.Action<FNode> action,float duration_) { Cancel(node); _action=action; _node=node; _scaleY=node.scaleY; pendings.Add(_node,this); _chain=new GoTweenChain(new GoTweenCollectionConfig().setIterations(1,GoLoopType.PingPong)); _chain.autoRemoveOnComplete=true; GoTweenConfig config; config=new GoTweenConfig().floatProp("scaleY",0f).onComplete(HandleMidAnim); config.easeType=GoEaseType.ExpoOut; _chain.append(Go.to(_node,duration_*0.5f,config)); config=new GoTweenConfig().floatProp("scaleY",_scaleY).onComplete(HandleEndAnim); config.easeType=GoEaseType.ExpoOut; _chain.append(Go.to(_node,duration_*0.5f,config)); _chain.play(); }
internal static GoTweenChain animateJellyInfinite( this Transform transform, float time, float value, GoEaseType ease = GoEaseType.QuadInOut ) { GoTweenChain chain = new GoTweenChain (); Vector3 scaleAtStart = transform.localScale; Vector3 target = new Vector3 ( scaleAtStart.x - value, scaleAtStart.y + value, scaleAtStart.z ); transform.localScale = target; target = new Vector3 ( scaleAtStart.x + value, scaleAtStart.y - value, scaleAtStart.z ); chain.append ( transform.scaleTo ( time, target ).eases ( ease ) ); target = new Vector3 ( scaleAtStart.x - value, scaleAtStart.y + value, scaleAtStart.z ); chain.append ( transform.scaleTo ( time, target ).eases ( ease ) ); chain.loopCount = -1; chain.play (); return chain; }
IEnumerator AnimateItems(IEnumerable<ItemMovementDetails> movementDetails) { List<GameObject> objectsToDestroy = new List<GameObject>(); foreach (var item in movementDetails) { //calculate the new position in the world space var newGoPosition = new Vector3(item.NewColumn + item.NewColumn * distance, item.NewRow + item.NewRow * distance, ZIndex); //move it there var tween = item.GOToAnimatePosition.transform.positionTo(Globals.AnimationDuration, newGoPosition); tween.autoRemoveOnComplete = true; //the scale is != null => this means that this item will also move and duplicate if (item.GOToAnimateScale != null) { var duplicatedItem = matrix[item.NewRow, item.NewColumn]; UpdateScore(duplicatedItem.Value); //check if the item is 2048 => game has ended if (duplicatedItem.Value == 2048) { gameState = GameState.Won; yield return new WaitForEndOfFrame(); } //create the duplicated item var newGO = Instantiate(GetGOBasedOnValue(duplicatedItem.Value), newGoPosition, Quaternion.identity) as GameObject; //make it small in order to animate it newGO.transform.localScale = new Vector3(0.01f, 0.01f, 0.01f); newGO.transform.scaleTo(Globals.AnimationDuration, 1.0f); //assign it to the proper position in the array matrix[item.NewRow, item.NewColumn].GO = newGO; //we need two animations to happen in chain //first, the movement animation var moveTween = new GoTween(item.GOToAnimateScale.transform, Globals.AnimationDuration, new GoTweenConfig().position(newGoPosition)); //then, the scale one var scaleTween = new GoTween(item.GOToAnimateScale.transform, Globals.AnimationDuration, new GoTweenConfig().scale(0.1f)); var chain = new GoTweenChain(); chain.autoRemoveOnComplete = true; //important -> https://github.com/prime31/GoKit/wiki/5.-TweenChains:-Chaining-Multiple-Tweens chain.append(moveTween).appendDelay(Globals.AnimationDuration).append(scaleTween); chain.play(); //destroy objects after the animations have ended objectsToDestroy.Add(item.GOToAnimateScale); objectsToDestroy.Add(item.GOToAnimatePosition); } } CreateNewItem(); //hold on till the animations finish yield return new WaitForSeconds(Globals.AnimationDuration * movementDetails.Count() * 3); foreach (var go in objectsToDestroy) Destroy(go); }
public void go(FSprite sprite_,FAtlasElement element,float duration_) { Cancel(sprite_); _switchToElment=element; _sprite=sprite_; _scaleY=_sprite.scaleY; pendings.Add(_sprite,this); _chain=new GoTweenChain(new GoTweenCollectionConfig().setIterations(1,GoLoopType.PingPong)); _chain.autoRemoveOnComplete=true; GoTweenConfig config; config=new GoTweenConfig().floatProp("scaleY",0f).onComplete(HandleSwitchElement); config.easeType=GoEaseType.ExpoOut; _chain.append(Go.to(sprite_,duration_*0.5f,config)); config=new GoTweenConfig().floatProp("scaleY",_scaleY).onComplete(HandleEndAnim); config.easeType=GoEaseType.ExpoOut; _chain.append(Go.to(sprite_,duration_*0.5f,config)); _chain.play(); }