public IEnumerator Blackout() { blackout.enabled = true; blur.enabled = true; int started = 0; Go.addTween(new GoTween(blackout, 0.1f, new GoTweenConfig() .floatProp("RampOffset", -1f) .setDelay(0.2f) .setEaseType(GoEaseType.Linear), (tween) => started--)); started++; Go.addTween(new GoTween(blur, 0.3f, new GoTweenConfig() .floatProp("BlurSpread", 1) .intProp("Iterations", 10) .setEaseType(GoEaseType.Linear), (tween) => started--)); started++; yield return(new WaitUntil(() => started == 0)); }
void SetupShowMainTableTweens() { Go.defaultEaseType = GoEaseType.AnimationCurve; var overworldCameraPositionProperty = new PositionTweenProperty(overworldCameraTweenEndPosition, false, true); var overworldCameraTweenConfig = new GoTweenConfig(); overworldCameraTweenConfig.addTweenProperty(overworldCameraPositionProperty); overworldCameraTweenConfig.startPaused(); overworldCameraTweenConfig.easeCurve = showMainTableTweenCurve; overworldCameraTweenConfig.onCompleteHandler = OnOverworldCameraTweenComplete; overworldCameraTween = new GoTween(overworldCameraTransform, showMainTableTweenTime, overworldCameraTweenConfig); overworldCameraTween.autoRemoveOnComplete = false; Go.addTween(overworldCameraTween); var directionalLightRotationProperty = new RotationTweenProperty(directionalLightTweenEndRotation); var directionalLightTweenConfig = new GoTweenConfig(); directionalLightTweenConfig.addTweenProperty(directionalLightRotationProperty); directionalLightTweenConfig.startPaused(); directionalLightTweenConfig.easeCurve = setSunTweenCurve; directionalLightTween = new GoTween(directionalLightTransform, setSunTweenTime, directionalLightTweenConfig); directionalLightTween.autoRemoveOnComplete = false; Go.addTween(directionalLightTween); }
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(); }
void ExplodeHeartsFromPoint(Vector2 point) { int heartsFound = 0; foreach (FSprite heart in hearts) { if (heartsFound >= 50) { break; } if (heart.container == null) { heartsFound++; heart.x = point.x; heart.y = point.y; AddChild(heart); float duration = Random.Range(0.1f, 1.5f); float xMovement = Random.Range(-600f, 600f); float yMovement = Random.Range(-600f, 600f); float rotationAmt = Random.Range(-360f, 360f); Tween tween = new Tween(heart, duration, new TweenConfig() .onComplete(OnHeartFinished) .floatProp("alpha", 0.0f) .floatProp("x", xMovement, true) .floatProp("y", yMovement, true) .floatProp("rotation", rotationAmt, true) .setEaseType(EaseType.SineInOut)); Go.addTween(tween); tween.play(); } } }
public IEnumerator Flip(string name, bool horizontal = true, bool vertical = false, float duration = 1f, GoEaseType type = GoEaseType.QuadInOut) { var go = GameObject.Find(name); if (!go) { yield return(null); } else { var ended = false; var handler = ElementHandlerFactory.Instance.CreateHandlerFor(go); Go.addTween(new GoTween(handler, duration, new GoTweenConfig() .setEaseType(type) .vector3Prop("Scale", new Vector3( (horizontal ? -1 : 1) * handler.Scale.x, (vertical ? -1 : 1) * handler.Scale.y, transform.localScale.z)), (tween) => ended = true )); yield return(new WaitUntil(() => ended)); } }
public void Grow() { //HERE I GROW; if (growTween != null) { growTween.pause(); } finishScale += 0.01f; Vector3 newScale = new Vector3(finishScale, finishScale, transform.localScale.z); var scaleProperty = new ScaleTweenProperty(newScale); tweenConfig = new GoTweenConfig(); //config.setDelay( 1f ); tweenConfig.addTweenProperty(scaleProperty); growTween = new GoTween(transform, 1f, tweenConfig); Go.addTween(growTween); }
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; }
internal static GoTweenFlow Start(this GoTweenFlow self) { Go.addTween(self); return(self); }
internal static GoTweenChain Start(this GoTweenChain self) { Go.addTween(self); return(self); }
public TPeopleScene(GoalType goalType) : base("") { FSprite background = SquareMaker.Square(Futile.screen.width, Futile.screen.height); background.color = Color.black; background.x = Futile.screen.halfWidth; background.y = Futile.screen.halfHeight; AddChild(background); startOverLabel = new FLabel("SoftSugar", "Any key or click\nto start completely over"); startOverLabel.x = Futile.screen.halfWidth; startOverLabel.y = Futile.screen.halfHeight; startOverLabel.alpha = 0; AddChild(startOverLabel); everythingContainer = new FContainer(); AddChild(everythingContainer); parallaxScene = new TParallaxScene(new Color(0.7f, 0.9f, 1.0f, 1.0f)); parallaxScene.foregroundVelocity = universalVelocity; parallaxScene.AddLayerWithImageName("mountains0.png", 0.15f, 0, true); parallaxScene.AddLayerWithImageName("mountains1.png", 0.3f, 0, true); parallaxScene.AddLayerWithImageName("cloud.psd", 0.2f, Futile.screen.halfHeight + 100f, false); parallaxScene.AddLayerWithImageName("ground.psd", 1.0f, 0, true); parallaxScene.StartUpdating(); everythingContainer.AddChild(parallaxScene); FSprite fog = SquareMaker.Square(Futile.screen.width, Futile.screen.height); fog.x = Futile.screen.halfWidth; fog.y = Futile.screen.halfHeight; fog.color = Color.black; fog.alpha = 0.5f; everythingContainer.AddChild(fog); this.goalType = goalType; tutorialIsDone = TMain.goalOneTutorialIsDone; if (this.goalType == GoalType.GoalOne) { goalDistance = 20000f; } else if (this.goalType == GoalType.GoalTwo) { goalDistance = 30000f; } else if (this.goalType == GoalType.GoalThree) { goalDistance = 50000f; } FSoundManager.PlayMusic("jazz"); SetupHeartTokens(); SetupUIElements(); SetupTutorial(); SetupHeartShower(); SetupFinalNote(); if (this.goalType == GoalType.GoalTwo) { FLabel label = new FLabel("SoftSugar", "\"I hope Dana's around\nhere somewhere!\""); label.x = Futile.screen.halfWidth; label.y = Futile.screen.height - 100f; everythingContainer.AddChild(label); Tween tween = new Tween(label, 0.3f, new TweenConfig() .setDelay(3.0f) .floatProp("y", Futile.screen.height + 200f) .setEaseType(EaseType.SineInOut)); Go.addTween(tween); tween.play(); } else if (this.goalType == GoalType.GoalThree) { FLabel label = new FLabel("SoftSugar", "\"Will I ever survive\nwithout her?\""); label.x = Futile.screen.halfWidth; label.y = Futile.screen.height - 100f; everythingContainer.AddChild(label); Tween tween = new Tween(label, 0.3f, new TweenConfig() .setDelay(3.0f) .floatProp("y", Futile.screen.height + 200f) .setEaseType(EaseType.SineInOut)); Go.addTween(tween); tween.play(); } whit = new TWalkingCharacter("whitHead.png"); whit.x = 130f; whit.y = 250f; everythingContainer.AddChild(whit); whit.StartWalking(); TBorderLayer borderLayer = new TBorderLayer(Futile.screen.width, Futile.screen.height, 5f, new Color(0.2f, 0.2f, 0.2f, 1.0f)); everythingContainer.AddChild(borderLayer); }
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 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 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 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; } } }