public void Close() { this.toolActive = false; this.onToolToggle?.Invoke(this.toolActive); this.currentTweenChain = this.exitTweenChain; this.currentTweenChain.Refresh(); }
void AnimateLettersIn(List <FLabel> letters, float finalZero, float yPosition, float durationPerLetter, float overlapBetweenLetterFlyins, float extraRotationAmount, System.Action <AbstractTween> onCompleteFunction) { if (overlapBetweenLetterFlyins > durationPerLetter) { Debug.Log("overlap can't be greater than duration!"); return; } float horizontalDivision = (Futile.screen.width - finalZero * 2) / (letters.Count + 1); TweenFlow flow = new TweenFlow(); for (int i = 0; i < letters.Count; i++) { TweenChain chain = TweenChainForLetter(letters[i], durationPerLetter, finalZero + horizontalDivision * (i + 1), yPosition, extraRotationAmount); flow.insert((durationPerLetter - overlapBetweenLetterFlyins) * i, chain); } if (onCompleteFunction != null) { flow.setOnCompleteHandler(onCompleteFunction); } Go.addTween(flow); flow.play(); }
public void Open() { this.toolActive = true; this.onToolToggle?.Invoke(this.toolActive); this.currentTweenChain = this.enterTweenChain; this.currentTweenChain.Refresh(); }
void Start() { // create a TweenConfig that we will use on all 4 cubes var config = new TweenConfig() .setEaseType( EaseType.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, LoopType.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 TweenChain().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 Tween( cube, 0.5f, config ); chain.append( tween ); } _tween = chain; }
//TBorderLayer border; public THeartToken(bool isBroken) { this.isBroken = isBroken; if (isBroken) { sprite = new FSprite("brokenHeart.psd"); } else { sprite = new FSprite("heart.psd"); } sprite.scale = 0.6f; sprite.color = new Color(1.0f, Random.Range(0.3f, 0.6f), Random.Range(0.3f, 0.6f), 1.0f); sprite.rotation = -10f; float duration = Random.Range(0.15f, 0.45f); Tween rotOut = new Tween(sprite, duration, new TweenConfig().floatProp("rotation", 10f)); Tween rotIn = new Tween(sprite, duration, new TweenConfig().floatProp("rotation", -10f)); TweenChain chain = new TweenChain(); chain.setIterations(-1); chain.append(rotOut).append(rotIn); Go.addTween(chain); chain.play(); }
public void AddHeart() { FSprite heart = new FSprite("heart.psd"); heart.x = Random.Range(heart.width / 2f, Futile.screen.width - heart.width / 2f); heart.y = Random.Range(heart.height / 2f, Futile.screen.height - heart.height / 2f - 50f /*UI bar*/); heart.scale = 0; heart.rotation = Random.Range(0, 359f); heart.color = new Color(1.0f, Random.Range(0.0f, 0.3f), Random.Range(0.0f, 0.3f), 1.0f); AddChild(heart); hearts.Add(heart); Go.to(heart, Random.Range(1.0f, 5.0f), new TweenConfig() .setIterations(-1) .floatProp("rotation", 360 * (RXRandom.Float() < 0.5f ? 1 : -1), true)); float inflationDuration = Random.Range(1.0f, 2.0f); Tween tweenUp = new Tween(heart, inflationDuration, new TweenConfig() .floatProp("scale", Random.Range(0.3f, 1.0f)) .setEaseType(EaseType.SineInOut)); Tween tweenDown = new Tween(heart, inflationDuration, new TweenConfig() .floatProp("scale", 0) .onComplete(OnHeartDisappearedWithoutBeingTouched) .setEaseType(EaseType.SineInOut)); TweenChain chain = new TweenChain(); chain.append(tweenUp); chain.append(tweenDown); Go.addTween(chain); chain.play(); }
private void Pulsate() { Debug.Log("PULSATE!!! " + (secondsPerBeat * (float)beatScale)); var scaleUp = new Tween(transform, secondsPerBeat * (float)beatScale, new TweenConfig().scale(defaultScale * scaleTo)); var scaleDown = new Tween(transform, secondsPerBeat * (float)beatScale, new TweenConfig().scale(defaultScale)); var scaleChain = new TweenChain().append(scaleUp).append(scaleDown); scaleChain.play(); }
public LevelTransition(Actor actor, int levelIndex) : base(actor) { Velocity = Vector2.Zero; this.levelTransitionTween = new TweenChain(); this.actor.scene.StartCoroutine(IntroCinematic(LevelDialogue.IntroSequence)); this.levelIndex = levelIndex; }
public ConsoleOverlay(Actor actor, SpriteFont spriteFont) : base(actor) { this.spriteFont = spriteFont; this.messages = new List <string>(); this.opacity = 0f; this.tweenChain = new TweenChain() .AppendWaitTween(3f) .AppendFloatTween(0f, 2f, EaseFuncs.QuadraticEaseIn, new TweenAccessors <float>(() => { return(this.opacity); }, val => { this.opacity = val; })) .AppendCallback(() => { this.messages.Clear(); }); }
// sets up the tweens so the flashingColor will actually flash bright/dark private void InitFlashingColorForCompletedLines() { Tween colorDown = new Tween(this, 0.2f, new TweenConfig().floatProp("flashingColorPercentage", 0.5f)); Tween colorUp = new Tween(this, 0.2f, new TweenConfig().floatProp("flashingColorPercentage", 1.0f)); TweenChain chain = new TweenChain(); chain.setIterations(-1); chain.append(colorDown).append(colorUp); Go.addTween(chain); chain.play(); }
public EyeRenderer(Actor actor, Player player, LevelTransition levelTransition) : base(actor) { this.player = player; this.levelTransition = levelTransition; this.levelTransition.onWakeUp += WakeUpAnimation; this.levelTransition.onFallAsleep += FallAsleepAnimation; this.openAmountAccessors = new TweenAccessors <float>(() => this.openPercent, val => this.openPercent = val); this.eyeTween = new TweenChain(); BuildEye(20); }
void MakeUIElements() { scoreLabel = new FLabel("SoftSugar", "0"); scoreLabel.anchorX = 1.0f; scoreLabel.anchorY = 1.0f; scoreLabel.scale = 0.75f; scoreLabel.x = Futile.screen.width + scoreLabel.textRect.width; scoreLabel.y = Futile.screen.height - 10f; scoreLabel.color = new Color(0.12f, 0.12f, 0.12f, 1.0f); AddChild(scoreLabel); missedLabel = new FLabel("SoftSugar", "Misses left: 0"); missedLabel.anchorX = 0.0f; missedLabel.anchorY = 1.0f; missedLabel.scale = 0.75f; missedLabel.x = -missedLabel.textRect.width; missedLabel.y = Futile.screen.height - 10f; missedLabel.color = new Color(0.75f, 0.12f, 0.12f, 1.0f); AddChild(missedLabel); startLabel1 = new FLabel("SoftSugar", "How much do I love you?"); startLabel2 = new FLabel("SoftSugar", "Click the hearts to find out,\nbut don't miss too many!"); startLabel1.color = new Color(0.75f, 0.12f, 0.12f, 1.0f); startLabel2.color = new Color(0.12f, 0.12f, 0.12f, 1.0f); float adj = 40f; startLabel1.x = startLabel2.x = Futile.screen.halfWidth; startLabel1.y = Futile.screen.halfHeight + adj; startLabel2.y = startLabel1.y - startLabel1.textRect.height / 2f - startLabel2.textRect.height / 2f - 10f + adj; startLabel1.scale = startLabel2.scale = 0; AddChild(startLabel1); AddChild(startLabel2); TweenConfig config1 = new TweenConfig() .floatProp("scale", 1.0f) .setEaseType(EaseType.SineInOut); TweenConfig config2 = new TweenConfig() .floatProp("scale", 0.5f) .setEaseType(EaseType.SineInOut); float duration = 0.5f; TweenChain chain = new TweenChain(); chain.append(new Tween(startLabel1, duration, config1)); chain.append(new Tween(startLabel2, duration, config2)); chain.setOnCompleteHandler(OnGameShouldBeReadyToStart); Go.addTween(chain); chain.play(); }
//TBorderLayer border; public TWalkingCharacter(string headImage) { FAtlasManager am = Futile.atlasManager; frameElements = new FAtlasElement[8]; crouchFrameElements = new FAtlasElement[8]; frameElements[0] = am.GetElementWithName("walkAnim/walk0.png"); frameElements[1] = am.GetElementWithName("walkAnim/walk1.png"); frameElements[2] = am.GetElementWithName("walkAnim/walk2.png"); frameElements[3] = am.GetElementWithName("walkAnim/walk3.png"); frameElements[4] = am.GetElementWithName("walkAnim/walk4.png"); frameElements[5] = am.GetElementWithName("walkAnim/walk1.png"); frameElements[6] = am.GetElementWithName("walkAnim/walk2.png"); frameElements[7] = am.GetElementWithName("walkAnim/walk3.png"); crouchFrameElements[0] = am.GetElementWithName("squashedWalkAnim/squashedWalk0.png"); crouchFrameElements[1] = am.GetElementWithName("squashedWalkAnim/squashedWalk1.png"); crouchFrameElements[2] = am.GetElementWithName("squashedWalkAnim/squashedWalk2.png"); crouchFrameElements[3] = am.GetElementWithName("squashedWalkAnim/squashedWalk3.png"); crouchFrameElements[4] = am.GetElementWithName("squashedWalkAnim/squashedWalk4.png"); crouchFrameElements[5] = am.GetElementWithName("squashedWalkAnim/squashedWalk1.png"); crouchFrameElements[6] = am.GetElementWithName("squashedWalkAnim/squashedWalk2.png"); crouchFrameElements[7] = am.GetElementWithName("squashedWalkAnim/squashedWalk3.png"); bodySprite = new FSprite("walkAnim/walk0.png"); bodySprite.scale = 0.5f; bodySprite.anchorY = 0; bodySprite.y = -200f; AddChild(bodySprite); headSprite = new FSprite(headImage); headSprite.y = 25f; headSprite.x -= 5f; headSprite.scale = 0.5f; headSprite.anchorY = 0; headSprite.rotation = -3f; AddChild(headSprite); Tween rotateOut = new Tween(headSprite, 0.3f, new TweenConfig().floatProp("rotation", 3f)); Tween rotateIn = new Tween(headSprite, 0.3f, new TweenConfig().floatProp("rotation", -3f)); chain = new TweenChain(); chain.setIterations(-1); chain.append(rotateOut).append(rotateIn); Go.addTween(chain); }
public Harness(Actor actor) : base(actor) { this.bubbleSpawner = RequireComponent <BubbleSpawner>(); this.levelTransition = RequireComponent <LevelTransition>(); wires = new Wire[7]; this.disconnectTween = new TweenChain(); var rand = MachinaGame.Random.DirtyRandom; wires[0] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(-47, -100)); wires[1] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(-60, -110)); wires[2] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(-25, -115)); wires[3] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(0, -120)); wires[4] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(70, -130)); wires[5] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(45, -90)); wires[6] = new Wire(new Vector2(rand.Next(-40, 40), -200 - rand.Next(0, 50)), new Vector2(55, -120)); }
public WTBlahGame() : base("") { nursesPass = new FSprite("nursesPass.psd"); nursesPass.x = Futile.screen.halfWidth; nursesPass.y = Futile.screen.halfHeight; nursesPass.scale = 0.5f; AddChild(nursesPass); Go.defaultEaseType = EaseType.SineInOut; Tween tweenUp = new Tween(nursesPass, 0.3f, new TweenConfig() .floatProp("scale", 0.6f)); Tween tweenDown = new Tween(nursesPass, 0.3f, new TweenConfig() .floatProp("scale", 0.5f)); TweenChain chain = new TweenChain(); chain.setIterations(-1); chain.append(tweenUp).append(tweenDown); Go.addTween(chain); chain.play(); }
public InvokableDebugTool(Actor actor, KeyCombination invokingKeyCombo) : base(actor) { this.invokingKeyCombo = invokingKeyCombo; this.enterTweenChain = new TweenChain() .AppendCallback(() => { this.actor.transform.Position = new Vector2(-64, 32); }) .AppendPositionTween(this.actor, new Vector2(32, 32), 0.25f, EaseFuncs.QuinticEaseOut) .AppendCallback(() => { this.currentTweenChain = null; }) ; this.exitTweenChain = new TweenChain() .AppendPositionTween(this.actor, new Vector2(0, 32), 0.25f, EaseFuncs.QuinticEaseOut) .AppendPositionTween(this.actor, new Vector2(-512, 32), 0.25f, EaseFuncs.QuinticEaseOut) .AppendCallback(() => { this.currentTweenChain = null; }) ; // start out off screen this.actor.transform.Position = new Vector2(-512, 32); this.currentTweenChain = null; }
public void ShowWave(int lvl) { _text.text = $"Wave {lvl}"; var scaleInTween = Go.to(transform, 0.5f, new TweenConfig() .scale(1) .setEaseType(EaseType.ElasticOut) ); var scaleOutTween = Go.to(transform, 0.5f, new TweenConfig() .scale(0) .setEaseType(EaseType.ElasticOut) ); var chain = new TweenChain(); chain .append(scaleInTween) .appendDelay(3f) .append(scaleOutTween); chain.play(); }
public void OnWinLabelDoneAppearing(AbstractTween tween) { gameFullyOver = true; FLabel label = (tween as Tween).target as FLabel; Tween up = new Tween(label, 0.3f, new TweenConfig() .floatProp("scale", 1.1f) .setEaseType(EaseType.SineInOut)); Tween down = new Tween(label, 0.3f, new TweenConfig() .floatProp("scale", 1.0f) .setEaseType(EaseType.SineInOut)); TweenChain upDownChain = new TweenChain(); upDownChain.setIterations(-1); upDownChain.append(up); upDownChain.append(down); Go.addTween(upDownChain); upDownChain.play(); }
public void ShakeWord(FSprite word) { /*float dur = Random.Range(0.05f, 0.15f); float xDelta = Random.Range(-5f, 5f); float yDelta = Random.Range(-5f, 5f);*/ float dur = 0.3f; float xDelta = -40f; float yDelta = -40f; Tween tweenIn = new Tween(word, dur, new TweenConfig().floatProp("x", xDelta, true).floatProp("y", yDelta, true)); Tween tweenOut = new Tween(word, dur, new TweenConfig().floatProp("x", -xDelta, true).floatProp("y", -yDelta, true).onComplete(HandleWordFinishedShake)); TweenChain tweenChain = new TweenChain(); tweenChain.append(tweenIn); tweenChain.append(tweenOut); if ((int)word.data == 0) { tweenChain1 = tweenChain; } else if ((int)word.data == 1) { tweenChain2 = tweenChain; } Go.addTween(tweenChain); tweenChain.play(); }
public void UpdateSolidifyingTrebellaLetters() { timeSinceLastSolidifiedLetter += Time.deltaTime; if (timeSinceLastSolidifiedLetter > 0.5f) { timeSinceLastSolidifiedLetter -= 0.5f; FLabel nextLetterToChange = null; switch (numLettersSolidified) { case 0: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "T") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 1: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "R") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 2: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "E") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 3: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "B") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 4: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "E") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 5: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "L") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 6: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "L") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 7: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "A") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; } FSoundManager.PlaySound("bomb", 2.0f); FLabel solidifiedLetter = trebellaLetters[numLettersSolidified]; solidifiedLetter.x = nextLetterToChange.x; solidifiedLetter.y = nextLetterToChange.y; nextLetterToChange.RemoveFromContainer(); float duration = 0.2f; float distance = 5f; Tween bounce = new Tween(solidifiedLetter, duration, new TweenConfig() .setEaseType(EaseType.SineInOut) .floatProp("y", distance, true)); Tween bounceBack = new Tween(solidifiedLetter, duration, new TweenConfig() .setEaseType(EaseType.SineInOut) .floatProp("y", -distance, true)); TweenChain chain = new TweenChain(); chain.setIterations(-1, LoopType.RestartFromBeginning); chain.append(bounce); chain.append(bounceBack); Go.addTween(chain); chain.play(); numLettersSolidified++; if (numLettersSolidified >= 8) { trebellaLettersDoneSolidifying = true; } } }
void OnGUI() { DemoGUIHelpers.setupGUIButtons(); if (_springTween == null) { _duration = DemoGUIHelpers.durationSlider(_duration); if (GUILayout.Button("Custom Property Tween (wackyDoodleWidth)")) { PropertyTweens.floatPropertyTo(this, "wackyDoodleWidth", 6f, _duration) .setFrom(1f) .setLoops(LoopType.PingPong) .start(); } if (GUILayout.Button("Position via Property Tween")) { PropertyTweens.vector3PropertyTo(cube, "position", new Vector3(5f, 5f, 5f), _duration) .setLoops(LoopType.PingPong) .start(); } if (GUILayout.Button("Tween Party (color, position, scale and rotation)")) { var party = new TweenParty(_duration); party.addTween(cube.GetComponent <Renderer>().material.ZKcolorTo(Color.black)) .addTween(cube.ZKpositionTo(new Vector3(7f, 4f))) .addTween(cube.ZKlocalScaleTo(new Vector3(1f, 4f))) .addTween(cube.ZKrotationTo(Quaternion.AngleAxis(180f, Vector3.one))) .setLoops(LoopType.PingPong) .start(); } if (GUILayout.Button("Tween Chain (same props as the party)")) { var chain = new TweenChain(); chain.appendTween(cube.GetComponent <Renderer>().material.ZKcolorTo(Color.black, _duration).setLoops(LoopType.PingPong)) .appendTween(cube.ZKpositionTo(new Vector3(7f, 4f), _duration).setLoops(LoopType.PingPong)) .appendTween(cube.ZKlocalScaleTo(new Vector3(1f, 4f), _duration).setLoops(LoopType.PingPong)) .appendTween(cube.ZKrotationTo(Quaternion.AngleAxis(180f, Vector3.one), _duration).setLoops(LoopType.PingPong)) .start(); } if (GUILayout.Button("Chaining Tweens Directly (same props as the party)")) { cube.GetComponent <Renderer>().material.ZKcolorTo(Color.black, _duration).setLoops(LoopType.PingPong) .setNextTween ( cube.ZKpositionTo(new Vector3(7f, 4f), _duration).setLoops(LoopType.PingPong).setNextTween ( cube.ZKlocalScaleTo(new Vector3(1f, 4f), _duration).setLoops(LoopType.PingPong).setNextTween ( cube.ZKrotationTo(Quaternion.AngleAxis(180f, Vector3.one), _duration).setLoops(LoopType.PingPong) ) ) ) .start(); } GUILayout.Space(10); if (GUILayout.Button("Start Spring Position")) { _springTween = new TransformSpringTween(cube, TransformTargetType.Position, cube.position); } if (GUILayout.Button("Start Spring Position (overdamped)")) { _springTween = new TransformSpringTween(cube, TransformTargetType.Position, cube.position); _springTween.dampingRatio = 1.5f; _springTween.angularFrequency = 20f; } if (GUILayout.Button("Start Spring Scale")) { _springTween = new TransformSpringTween(cube, TransformTargetType.LocalScale, cube.localScale); } GUILayout.Space(10); if (GUILayout.Button("Run Action Every 1s After 2s Delay")) { ActionTask.every(2f, 1f, this, task => { // by using the context we get away with not allocating when passing this Action around! (task.context as ZestKitOtherGoodies).methodCalledForDemonstrationPurposes(); }); } if (GUILayout.Button("ActionTask Interoperability")) { Debug.Log("The Story: An ActionTask with a 2s delay will be created with a continueWith ActionTask appended to it that will tick every 0.3s for 2s. The original ActionTask will have a waitFor called that is an ActionTask with a 1s delay. Follow?"); Debug.Log("--- current time: " + Time.time); ActionTask.afterDelay(2f, this, task => { Debug.Log("--- root task ticked: " + Time.time); }).continueWith ( ActionTask.create(this, task => { Debug.Log("+++ continueWith task elapsed time: " + task.elapsedTime); if (task.elapsedTime > 2f) { task.stop(); } }) .setDelay(1f) .setRepeats(0.3f) ).waitFor ( ActionTask.afterDelay(1f, this, task => { Debug.Log("--- waitFor ticked: " + Time.time); }) ); } DemoGUIHelpers.easeTypesGUI(); } else { GUILayout.Label("While the spring tween is active the cube will spring to\n" + "whichever location you click or scale x/y to that location\n" + "if you chose a scale spring. The sliders below let you tweak\n" + "the spring contants.\n\n" + "For the scale tween, try clicking places on a horizontal or vertical\n" + "axis to get a feel for how it works."); springSliders(); var prefix = _springTween.targetType == TransformTargetType.Position ? "Spring position to:" : "Spring scale to:"; var mousePosWorld = Camera.main.ScreenToWorldPoint(Input.mousePosition); var labelText = string.Format("{0}\nx: {1:F1}\ny: {2:F1}", prefix, mousePosWorld.x, mousePosWorld.y); GUI.Label(new Rect(Input.mousePosition.x, Screen.height - Input.mousePosition.y - 50f, 130f, 50f), labelText); if (GUILayout.Button("Stop Spring")) { _springTween.stop(); _springTween = null; cube.position = new Vector3(-1f, -2f); cube.localScale = Vector3.one; } } }
public void HandleTouchOnBlackallAndTesser(FTouch touch) { FLabel touchedLetter = null; for (int i = 0; i < tesserLetters.Count; i++) { FLabel label = tesserLetters[i]; if (label == null) { continue; } Vector2 touchPos = label.GlobalToLocal(touch.position); if (label.textRect.Contains(touchPos)) { touchedLetter = label; break; } } for (int i = 0; i < blackallLetters.Count; i++) { FLabel label = blackallLetters[i]; if (label == null) { continue; } Vector2 touchPos = label.GlobalToLocal(touch.position); if (label.textRect.Contains(touchPos)) { touchedLetter = label; break; } } if (touchedLetter == null) { return; } touchWasUsedCorrectly = true; TweenChain chain = null; float duration = 0.2f; float extraRotation = 0f; // TESSER // T if (touchedLetter == tesserLetters[0]) { if (unsolidifiedTrebellaLetters.Contains(touchedLetter)) { FSoundManager.PlaySound("error"); return; } if (!movedT) { chain = TweenChainForLetter(touchedLetter, duration, trebellaFinalPositions[0].x, trebellaFinalPositions[0].y, extraRotation); movedT = true; unsolidifiedTrebellaLetters.Add(touchedLetter); } } // E if (touchedLetter == tesserLetters[1] || touchedLetter == tesserLetters[4]) { if (unsolidifiedTrebellaLetters.Contains(touchedLetter)) { FSoundManager.PlaySound("error"); return; } int index; if (numTouchedEs == 0) { index = 2; } else if (numTouchedEs == 1) { index = 4; } else { index = -1; } if (index != -1) { chain = TweenChainForLetter(touchedLetter, duration, trebellaFinalPositions[index].x, trebellaFinalPositions[index].y, extraRotation); numTouchedEs++; unsolidifiedTrebellaLetters.Add(touchedLetter); } else { int tesserIndex = 0; if (touchedLetter == tesserLetters[1]) { tesserIndex = 0; } else if (touchedLetter == tesserLetters[4]) { tesserIndex = 4; } KillLetter(touchedLetter); tesserLetters[tesserIndex] = null; numNonTrebellaLettersLeft--; } } // S if (touchedLetter == tesserLetters[2]) { KillLetter(touchedLetter); numNonTrebellaLettersLeft--; tesserLetters[2] = null; } // S if (touchedLetter == tesserLetters[3]) { KillLetter(touchedLetter); numNonTrebellaLettersLeft--; tesserLetters[3] = null; } // R if (touchedLetter == tesserLetters[5]) { if (unsolidifiedTrebellaLetters.Contains(touchedLetter)) { FSoundManager.PlaySound("error"); return; } if (!movedR) { chain = TweenChainForLetter(touchedLetter, duration, trebellaFinalPositions[1].x, trebellaFinalPositions[1].y, extraRotation); movedR = true; unsolidifiedTrebellaLetters.Add(touchedLetter); } } // BLACKALL // B if (touchedLetter == blackallLetters[0]) { if (unsolidifiedTrebellaLetters.Contains(touchedLetter)) { FSoundManager.PlaySound("error"); return; } if (!movedB) { chain = TweenChainForLetter(touchedLetter, duration, trebellaFinalPositions[3].x, trebellaFinalPositions[3].y, extraRotation); movedB = true; unsolidifiedTrebellaLetters.Add(touchedLetter); } } // L if (touchedLetter == blackallLetters[1] || touchedLetter == blackallLetters[6] || touchedLetter == blackallLetters[7]) { if (unsolidifiedTrebellaLetters.Contains(touchedLetter)) { FSoundManager.PlaySound("error"); return; } int index; if (numTouchedLs == 0) { index = 5; } else if (numTouchedLs == 1) { index = 6; } else { index = -1; } if (index != -1) { chain = TweenChainForLetter(touchedLetter, duration, trebellaFinalPositions[index].x, trebellaFinalPositions[index].y, extraRotation); numTouchedLs++; unsolidifiedTrebellaLetters.Add(touchedLetter); } else { int blackallIndex = 0; if (touchedLetter == blackallLetters[1]) { blackallIndex = 1; } else if (touchedLetter == blackallLetters[6]) { blackallIndex = 6; } else if (touchedLetter == blackallLetters[7]) { blackallIndex = 7; } KillLetter(touchedLetter); blackallLetters[blackallIndex] = null; numNonTrebellaLettersLeft--; } } // A if (touchedLetter == blackallLetters[2] || touchedLetter == blackallLetters[5]) { if (unsolidifiedTrebellaLetters.Contains(touchedLetter)) { FSoundManager.PlaySound("error"); return; } int index; if (numTouchedAs == 0) { index = 7; } else { index = -1; } if (index != -1) { chain = TweenChainForLetter(touchedLetter, duration, trebellaFinalPositions[index].x, trebellaFinalPositions[index].y, extraRotation); numTouchedAs++; unsolidifiedTrebellaLetters.Add(touchedLetter); } else { int blackallIndex = 0; if (touchedLetter == blackallLetters[2]) { blackallIndex = 2; } else if (touchedLetter == blackallLetters[5]) { blackallIndex = 5; } KillLetter(touchedLetter); blackallLetters[blackallIndex] = null; numNonTrebellaLettersLeft--; } } // C if (touchedLetter == blackallLetters[3]) { KillLetter(touchedLetter); blackallLetters[3] = null; numNonTrebellaLettersLeft--; } // K if (touchedLetter == blackallLetters[4]) { KillLetter(touchedLetter); blackallLetters[4] = null; numNonTrebellaLettersLeft--; } if (chain != null) { chain.setOnCompleteHandler(OnTrebellaLetterInPlace); Go.addTween(chain); chain.play(); } }
public LureRenderer(Actor actor, Player player, EyeRenderer eye, Level currentLevel) : base(actor) { MachinaGame.Assets.GetSoundEffectInstance("frog_bass").Play(); this.eye = eye; this.player = player; this.bubbleSpawner = RequireComponent <BubbleSpawner>(); var targetLocalPos = transform.LocalPosition; this.lureTween = new TweenChain(); var accessors = new TweenAccessors <float>(() => this.progress, val => this.progress = val); lureTween.AppendFloatTween(1f, 0.25f, EaseFuncs.QuadraticEaseOut, accessors); lureTween.AppendCallback(() => { var caughtFish = false; if (currentLevel.HarnessVulnerable) { foreach (var targetActor in actor.scene.GetAllActors()) { var harness = targetActor.GetComponent <Harness>(); if (harness != null && harness.HarnessRect.Contains(EndPos)) { harness.TakeDamage(); } } } foreach (var targetActor in actor.scene.GetAllActors()) { var jellyfish = targetActor.GetComponent <Jellyfish>(); if (jellyfish != null) { if (jellyfish.IsHit(transform.Position, lureSize)) { this.wasStunned = true; jellyfish.Hit(); } } } if (!wasStunned) { foreach (var targetActor in actor.scene.GetAllActors()) { var eatable = targetActor.GetComponent <Eatable>(); if (eatable != null) { if ((targetActor.transform.Position - transform.Position).Length() < this.lureSize + eatable.fish.HitRadius) { caughtFish = true; this.caughtFishSize = eatable.fish.Size; eatable.actor.Destroy(); break; } } } } if (!caughtFish) { foreach (var targetActor in actor.scene.GetAllActors()) { var plant = targetActor.GetComponent <Seaweed>(); if (plant != null) { var node = plant.NodeAt(transform.Position, this.lureSize); if (node != null) { this.wasStunned = true; plant.Hit(); } } } } if (caughtFish) { MachinaGame.Assets.GetSoundEffectInstance("bass").Play(); bubbleSpawner.SpawnBubble(EndPos, Vector2.Zero, 0.1f); bubbleSpawner.SpawnBubble(EndPos, Vector2.Zero, 0.2f); bubbleSpawner.SpawnBubble(EndPos, Vector2.Zero, 0.3f); bubbleSpawner.SpawnBubble(EndPos, Vector2.Zero, 0.4f); this.currentPhase = Phase.Caught; lureTween.AppendFloatTween(0f, 0.2f, EaseFuncs.QuadraticEaseOut, accessors); lureTween.AppendCallback(() => { this.currentPhase = Phase.Feeding; transform.LocalPosition = new Vector2(0, 0); }); lureTween.AppendWaitTween(0.25f); lureTween.AppendCallback(() => { this.currentPhase = Phase.Retracting; this.eye.ClearTween(); this.eye.TweenOpenAmountTo(2f, 0.1f); this.eye.TweenPlaySound("cthulu-wins"); this.eye.TweenOpenAmountTo(0f, 0.15f); this.eye.TweenOpenAmountTo(0f, 0.2f); // Stay closed this.eye.TweenOpenAmountTo(1f, 0.25f); }); lureTween.AppendCallback(() => { var rand = MachinaGame.Random.DirtyRandom; for (int i = 0; i < 10; i++) { bubbleSpawner.SpawnBubble(EndPos, new Vector2(rand.Next(-5, 5), rand.Next(5, 10)), 0f); } }); lureTween.AppendWaitTween(0.5f); lureTween.AppendFloatTween(0f, 1f, EaseFuncs.QuadraticEaseOut, accessors); } else { lureTween.AppendCallback(() => { if (wasStunned) { var s = MachinaGame.Assets.GetSoundEffectInstance("snare"); s.Pitch = -1f; s.Play(); } else { var s = MachinaGame.Assets.GetSoundEffectInstance("snare"); s.Pitch = 1f; s.Play(); } this.currentPhase = Phase.Retracting; var rand = MachinaGame.Random.DirtyRandom; for (int i = 0; i < 3; i++) { bubbleSpawner.SpawnBubble(EndPos, new Vector2(rand.Next(-5, 5), rand.Next(-5, 5)), 0f); } }); var retractDuration = 0.5f; if (this.wasStunned) { retractDuration = 2.5f; } lureTween.AppendFloatTween(0f, retractDuration, EaseFuncs.QuadraticEaseOut, accessors); } }); }
public void DisplayNextString() { if (stringQueue.Count == 0) { hasStringsToShow = false; NoStringsLeftToShow(); return; } float startX = defaultX; float startY = defaultY; float holdX = defaultX; float holdY = defaultY; float endX = defaultX; float endY = defaultY; label.text = stringQueue[0]; label.CreateTextQuads(); if (labelShowType == LabelShowType.SlideFromLeft) { startX = -label.textRect.width / 2f; } else if (labelShowType == LabelShowType.SlideFromRight) { startX = Futile.screen.width + label.textRect.width / 2f; } else if (labelShowType == LabelShowType.SlideFromTop) { startY = Futile.screen.height + label.textRect.height / 2f; } else if (labelShowType == LabelShowType.SlideFromBottom) { startY = -label.textRect.height / 2f; } if (labelHideType == LabelHideType.SlideToLeft) { endX = -label.textRect.width / 2f; } else if (labelHideType == LabelHideType.SlideToRight) { endX = Futile.screen.width + label.textRect.width / 2f; } else if (labelHideType == LabelHideType.SlideToTop) { endY = Futile.screen.height + label.textRect.height / 2f; } else if (labelHideType == LabelHideType.SlideToBottom) { endY = -label.textRect.height / 2f; } label.x = startX; label.y = startY; Tween inTween = new Tween(label, inDuration, new TweenConfig() .floatProp("x", holdX) .floatProp("y", holdY) .onComplete(DoneMovingLabelIntoPlace) .setEaseType(easeType)); float holdDuration = defaultHoldDuration; if (shouldIncreaseHoldDurationBasedOnStringLength) holdDuration = Mathf.Max((float)(label.text.Length / 10), 3.0f); Tween holdTween = new Tween(label, holdDuration, new TweenConfig() .floatProp("x", 0, true) // just to fake it into thinking it has a real tween .onComplete(StartingToAnimateLabelOut)); Tween outTween = new Tween(label, outDuration, new TweenConfig() .floatProp("x", endX) .floatProp("y", endY) .setEaseType(easeType)); TweenChain chain = new TweenChain(); chain.append(inTween).append(holdTween).append(outTween); chain.setOnCompleteHandler(DoneShowingLabel); Go.addTween(chain); chain.play(); labelIsAnimating = true; label.isVisible = true; }
private void HandleGameComplete(AbstractTween tween) { Go.to(playArea, 0.3f, new TweenConfig().floatProp("scale", 0f).floatProp("alpha", 0.0f)); TweenChain chain = new TweenChain(); chain.append(new Tween(_bestScoreLabel, 1f, new TweenConfig().setEaseType(EaseType.SineOut).floatProp("anchorX", 0.5f) .floatProp("anchorY", 0.5f) .floatProp("scale", 1f) .floatProp("x", 0.0f) .floatProp("y", 0.0f))); bool highscoreGET = false; for(int i = 0; i < FScoreManager.Scores.Count; i++){ if(BaseMain.Instance._score > (long)FScoreManager.Scores[i]) highscoreGET = true; } if(highscoreGET){ _bestScoreLabel.text = string.Format("new high score:\n{0}", BaseMain.Instance._score); Tween move = new Tween(_bestScoreLabel, 0.5f, new TweenConfig().floatProp("alpha", 0).setIterations(6, LoopType.PingPong)); this.AddChild(new FKeyBoard("BitOut", HandleUpdate, setText)); chain.append(move); }else{ _bestScoreLabel.text = string.Format("score: {0}", BaseMain.Instance._score); } chain.setOnCompleteHandler(HandleGameComplete2); chain.play(); }
public void EndGame() { FlyOutUIElements(); scoreLabel.text = string.Format("{0:#,###0}", score); for (int i = hearts.Count - 1; i >= 0; i--) { FSprite heart = hearts[i]; foreach (AbstractTween tween in Go.tweensWithTarget(heart)) { Go.removeTween(tween); } heart.RemoveFromContainer(); hearts.Remove(heart); } if (score >= 1000000) { StartHeartShower(); FSoundManager.StopMusic(); FSoundManager.PlaySound("happyPiano"); gameIsOver = true; FLabel label = new FLabel("SoftSugar", "I love you times a million!"); label.color = new Color(0.12f, 0.12f, 0.12f, 1.0f); label.x = Futile.screen.halfWidth; label.y = Futile.screen.halfHeight; label.scale = 0; AddChild(label); TweenConfig config = new TweenConfig() .floatProp("scale", 1.0f) .setEaseType(EaseType.SineInOut) .onComplete(OnWinLabelDoneAppearing); Go.to(label, 0.5f, config); } if (numHeartsMissed >= 5) { gameIsOver = true; FSoundManager.StopMusic(); FSoundManager.PlaySound("sadPiano"); FLabel topLabel = new FLabel("SoftSugar", "Are you kidding me?!"); FLabel bottomLabel = new FLabel("SoftSugar", string.Format("I love you way more than x{0:#,###0}!", score)); topLabel.color = new Color(0.75f, 0.12f, 0.12f, 1.0f); bottomLabel.color = new Color(0.12f, 0.12f, 0.12f, 1.0f); bottomLabel.x = topLabel.x = Futile.screen.halfWidth; float bottomBeginning = 300f; float segmentHeight = (Futile.screen.height - bottomBeginning * 2f) / 3f; bottomLabel.y = segmentHeight - bottomLabel.textRect.height / 2f + bottomBeginning; topLabel.y = segmentHeight * 3f - topLabel.textRect.height / 2f + bottomBeginning; bottomLabel.scale = topLabel.scale = 0; AddChild(topLabel); AddChild(bottomLabel); TweenConfig config1 = new TweenConfig() .floatProp("scale", 1.0f) .setEaseType(EaseType.SineInOut); TweenConfig config2 = new TweenConfig() .floatProp("scale", 0.75f) .setEaseType(EaseType.SineInOut); float duration = 0.5f; TweenChain chain = new TweenChain(); chain.append(new Tween(topLabel, duration, config1)); chain.append(new Tween(bottomLabel, duration, config2)); chain.setOnCompleteHandler(OnGameShouldBeFullyOver); Go.addTween(chain); chain.play(); } }
public void UpdateGoal() { if (totalDistance < goalDistance - 1000f || initiatedSceneSwitch) return; if (goalType == GoalType.GoalOne) { if (faceCoin == null) { faceCoin = new FSprite("danaHappy.png"); faceCoin.x = Futile.screen.width + 100f; faceCoin.y = 250f; everythingContainer.AddChild(faceCoin); everythingContainer.AddChild(whit); // move him to top Tween tween1 = new Tween(faceCoin, 0.5f, new TweenConfig() .floatProp("scaleX", -1.0f) .setEaseType(EaseType.SineInOut)); Tween tween2 = new Tween(faceCoin, 0.5f, new TweenConfig() .floatProp("scaleX", 1.0f) .setEaseType(EaseType.SineInOut)); TweenChain chain = new TweenChain(); chain.setIterations(-1); chain.append(tween1); chain.append(tween2); Go.addTween(chain); chain.play(); } faceCoin.x += Time.fixedDeltaTime * universalVelocity; if (faceCoin.x < 100f) { initiatedSceneSwitch = true; FSoundManager.PlaySound("success"); TMain.SwitchToScene(TMain.SceneType.DreamSceneOne); } } else if (goalType == GoalType.GoalTwo) { if (bigHeartCoin == null) { bigHeartCoin = new FSprite("heart.psd"); bigHeartCoin.scale = 2.0f; bigHeartCoin.x = Futile.screen.width + 100f; bigHeartCoin.color = new Color(1.0f, 0.2f, 0.2f, 1.0f); bigHeartCoin.y = 250f; everythingContainer.AddChild(bigHeartCoin); everythingContainer.AddChild(whit); // move to top Tween tween1 = new Tween(bigHeartCoin, 0.5f, new TweenConfig() .floatProp("scaleX", -1.0f) .setEaseType(EaseType.SineInOut)); Tween tween2 = new Tween(bigHeartCoin, 0.5f, new TweenConfig() .floatProp("scaleX", 1.0f) .setEaseType(EaseType.SineInOut)); TweenChain chain = new TweenChain(); chain.setIterations(-1); chain.append(tween1); chain.append(tween2); Go.addTween(chain); chain.play(); } bigHeartCoin.x += Time.fixedDeltaTime * universalVelocity; if (bigHeartCoin.x < 100f) { initiatedSceneSwitch = true; FSoundManager.StopMusic(); FSoundManager.PlaySound("success"); TMain.SwitchToScene(TMain.SceneType.DreamSceneTwo); } } else if (goalType == GoalType.GoalThree) { if (dana == null) { dana = new TWalkingCharacter("danaHead.png"); dana.x = Futile.screen.width + 100f; dana.y = 250f; everythingContainer.AddChild(dana); dana.StartWalking(); } dana.x += Time.fixedDeltaTime * universalVelocity * 0.25f; if (dana.x < 350f) { start.isVisible = goal.isVisible = false; FSoundManager.PlayMusic("yay"); foundEachother = true; dana.TurnAround(); dana.StopWalking(); whit.StopWalking(); parallaxScene.StopUpdating(); whit.StopCrouching(); StartHeartShower(); } } }
public void UpdateSolidifyingTrebellaLetters() { timeSinceLastSolidifiedLetter += Time.deltaTime; if (timeSinceLastSolidifiedLetter > 0.5f) { timeSinceLastSolidifiedLetter -= 0.5f; FLabel nextLetterToChange = null; switch (numLettersSolidified) { case 0: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "T") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 1: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "R") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 2: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "E") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 3: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "B") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 4: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "E") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 5: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "L") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 6: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "L") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; case 7: foreach (FLabel letter in unsolidifiedTrebellaLetters) { if (letter.text == "A") { nextLetterToChange = letter; unsolidifiedTrebellaLetters.Remove(letter); break; } } break; } FSoundManager.PlaySound("bomb", 2.0f); FLabel solidifiedLetter = trebellaLetters[numLettersSolidified]; solidifiedLetter.x = nextLetterToChange.x; solidifiedLetter.y = nextLetterToChange.y; nextLetterToChange.RemoveFromContainer(); float duration = 0.2f; float distance = 5f; Tween bounce = new Tween(solidifiedLetter, duration, new TweenConfig() .setEaseType(EaseType.SineInOut) .floatProp("y", distance, true)); Tween bounceBack = new Tween(solidifiedLetter, duration, new TweenConfig() .setEaseType(EaseType.SineInOut) .floatProp("y", -distance, true)); TweenChain chain = new TweenChain(); chain.setIterations(-1, LoopType.RestartFromBeginning); chain.append(bounce); chain.append(bounceBack); Go.addTween(chain); chain.play(); numLettersSolidified++; if (numLettersSolidified >= 8) trebellaLettersDoneSolidifying = true; } }
private void showGrid(float width, float height) { TweenChain chainY = new TweenChain(); TweenChain chainX = new TweenChain(); for(float y = height/2;y >= -height/2;y-=64) { FSliceSprite ss = new FSliceSprite(Futile.whiteElement, width, 1, 0, 0, 0, 0); ss.y = y; ss.x = -width; AddChild(ss); Tween t = new Tween(ss, 3 / (height / 64), new TweenConfig().floatProp("x", 0), null); chainY.append(t); } for(float x = -width/2;x<= width/2;x+=64) { FSliceSprite ss = new FSliceSprite(Futile.whiteElement, 1, height, 0, 0, 0, 0); ss.x = x; ss.y = height; AddChild(ss); Tween t = new Tween(ss, 3 / (width / 64), new TweenConfig().floatProp("y", 0), null); chainX.append(t); } chainY.play(); chainX.play(); }
void OnGUI() { DemoGUIHelpers.setupGUIButtons(); _duration = DemoGUIHelpers.durationSlider(_duration); if (_springTween == null) { if (GUILayout.Button("Custom Property Tween (wackyDoodleWidth)")) { PropertyTweens.floatPropertyTo(this, "wackyDoodleWidth", 1f, 6f, _duration) .setLoops(LoopType.PingPong) .start(); } if (GUILayout.Button("Position via Property Tween")) { PropertyTweens.vector3PropertyTo(cube, "position", cube.position, new Vector3(5f, 5f, 5f), _duration) .setLoops(LoopType.PingPong) .start(); } if (GUILayout.Button("Tween Party (color, position, scale and rotation)")) { var party = new TweenParty(_duration); party.addTween(cube.GetComponent <Renderer>().material.ZKcolorTo(Color.black)) .addTween(cube.ZKpositionTo(new Vector3(7f, 4f))) .addTween(cube.ZKlocalScaleTo(new Vector3(1f, 4f))) .addTween(cube.ZKrotationTo(Quaternion.AngleAxis(180f, Vector3.one))) .setLoops(LoopType.PingPong) .start(); } if (GUILayout.Button("Tween Chain (same props as the party)")) { var chain = new TweenChain(); chain.appendTween(cube.GetComponent <Renderer>().material.ZKcolorTo(Color.black, _duration).setLoops(LoopType.PingPong)) .appendTween(cube.ZKpositionTo(new Vector3(7f, 4f), _duration).setLoops(LoopType.PingPong)) .appendTween(cube.ZKlocalScaleTo(new Vector3(1f, 4f), _duration).setLoops(LoopType.PingPong)) .appendTween(cube.ZKrotationTo(Quaternion.AngleAxis(180f, Vector3.one), _duration).setLoops(LoopType.PingPong)) .start(); } if (GUILayout.Button("Chaining Tweens Directly (same props as the party)")) { cube.GetComponent <Renderer>().material.ZKcolorTo(Color.black).setLoops(LoopType.PingPong) .setNextTween ( cube.ZKpositionTo(new Vector3(7f, 4f)).setLoops(LoopType.PingPong).setNextTween ( cube.ZKlocalScaleTo(new Vector3(1f, 4f)).setLoops(LoopType.PingPong).setNextTween ( cube.ZKrotationTo(Quaternion.AngleAxis(180f, Vector3.one)).setLoops(LoopType.PingPong) ) ) ) .start(); } if (GUILayout.Button("Start Spring Position")) { _springTween = new TransformSpringTween(cube, TransformTargetType.Position, cube.position); } if (GUILayout.Button("Start Spring Scale")) { _springTween = new TransformSpringTween(cube, TransformTargetType.LocalScale, cube.localScale); } } else { GUILayout.Label("While the spring tween is active the cube will spring to\n" + "whichever location you click or scale x/y to that location\n" + "if you chose a scale spring. The sliders below let you tweak\n" + "the spring contants.\n\n" + "For the scale tween, try clicking places on a horizontal or vertical\n" + "axis to get a feel for how it works."); springSliders(); if (GUILayout.Button("Stop Spring")) { _springTween.stop(); _springTween = null; cube.position = new Vector3(-1f, -2f); cube.localScale = Vector3.one; } } DemoGUIHelpers.easeTypesGUI(); }
void OnGUI() { DemoGUIHelpers.setupGUIButtons(); if( _springTween == null ) { _duration = DemoGUIHelpers.durationSlider( _duration ); if( GUILayout.Button( "Custom Property Tween (wackyDoodleWidth)" ) ) { PropertyTweens.floatPropertyTo( this, "wackyDoodleWidth", 6f, _duration ) .setFrom( 1f ) .setLoops( LoopType.PingPong ) .start(); } if( GUILayout.Button( "Position via Property Tween" ) ) { PropertyTweens.vector3PropertyTo( cube, "position", new Vector3( 5f, 5f, 5f ), _duration ) .setLoops( LoopType.PingPong ) .start(); } if( GUILayout.Button( "Tween Party (color, position, scale and rotation)" ) ) { var party = new TweenParty( _duration ); party.addTween( cube.GetComponent<Renderer>().material.ZKcolorTo( Color.black ) ) .addTween( cube.ZKpositionTo( new Vector3( 7f, 4f ) ) ) .addTween( cube.ZKlocalScaleTo( new Vector3( 1f, 4f ) ) ) .addTween( cube.ZKrotationTo( Quaternion.AngleAxis( 180f, Vector3.one ) ) ) .setLoops( LoopType.PingPong ) .start(); } if( GUILayout.Button( "Tween Chain (same props as the party)" ) ) { var chain = new TweenChain(); chain.appendTween( cube.GetComponent<Renderer>().material.ZKcolorTo( Color.black, _duration ).setLoops( LoopType.PingPong ) ) .appendTween( cube.ZKpositionTo( new Vector3( 7f, 4f ), _duration ).setLoops( LoopType.PingPong ) ) .appendTween( cube.ZKlocalScaleTo( new Vector3( 1f, 4f ), _duration ).setLoops( LoopType.PingPong ) ) .appendTween( cube.ZKrotationTo( Quaternion.AngleAxis( 180f, Vector3.one ), _duration ).setLoops( LoopType.PingPong ) ) .start(); } if( GUILayout.Button( "Chaining Tweens Directly (same props as the party)" ) ) { cube.GetComponent<Renderer>().material.ZKcolorTo( Color.black, _duration ).setLoops( LoopType.PingPong ) .setNextTween ( cube.ZKpositionTo( new Vector3( 7f, 4f ), _duration ).setLoops( LoopType.PingPong ).setNextTween ( cube.ZKlocalScaleTo( new Vector3( 1f, 4f ), _duration ).setLoops( LoopType.PingPong ).setNextTween ( cube.ZKrotationTo( Quaternion.AngleAxis( 180f, Vector3.one ), _duration ).setLoops( LoopType.PingPong ) ) ) ) .start(); } GUILayout.Space( 10 ); if( GUILayout.Button( "Start Spring Position" ) ) { _springTween = new TransformSpringTween( cube, TransformTargetType.Position, cube.position ); } if( GUILayout.Button( "Start Spring Position (overdamped)" ) ) { _springTween = new TransformSpringTween( cube, TransformTargetType.Position, cube.position ); _springTween.dampingRatio = 1.5f; _springTween.angularFrequency = 20f; } if( GUILayout.Button( "Start Spring Scale" ) ) { _springTween = new TransformSpringTween( cube, TransformTargetType.LocalScale, cube.localScale ); } GUILayout.Space( 10 ); if( GUILayout.Button( "Run Action Every 1s After 2s Delay" ) ) { ActionTask.every( 2f, 1f, this, task => { // by using the context we get away with not allocating when passing this Action around! ( task.context as ZestKitOtherGoodies ).methodCalledForDemonstrationPurposes(); }); } if( GUILayout.Button( "ActionTask Interoperability" ) ) { Debug.Log( "The Story: An ActionTask with a 2s delay will be created with a continueWith ActionTask appended to it that will tick every 0.3s for 2s. The original ActionTask will have a waitFor called that is an ActionTask with a 1s delay. Follow?" ); Debug.Log( "--- current time: " + Time.time ); ActionTask.afterDelay( 2f, this, task => { Debug.Log( "--- root task ticked: " + Time.time ); }).continueWith ( ActionTask.create( this, task => { Debug.Log( "+++ continueWith task elapsed time: " + task.elapsedTime ); if( task.elapsedTime > 2f ) task.stop(); }) .setDelay( 1f ) .setRepeats( 0.3f ) ).waitFor ( ActionTask.afterDelay( 1f, this, task => { Debug.Log( "--- waitFor ticked: " + Time.time ); }) ); } DemoGUIHelpers.easeTypesGUI(); } else { GUILayout.Label( "While the spring tween is active the cube will spring to\n" + "whichever location you click or scale x/y to that location\n" + "if you chose a scale spring. The sliders below let you tweak\n" + "the spring contants.\n\n" + "For the scale tween, try clicking places on a horizontal or vertical\n" + "axis to get a feel for how it works."); springSliders(); var prefix = _springTween.targetType == TransformTargetType.Position ? "Spring position to:" : "Spring scale to:"; var mousePosWorld = Camera.main.ScreenToWorldPoint( Input.mousePosition ); var labelText = string.Format( "{0}\nx: {1:F1}\ny: {2:F1}", prefix, mousePosWorld.x, mousePosWorld.y ); GUI.Label( new Rect( Input.mousePosition.x, Screen.height - Input.mousePosition.y - 50f, 130f, 50f ), labelText ); if( GUILayout.Button( "Stop Spring" ) ) { _springTween.stop(); _springTween = null; cube.position = new Vector3( -1f, -2f ); cube.localScale = Vector3.one; } } }
public void EndGame() { FlyOutUIElements(); scoreLabel.text = string.Format("{0:#,###0}", score); for (int i = hearts.Count - 1; i >= 0; i--) { FSprite heart = hearts[i]; foreach (AbstractTween tween in Go.tweensWithTarget(heart)) Go.removeTween(tween); heart.RemoveFromContainer(); hearts.Remove(heart); } if (score >= 1000000) { StartHeartShower(); FSoundManager.StopMusic(); FSoundManager.PlaySound("happyPiano"); gameIsOver = true; FLabel label = new FLabel("SoftSugar", "I love you times a million!"); label.color = new Color(0.12f, 0.12f, 0.12f, 1.0f); label.x = Futile.screen.halfWidth; label.y = Futile.screen.halfHeight; label.scale = 0; AddChild(label); TweenConfig config = new TweenConfig() .floatProp("scale", 1.0f) .setEaseType(EaseType.SineInOut) .onComplete(OnWinLabelDoneAppearing); Go.to(label, 0.5f, config); } if (numHeartsMissed >= 5) { gameIsOver = true; FSoundManager.StopMusic(); FSoundManager.PlaySound("sadPiano"); FLabel topLabel = new FLabel("SoftSugar", "Are you kidding me?!"); FLabel bottomLabel = new FLabel("SoftSugar", string.Format("I love you way more than x{0:#,###0}!", score)); topLabel.color = new Color(0.75f, 0.12f, 0.12f, 1.0f); bottomLabel.color = new Color(0.12f, 0.12f, 0.12f, 1.0f); bottomLabel.x = topLabel.x = Futile.screen.halfWidth; float bottomBeginning = 300f; float segmentHeight = (Futile.screen.height - bottomBeginning * 2f) / 3f; bottomLabel.y = segmentHeight - bottomLabel.textRect.height / 2f + bottomBeginning; topLabel.y = segmentHeight * 3f - topLabel.textRect.height / 2f + bottomBeginning; bottomLabel.scale = topLabel.scale = 0; AddChild(topLabel); AddChild(bottomLabel); TweenConfig config1 = new TweenConfig() .floatProp("scale", 1.0f) .setEaseType(EaseType.SineInOut); TweenConfig config2 = new TweenConfig() .floatProp("scale", 0.75f) .setEaseType(EaseType.SineInOut); float duration = 0.5f; TweenChain chain = new TweenChain(); chain.append(new Tween(topLabel, duration, config1)); chain.append(new Tween(bottomLabel, duration, config2)); chain.setOnCompleteHandler(OnGameShouldBeFullyOver); Go.addTween(chain); chain.play(); } }
public TweenChainComponent(Actor actor) : base(actor) { this.chain = new TweenChain(); }
public void DisplayNextString() { if (stringQueue.Count == 0) { hasStringsToShow = false; NoStringsLeftToShow(); return; } float startX = defaultX; float startY = defaultY; float holdX = defaultX; float holdY = defaultY; float endX = defaultX; float endY = defaultY; label.text = stringQueue[0]; label.CreateTextQuads(); if (labelShowType == LabelShowType.SlideFromLeft) { startX = -label.textRect.width / 2f; } else if (labelShowType == LabelShowType.SlideFromRight) { startX = Futile.screen.width + label.textRect.width / 2f; } else if (labelShowType == LabelShowType.SlideFromTop) { startY = Futile.screen.height + label.textRect.height / 2f; } else if (labelShowType == LabelShowType.SlideFromBottom) { startY = -label.textRect.height / 2f; } if (labelHideType == LabelHideType.SlideToLeft) { endX = -label.textRect.width / 2f; } else if (labelHideType == LabelHideType.SlideToRight) { endX = Futile.screen.width + label.textRect.width / 2f; } else if (labelHideType == LabelHideType.SlideToTop) { endY = Futile.screen.height + label.textRect.height / 2f; } else if (labelHideType == LabelHideType.SlideToBottom) { endY = -label.textRect.height / 2f; } label.x = startX; label.y = startY; Tween inTween = new Tween(label, inDuration, new TweenConfig() .floatProp("x", holdX) .floatProp("y", holdY) .onComplete(DoneMovingLabelIntoPlace) .setEaseType(easeType)); float holdDuration = defaultHoldDuration; if (shouldIncreaseHoldDurationBasedOnStringLength) { holdDuration = Mathf.Max((float)(label.text.Length / 10), 3.0f); } Tween holdTween = new Tween(label, holdDuration, new TweenConfig() .floatProp("x", 0, true) // just to fake it into thinking it has a real tween .onComplete(StartingToAnimateLabelOut)); Tween outTween = new Tween(label, outDuration, new TweenConfig() .floatProp("x", endX) .floatProp("y", endY) .setEaseType(easeType)); TweenChain chain = new TweenChain(); chain.append(inTween).append(holdTween).append(outTween); chain.setOnCompleteHandler(DoneShowingLabel); Go.addTween(chain); chain.play(); labelIsAnimating = true; label.isVisible = true; }
public void UpdateGoal() { if (totalDistance < goalDistance - 1000f || initiatedSceneSwitch) { return; } if (goalType == GoalType.GoalOne) { if (faceCoin == null) { faceCoin = new FSprite("danaHappy.png"); faceCoin.x = Futile.screen.width + 100f; faceCoin.y = 250f; everythingContainer.AddChild(faceCoin); everythingContainer.AddChild(whit); // move him to top Tween tween1 = new Tween(faceCoin, 0.5f, new TweenConfig() .floatProp("scaleX", -1.0f) .setEaseType(EaseType.SineInOut)); Tween tween2 = new Tween(faceCoin, 0.5f, new TweenConfig() .floatProp("scaleX", 1.0f) .setEaseType(EaseType.SineInOut)); TweenChain chain = new TweenChain(); chain.setIterations(-1); chain.append(tween1); chain.append(tween2); Go.addTween(chain); chain.play(); } faceCoin.x += Time.fixedDeltaTime * universalVelocity; if (faceCoin.x < 100f) { initiatedSceneSwitch = true; FSoundManager.PlaySound("success"); TMain.SwitchToScene(TMain.SceneType.DreamSceneOne); } } else if (goalType == GoalType.GoalTwo) { if (bigHeartCoin == null) { bigHeartCoin = new FSprite("heart.psd"); bigHeartCoin.scale = 2.0f; bigHeartCoin.x = Futile.screen.width + 100f; bigHeartCoin.color = new Color(1.0f, 0.2f, 0.2f, 1.0f); bigHeartCoin.y = 250f; everythingContainer.AddChild(bigHeartCoin); everythingContainer.AddChild(whit); // move to top Tween tween1 = new Tween(bigHeartCoin, 0.5f, new TweenConfig() .floatProp("scaleX", -1.0f) .setEaseType(EaseType.SineInOut)); Tween tween2 = new Tween(bigHeartCoin, 0.5f, new TweenConfig() .floatProp("scaleX", 1.0f) .setEaseType(EaseType.SineInOut)); TweenChain chain = new TweenChain(); chain.setIterations(-1); chain.append(tween1); chain.append(tween2); Go.addTween(chain); chain.play(); } bigHeartCoin.x += Time.fixedDeltaTime * universalVelocity; if (bigHeartCoin.x < 100f) { initiatedSceneSwitch = true; FSoundManager.StopMusic(); FSoundManager.PlaySound("success"); TMain.SwitchToScene(TMain.SceneType.DreamSceneTwo); } } else if (goalType == GoalType.GoalThree) { if (dana == null) { dana = new TWalkingCharacter("danaHead.png"); dana.x = Futile.screen.width + 100f; dana.y = 250f; everythingContainer.AddChild(dana); dana.StartWalking(); } dana.x += Time.fixedDeltaTime * universalVelocity * 0.25f; if (dana.x < 350f) { start.isVisible = goal.isVisible = false; FSoundManager.PlayMusic("yay"); foundEachother = true; dana.TurnAround(); dana.StopWalking(); whit.StopWalking(); parallaxScene.StopUpdating(); whit.StopCrouching(); StartHeartShower(); } } }