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); }
static public int constructor(IntPtr l) { try { int argc = LuaDLL.lua_gettop(l); GoTweenChain o; if (argc == 1) { o = new GoTweenChain(); pushValue(l, o); return(1); } else if (argc == 2) { GoTweenCollectionConfig a1; checkType(l, 2, out a1); o = new GoTweenChain(a1); pushValue(l, o); return(1); } return(error(l, "New object failed.")); } catch (Exception e) { return(error(l, e)); } }
public void Throw(Direction direction) { transform.SetScale(0.25f); transform.localEulerAngles = new Vector3(0, 0, direction.ToRotationAngle()); Vector2 localMoveVector = direction.ToVector2() * shootDistance; if (tween != null) { Debug.LogError("Tween is already running"); gameObject.DestroySelf(); } tween = new GoTweenChain(); tween.insert(0, transform.localPositionTo(shootDuration, localMoveVector, true).eases(shootEase)); tween.insert(0, transform.scaleTo(0.125f, 1).eases(GoEaseType.QuartIn)); tween.insert(0.25f, transform.scaleTo(0.5f, 0).eases(GoEaseType.QuadOut)); tween.insertAction(timeBetweenWeapons, () => { if (onEnd != null) { onEnd(); } }); tween.Start(); tween.setOnCompleteHandler(c => gameObject.DestroySelf()); }
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 chain and set it to have 2 iterations var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(2)); // add a completion handler for the chain chain.setOnCompleteHandler(c => Debug.Log("chain complete")); // create a Tween for each cube and it to the chain foreach (var cube in cubes) { var tween = new GoTween(cube, 0.5f, config); chain.append(tween); } _tween = chain; }
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 chain and set it to have 2 iterations var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations( 2 )); // add a completion handler for the chain chain.setOnCompleteHandler( c => Debug.Log( "chain complete" ) ); // create a Tween for each cube and it to the chain foreach( var cube in cubes ) { var tween = new GoTween( cube, 0.5f, config ); chain.append( tween ); } _tween = chain; }
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(); }
// Use this for initialization void Start() { TurnManager.Instance.OnRoundStart.AddListener(newRound); TurnManager.Instance.OnGameEnd.AddListener(gameOver); RoundPanel.anchoredPosition = new Vector2(0, 150); // Movement fun movementTween = new GoTweenChain(); movementTween.append(new GoTween(RoundPanel, 0.5f, new GoTweenConfig().anchoredPosition(new Vector2(0, -50)))); movementTween.appendDelay(1); movementTween.append(new GoTween(RoundPanel, 0.5f, new GoTweenConfig().anchoredPosition(new Vector2(0, 150)))); }
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; }
static public int prependDelay(IntPtr l) { try { GoTweenChain self = (GoTweenChain)checkSelf(l); System.Single a1; checkType(l, 2, out a1); var ret = self.prependDelay(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int append(IntPtr l) { try { GoTweenChain self = (GoTweenChain)checkSelf(l); AbstractGoTween a1; checkType(l, 2, out a1); var ret = self.append(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
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 override void ApplyPattern(Transform transform, ref AbstractGoTween tween) { var path = new GoSpline("little_curve_r"); var move = Go.to(transform, 1f, new GoTweenConfig().positionPath(path, true)); var path2 = new GoSpline("forward_top_bot"); var move3 = Go.to(transform, 5f, new GoTweenConfig().positionPath(path2, true)); var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1)); chain.append(move); chain.append(move3); tween = chain; tween.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; }
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(); }
// Use this for initialization void Start() { var path = new GoSpline("little_curve"); var move = Go.to(transform, 1f, new GoTweenConfig() .positionPath(path, true)); var move2 = Go.to(transform, 1f, new GoTweenConfig().positionPath(path, true)); var path2 = new GoSpline("forward_top_bot"); var move3 = Go.to(transform, 5f, new GoTweenConfig().positionPath(path2, true)); var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1)); chain.append(move); chain.append(move2); chain.append(move3); _tween = chain; _tween.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 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); } }
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(); }
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); }
public override void ApplyPattern(Transform transform, ref AbstractGoTween tween) { var path = new GoSpline("top_to_bot_one_third"); var move = Go.to(transform, 2f, new GoTweenConfig().positionPath(path, true)); var path2 = new GoSpline("diag_right_to_left_one_square"); var move2 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path2, true)); var path3 = new GoSpline("top_to_bot_one_third"); var move3 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path3, true)); var move4 = Go.to(transform, 2f, new GoTweenConfig().positionPath(path3, true)); var chain = new GoTweenChain(new GoTweenCollectionConfig().setIterations(1)); chain.append(move); chain.append(move2); chain.append(move3); chain.append(move4); tween = chain; tween.play(); }
internal virtual void TakeDamage() { if (state == MonsterState.Living) { Vector3 splashVector = (transform.position - Player.Instance.transform.position).normalized; life -= 1; if (life == 0) { ApplySound(); state = MonsterState.Dying; GoTweenChain chain = new GoTweenChain(); chain.insert(0, transform .scaleTo(0.5f, 0.75f, true) .eases(GoEaseType.QuartOut) ); chain.insert(0, transform .localEularAnglesTo(0.5f, new Vector3(0, 0, RandomFloat.Range(-180, 180))) .eases(GoEaseType.QuadOut) ); chain.insert(0.25f, gameObject .alphaTo(0.25f, 0, GoEaseType.QuartOut) ); chain.setOnCompleteHandler(c => gameObject.DestroySelf()); chain.Start(); } transform.position += splashVector * 25; // bool isDying = ( life == 0 ); // transform.position += splashVector * ( isDying ? 100 : 25 ); } }
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(); }
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(); }
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; } } }
public void TryShowSkill(string skillId) { //var rigidBody = gameObject.GetComponent<Rigidbody> (); //rigidBody.velocity = testVelocity; if (!(skillSheet != null && boxesSheet != null && skillId != null && skillId != "")) { return; } string trimmedSid = skillId.Trim(); IRow skillRow = XlsUtil.findRow(skillSheet, trimmedSid); if (skillRow == null) { return; } IRow skillRefRow = skillSheet.GetRow(2); IRow boxesRefRow = boxesSheet.GetRow(2); Dictionary <string, string> skillData = XlsUtil.getValueDict(skillRow, skillRefRow); List <string> boxIdList = new List <string> (); for (int i = 1; i <= 10; ++i) { string key = "box" + i.ToString(); if (skillData.ContainsKey(key)) { boxIdList.Add(skillData [key]); } } List <Dictionary <string, string> > boxDataDict = new List <Dictionary <string, string> >(); foreach (string boxId in boxIdList) { IRow boxRow = XlsUtil.findRow(boxesSheet, boxId); if (boxRow != null) { Dictionary <string, string> boxData = XlsUtil.getValueDict(boxRow, boxesRefRow); boxDataDict.Add(boxData); } } // clear colliders for simulate hit pause clearColliders(); foreach (var boxData in boxDataDict) { if (boxData.ContainsKey("shake_tm")) { delayList.Add(Single.Parse(boxData["shake_tm"]) / 24); } else { delayList.Add(0.0f); } } // play sounds List <KeyValuePair <string, int> > sounds = new List <KeyValuePair <string, int> >(); if (skillData.ContainsKey("sound1")) { string sounds_str = skillData ["sound1"]; string frames_str = ""; if (skillData.ContainsKey("sound_frame1")) { frames_str = skillData ["sound_frame1"]; } string[] all_sounds = sounds_str.Split(','); string[] all_frames = frames_str.Split(','); for (int i = 0; i < all_sounds.Length; ++i) { string sound = all_sounds[i].Trim(); int frame = 0; if (all_frames.Length > i) { frame = Convert.ToInt32(all_frames [i]); } sounds.Add(new KeyValuePair <string, int>(sound, frame)); } } if (gtc != null) { gtc.destroy(); gtc = null; } if (audioGtc != null) { audioGtc.destroy(); audioGtc = null; } _sounds = sounds; _skillData = skillData; _boxDataDict = boxDataDict; var config = LBootEditor.GameConfig.Get(); animLen = config.getClipLength(this.animator.runtimeAnimatorController.name, skillData["anim_type"]); // StartCoroutine ("loadSounds"); loadSounds(); }
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); }
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 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 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; }
protected void Stop() { if (_sprite!=null) { _sprite.element=_switchToElment; _sprite.scaleY=_scaleY; pendings.Remove(_sprite); _chain.destroy(); _chain=null; _sprite=null; } }
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(); }
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; }
internal ComboPaneResolution TryResolvingState( Player player, List<InputActionName> inputs ) { if ( isCompleted ) return ComboPaneResolution.Completed; bool isFailed = false; int activatedCount = 0; for ( int i = 0; i < combo.actions.Count; i++ ) { if ( i < inputs.Count ) if ( inputs[i] == combo.actions[i] ) activatedCount++; else { isFailed = true; break; } } if ( player.playerSide == PlayerSide.Left ) activatedCountPlayerLeft = activatedCount; if ( player.playerSide == PlayerSide.Right ) activatedCountPlayerRight = activatedCount; if ( isFailed ) { return ComboPaneResolution.Failed; } isCompleted = ( activatedCount == buttons.Count ); if ( isCompleted ) { state = ComboPaneState.Absorbed; player.PrepareAttack ( Size ); GoTweenChain chain = new GoTweenChain(); chain.append ( transform.scaleTo ( 0.125f, 1.5f ).eases ( GoEaseType.Linear ) ); chain.append ( transform.scaleTo ( 0.125f, 1.0f ).eases ( GoEaseType.Linear ) ); chain.insert ( 0.25f, transform.scaleTo ( 1.25f, 0.25f ).eases ( GoEaseType.QuadInOut ) ); chain.insert ( 0.25f, transform.positionTo ( 1.25f, player.ComboCollectPosition ).eases ( GoEaseType.QuadInOut ) ); chain.setOnCompleteHandler ( c => { gameObject.DestroySelf (); } ); chain.Start (); return ComboPaneResolution.Completed; } else { return ComboPaneResolution.NotCompleted; } }
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, 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); }
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; }
public void TryShowSkill() { //var rigidBody = gameObject.GetComponent<Rigidbody> (); //rigidBody.velocity = testVelocity; if (!(skillWorkBook != null && boxesWorkBook != null && skillId != null && skillId != "")) { return; } ISheet skillSheet = skillWorkBook.GetSheetAt(1); ISheet boxesSheet = boxesWorkBook.GetSheetAt(1); string trimmedSid = skillId.Trim(); IRow skillRow = XlsUtil.findRow(skillSheet, trimmedSid); if (skillRow == null) { return; } IRow skillRefRow = skillSheet.GetRow(2); IRow boxesRefRow = boxesSheet.GetRow(2); Dictionary <string, string> skillData = XlsUtil.getValueDict(skillRow, skillRefRow); List <string> boxIdList = new List <string> (); for (int i = 1; i <= 10; ++i) { string key = "box" + i.ToString(); if (skillData.ContainsKey(key)) { boxIdList.Add(skillData [key]); } } List <Dictionary <string, string> > boxDataDict = new List <Dictionary <string, string> >(); foreach (string boxId in boxIdList) { IRow boxRow = XlsUtil.findRow(boxesSheet, boxId); if (boxRow != null) { Dictionary <string, string> boxData = XlsUtil.getValueDict(boxRow, boxesRefRow); boxDataDict.Add(boxData); } } // clear colliders for simulate hit pause clearColliders(); foreach (var boxData in boxDataDict) { if (boxData.ContainsKey("shake_tm")) { delayList.Add(Single.Parse(boxData["shake_tm"]) / 24); } else { delayList.Add(0.0f); } } if (gtc != null) { gtc.destroy(); gtc = null; } this.time = 0; animTimeVal = 0; preATV = 0; preState = skillData["anim_type"]; gameObject.transform.position = Vector3.zero; this.animator.Play(preState, 0, 0); this.animator.enabled = true; this.animator.speed = 1.0f; DestroyEfx(); if (skillData.ContainsKey("self_eff")) { effect_nf = MakeEfx(skillData["self_eff"]); } if (skillData.ContainsKey("self_eff_follow")) { effect_f = MakeEfx(skillData["self_eff_follow"]); } if (effect_f != null) { effect_f.transform.SetParent(gameObject.transform, true); effect_f.name = skillData["self_eff_follow"] + "efx"; } if (effect_nf != null) { effect_nf.transform.position = gameObject.transform.position; effect_nf.name = skillData["self_eff"] + "efx"; } if (skillData["is_jump_skill"] == "是") { applyJumpSkillMove(boxDataDict); } else { applyNonJumpSkillMove(boxDataDict); } }
internal static GoTweenChain Start(this GoTweenChain self) { Go.addTween(self); return(self); }
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); }
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(); }
float AnimateOpening() { AbstractGoTween tween = null; switch (gateName) { case GateName.Basique: tween = sprite.transform.localPositionTo(1, new Vector3(-70, 0, 0), true); break; case GateName.Bleue: tween = sprite.transform.localPositionTo(1, new Vector3(0, -120, 0), true); break; case GateName.Cassée: { GoTweenChain chain = new GoTweenChain(); chain.insert(0, sprite.transform.localPositionTo(0.5f, new Vector3(-2, -3, 0))); chain.insert(0.5f, sprite.transform.localPositionTo(1.0f, new Vector3(-60, 770, 0))); chain.Start(); tween = chain; } break; case GateName.Cloche: { GoTweenChain chain = new GoTweenChain(); chain.insert(0, sprite.transform.localPositionTo(0.5f, new Vector3(5, -5, 0))); chain.insert(0.5f, sprite.transform.localPositionTo(1.0f, new Vector3(-30, 55, 0))); chain.Start(); tween = chain; } break; case GateName.Colonne: { GoTweenChain chain = new GoTweenChain(); chain.insert(0, spriteA.transform.localPositionTo(1, new Vector3(-75, 10, 0))); chain.insert(0, spriteB.transform.localPositionTo(1, new Vector3(95, 10, 0))); chain.insert(1, spriteA.transform.localPositionTo(1, new Vector3(-75, 95, 0))); chain.insert(1, spriteB.transform.localPositionTo(1, new Vector3(105, 95, 0))); chain.Start(); tween = chain; } break; case GateName.Herbe: tween = sprite.transform.localPositionTo(1, new Vector3(0, -40, 0)); break; case GateName.Jaune: tween = sprite.transform.localPositionTo(1, new Vector3(0, -70, 0)); break; case GateName.Oeil: tween = sprite.transform.localPositionTo(1, new Vector3(0, 85, 0)); break; case GateName.Orange: tween = sprite.transform.localPositionTo(1, new Vector3(70, 0, 0)); break; case GateName.Orientale: { GoTweenChain chain = new GoTweenChain(); chain.insert(0, spriteA.transform.localPositionTo(1, new Vector3(0, 50, 0), true)); chain.insert(0, spriteB.transform.localPositionTo(1, new Vector3(0, -50, 0), true)); chain.Start(); tween = chain; } break; case GateName.Rouge: tween = sprite.transform.localPositionTo(1, new Vector3(0, -70, 0), true); break; case GateName.TriangleDroite: tween = sprite.transform.localPositionTo(1, new Vector3(65, 0, 0), true); break; case GateName.TriangleGauche: tween = sprite.transform.localPositionTo(1, new Vector3(-70, 0, 0), true); break; case GateName.Verte: tween = sprite.transform.localPositionTo(1, new Vector3(0, -65, 0), true); break; default: return(0); } return(tween.totalDuration); }
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); }
protected void Stop() { if (_node!=null) { HandleMidAnim(null); _node.scaleY=_scaleY; pendings.Remove(_node); _chain.destroy(); _chain=null; _node=null; } }