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 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)))); }
static public int appendDelay(IntPtr l) { try { GoTweenChain self = (GoTweenChain)checkSelf(l); System.Single a1; checkType(l, 2, out a1); var ret = self.appendDelay(a1); pushValue(l, ret); return(1); } catch (Exception e) { return(error(l, e)); } }
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); } }
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; } } }