Block.CreateDisappearTransition C# (CSharp) Method

CreateDisappearTransition() public method

Creates a transition which disappears the block and spawns a score label in its place, which will itself disappear after some time.
public CreateDisappearTransition ( int score ) : U9Transition,
score int Score.
return U9Transition,
	public U9Transition CreateDisappearTransition( int score ) {

		U9Transition scorePopupTransition = null;

		//U9Transition blockDisappearTransition = U9T.HOT (iTween.ScaleTo, squareSprite.gameObject, iTween.Hash ("scale", Vector3.zero, "time", 0.25f, "easetype", iTween.EaseType.easeInOutQuad ));

		//U9Transition bDT = U9T.HOT (HOTween.To, Scaling, 0.25f, new TweenParms().Prop("localScale", Vector3.zero, false).Ease(EaseType.EaseInOutQuad));
		U9Transition bDLT = U9T.LT (LeanTween.scale, squareGO, Vector3.zero, 0.25f, iTween.Hash("ease", LeanTweenType.easeInOutQuad));

		if (score > 0) 
		{
			/*GameObject popupScoreInstance = (GameObject)Instantiate(scorePrefab[score-3], transform.position, Quaternion.identity);
			popupScoreInstance.transform.parent = transform;
			popupScoreInstance.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);

			int materialIn = 5*(score-3);
			for(int i = materialIn; i < 5 + materialIn; i++)
			{
				if(scoreMaterial[i].color == color)
				{
					Color newColor = new Color(scoreMaterial[i].color.r, scoreMaterial[i].color.g, scoreMaterial[i].color.b, 0);
					popupScoreInstance.renderer.material.color = newColor;
					break;
				}
			}

			U9Transition ScaleIn = U9T.LT (LeanTween.scale, popupScoreInstance, new Vector3(53f, 53f, 53f), 1f, iTween.Hash("ease", LeanTweenType.linear));
			U9Transition FadeIn = U9T.HOT (HOTween.To, popupScoreInstance.renderer.material, 0.35f, new TweenParms().Prop("color", new Color(color.r, color.g, color.b, 1), false).Ease(EaseType.EaseInOutQuad));
			U9Transition FadeOut = U9T.HOT (HOTween.To, popupScoreInstance.renderer.material, 0.55f, new TweenParms().Prop("color", new Color(color.r, color.g, color.b, 0), false).Ease(EaseType.EaseInOutQuad).Delay(0.65f));
			
			ScaleIn.Begin();
			FadeIn.Begin();
			FadeOut.Begin();*/


			PopupScoreLabel popupScoreLabelInstance = (PopupScoreLabel)Instantiate (popupScoreLabelPrefab, transform.position, Quaternion.identity);

			popupScoreLabelInstance.transform.parent = transform;
			popupScoreLabelInstance.transform.localScale = new Vector3(0.2f, 0.2f, 0.2f);
			popupScoreLabelInstance.Score = score;
			Color c = new Color(color.r, color.g, color.b, 0);
			popupScoreLabelInstance.Color = c;

			U9Transition ScaleIn = U9T.LT (LeanTween.scale, popupScoreLabelInstance.gameObject, new Vector3(0.6f, 0.6f, 0.6f), 1f, iTween.Hash("ease", LeanTweenType.linear));
			U9Transition FadeIn = U9T.HOT (HOTween.To, popupScoreLabelInstance.GetComponent<UILabel>(), 0.35f, new TweenParms().Prop("color", new Color(color.r, color.g, color.b, 1), false).Ease(EaseType.EaseInOutQuad));
			U9Transition FadeOut = U9T.HOT (HOTween.To, popupScoreLabelInstance.GetComponent<UILabel>(), 0.55f, new TweenParms().Prop("color", new Color(color.r, color.g, color.b, 0), false).Ease(EaseType.EaseInOutQuad).Delay(0.65f));

			ScaleIn.Begin();
			FadeIn.Begin();
			FadeOut.Begin();
			//U9Transition FadeIn  = U9T.LT (LeanTween.alpha, popupScoreLabelInstance, 1.0f, 0.35f, iTween.Hash("ease", LeanTweenType.easeInCubic));

			Destroy(popupScoreLabelInstance, 5.0f);
		}

		bDLT.Ended += (transition) => 
		{
			Destroy (gameObject, 4.0f); 
		};
		
		return new InstantTransition( U9T.S ( bDLT) );
	}

Usage Example

Beispiel #1
0
    /// <summary>
    /// Causes all blocks to disappear
    /// </summary>
    /// <returns>The clear board transition.</returns>
    U9Transition CreateClearBoardTransition()
    {
        List <U9Transition> transitions = new List <U9Transition> ();

        for (int i = 0, ni = gridSize; i < ni; i++)
        {
            for (int j = 0, nj = gridSize; j < nj; j++)
            {
                Block b = blocks [i, j];
                if (b)
                {
                    transitions.Add(b.CreateDisappearTransition(0));
                }
            }
        }

        // Randomises the order of the disappear transitions to make it more pretty!
        List <U9Transition> randomisedTransitions = GetRandomSubset(transitions, transitions.Count);

        float staggerTime = 0.025f;         // 0.025f;

        return(U9T.Stagger(staggerTime, randomisedTransitions.ToArray()));
    }