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; }
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(); }
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 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 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 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(); } }