Example #1
0
    void Start()
    {
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText( "prototype", "prototype.png" );

        // spawn new text instances showing off the relative positioning features by placing one text instance in each corner
        var x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        var y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f );
        text1 = text.addTextInstance( "hello man.  I have a line\nbreak", x, y );

        var textSize = text.sizeForText( "testing small bitmap fonts", 0.3f );
        x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y );
        text2 = text.addTextInstance( "testing small bitmap fonts", x, y, 0.3f );

        textSize = text.sizeForText( "with only\n1 draw call\nfor everything", 0.5f );
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x );
        y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f );
        text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow );

        textSize = text.sizeForText( "kudos" );
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y );
        text4 = text.addTextInstance( "kudos", x, y );

        textSize = text.sizeForText( "Be sure to try this with\niPhone and iPad resolutions" );
        var center = UIRelative.center( textSize.x, textSize.y );
        text.addTextInstance( "Be sure to try this with\niPhone and iPad resolutions", center.x, center.y, 1f, 4, Color.red );

        StartCoroutine( waitThenRemoveText() );
    }
Example #2
0
    IEnumerator ShowCredits()
    {
        float cameraSpeed = 0;

        while (Camera.main.transform.position.y > 26)
        {
            cameraSpeed = Mathf.Lerp(cameraSpeed, -30, Time.deltaTime);
            Camera.main.transform.Translate(0, cameraSpeed * Time.deltaTime, 0);
            yield return(null);
        }

        yield return(new WaitForSeconds(0.3f));

        var yOffset = 50 + (Screen.height - 640) / 2;

        var creditsText = text.addTextInstance("CREDITS", Screen.width / 2, yOffset, textScale, 1, Colors.DisableText);

        creditsText.alignMode = UITextAlignMode.Center;
        creditsText.xPos     -= creditsText.width / 2;

        var title     = "\n\n\n\nDesigners\n\n\n\nArtists\n\n\n\n\nProgrammer";
        var titleText = text.addTextInstance(title, Screen.width / 4, yOffset, textScale, 1, Colors.DisableText);

        titleText.alignMode = UITextAlignMode.Center;
        titleText.xPos     -= titleText.width / 2;

        var names    = "\n\nWhirlblast Studio\n\n\nRaven Wang\nPauland\n\n\nPauland\nCR Zhang\nBlake Seow\n\n\nRaven Wang";
        var nameText = text.addTextInstance(names, Screen.width / 4, yOffset, textScale, 1, Colors.HighlightText);

        nameText.alignMode = UITextAlignMode.Center;
        nameText.xPos     -= nameText.width / 2;

        var thanksTitle = text.addTextInstance("\n\n\n\nUnity Plugin\n\n\nMusic\n\n\n\nFonts", Screen.width * 3 / 4, yOffset, textScale, 1, Colors.DisableText);

        thanksTitle.alignMode = UITextAlignMode.Center;
        thanksTitle.xPos     -= thanksTitle.width / 2;

        var thankNames = text.addTextInstance("\n\nThanks\n" +
                                              "\n\nUIToolkit - Prime[31]\n" +
                                              "\n\nTitle: Green Sky - DST\nBattle: Znake - Osnoff\n" +
                                              "\n\nOptimus - Neale Davidson\nNamco - Family Font Mart",
                                              Screen.width * 3 / 4, yOffset, textScale, 1, Colors.HighlightText);

        thankNames.alignMode = UITextAlignMode.Center;
        thankNames.xPos     -= thankNames.width / 2;

        while (Input.touchCount == 0 && !Input.anyKeyDown)
        {
            yield return(null);
        }

        creditsText.clear();
        titleText.clear();
        nameText.clear();
        thanksTitle.clear();
        thankNames.clear();

        yield return(StartCoroutine(HideCredits()));
    }
Example #3
0
	void Start()
	{
		// setup our text instance which will parse our .fnt file and allow us to
		var text = new UIText( "prototype", "prototype.png" );

		
		// spawn new text instances showing off the relative positioning features by placing one text instance in each corner
		// Uses default color, scale, alignment, and depth.
		text1 = text.addTextInstance( "hello man.  I have a line\nbreak.", 0, 0 );
        text1.pixelsFromTopLeft( 0, 0 );
		

		text2 = text.addTextInstance( "testing small bitmap fonts", 0, 0, 0.3f );
        text2.pixelsFromBottomLeft( 25, 0 );
		
		
		// Centering using alignment modes.
		text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", 0, 0, 0.5f, 5, Color.yellow, UITextAlignMode.Right, UITextVerticalAlignMode.Top );
        text3.positionFromTopLeft( 0.5f, 0.2f );

		
		// High Ascii forcing crash demo. To test this, 
		// Disable "Set Low ASCII Forcing Mode" in the TextManager inspector and see the crash.
		// Not as handy if you don't need to paste in large amounts of text from word.
		text.forceLowAscii = setLowAsciiForcingMode;

		text4 = text.addTextInstance( highAsciiString, 0, 0, 0.4f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Bottom );
        text4.positionFromBottomRight( 0f, 0f );
		
		
		// Centering using text size calculation offset and per-char color
		var centeredText = "Be sure to try this with\niPhone and iPad resolutions";
		var colors = new List<Color>();
		for( var i = 0; i < centeredText.Length; i++ )
			colors.Add( Color.Lerp( Color.white, Color.magenta, (float)i / centeredText.Length ) );
		
		text5 = text.addTextInstance( centeredText, 0, 0, 1f, 4, colors.ToArray(), UITextAlignMode.Left, UITextVerticalAlignMode.Middle );
        text5.positionFromLeft( -0.1f, 0f );
		
		
		// Now center on right side.
		text6 = text.addTextInstance( "Vert-Centering on right side", 0, 0, 0.5f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Middle );
        text6.positionFromTopRight( 0.3f, 0f );
		
		
		var wrapText = new UIText( "prototype", "prototype.png" );
		wrapText.wrapMode = UITextLineWrapMode.MinimumLength;
		wrapText.lineWrapWidth = 100.0f;
		textWrap1 = wrapText.addTextInstance( "Testing line wrap width with small words in multiple resolutions.\n\nAnd manual L/B.", 0, 0, 0.3f, 1, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Bottom );
        textWrap1.positionFromBottomLeft( 0.1f, 0.1f );
		
		wrapText.lineWrapWidth = 100.0f;
		wrapText.wrapMode = UITextLineWrapMode.AlwaysHyphenate;
		
		textWrap2 = wrapText.addTextInstance( "This should be hyphenated. Check baseline - tytyt", 0, 0, 0.5f, 1, Color.green, UITextAlignMode.Center, UITextVerticalAlignMode.Bottom );
        textWrap2.positionFromBottom( 0f );
		
		StartCoroutine( modifyTextInstances() );
	}
 // Use this for initialization
 void Start()
 {
     UIText fnt = new UIText("Pourquoi64", "Pourquoi64.png");
     text = fnt.addTextInstance("The quick brown fox", 20, 20);
     text.setColorForAllLetters(Color.yellow);
     text2 = fnt.addTextInstance("jumps over the lazy dog", 20, 60, 0.75f);
     text2.setColorForAllLetters(Color.red);
 }
Example #5
0
    void createSplashScreen()
    {
        splashScreenButton            = UIButton.create("splash.png", "splash.png", 0, 0);
        splashScreenButton.onTouchUp += onTouchSplashScreen;
        splashScreenButton.positionCenter();

        splashText = textManager.addTextInstance("Tap to continue...", 0, 0);
        splashText.positionFromBottom(0.1f);
    }
Example #6
0
    void DrawScore()
    {
        var x = Screen.width / 2 - 10;

        scoreButton = spriteManager.addSprite("button_score.png", x, 0);

        scoreXPos = x + 62;
        scoreText = text.addTextInstance(LevelHandler.instance.score.ToString(), scoreXPos, scoreYPos, defaultTextScale, 1, Colors.HighlightText);
        scoreText.autoRefreshPositionOnScaling = false;
    }
Example #7
0
 void Start()
 {
     //Initialize Score
     scoreText        = new UIText(textButtonManager, "VogueCyrBold_60_ffffff", "VogueCyrBold_60_ffffff.png");
     scoretext1       = scoreText.addTextInstance(string.Format("{0}", score), 0, 0);
     scoretext1.color = Color.black;
     scoretext2       = scoreText.addTextInstance(string.Format("{0}", TargetScore), 0, 0);
     scoretext2.color = Color.black;
     scoretext1.positionFromTopLeft(0.1f, 0.18f);         //display for score
     scoretext2.positionFromTopLeft(0.1f, 0.78f);
 }
	void Start()
	{
		// setup our text instance which will parse our .fnt file and allow us to
		var text = new UIText( "prototype", "prototype.png" );
		text.alignMode = UITextAlignMode.Center;
		
		// add a text instance that we will animate later
		text1 = text.addTextInstance( "hello man.  I have a line\nbreak.", Screen.width / 2, 0 );
		text2 = text.addTextInstance( _counter.ToString(), Screen.width, 35, 1, 5, Color.black, UITextAlignMode.Right, UITextVerticalAlignMode.Middle );
		
		StartCoroutine( modifyTextInstance() );
	}
Example #9
0
    void Start()
    {
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText("prototype", "prototype.png");

        text.alignMode = UITextAlignMode.Center;

        // add a text instance that we will animate later
        text1 = text.addTextInstance("hello man.  I have a line\nbreak.", Screen.width / 2, 0);
        text2 = text.addTextInstance(_counter.ToString(), Screen.width, 35, 1, 5, Color.black, UITextAlignMode.Right, UITextVerticalAlignMode.Middle);

        StartCoroutine(modifyTextInstance());
    }
Example #10
0
    void Start()
    {
        // create a vertical layout to house our buttons
        var vBox = new UIVerticalLayout(10);

        vBox.edgeInsets = new UIEdgeInsets(10, 5, 10, 0);

        // create some buttons to control the positioning. we will add text to them se create the UIText we will use as well
        var text = new UIText(textToolkit, "prototype", "prototype.png");

        var positions = new string[] { "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right" };

        foreach (var pos in positions)
        {
            // create the button
            var touchable = UIButton.create("emptyUp.png", "emptyDown.png", 0, 0);
            touchable.userData         = pos;
            touchable.onTouchUpInside += onButtonTouched;

            // add the text
            var helloText = text.addTextInstance(pos, 0, 0, 0.5f, -1, Color.white, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
            helloText.parentUIObject = touchable;
            helloText.positionCenter();

            vBox.addChild(touchable);
        }


        // Scores button. we will use this to demo positioning
        _scoresButton = UIContinuousButton.create(buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0);
        _scoresButton.positionCenter();
    }
Example #11
0
    // Use this for initialization
    void Start()
    {
        PlayerScores = new UITextInstance[4];
        PlayerIcons = new UISprite[4];

        UIText fnt = new UIText("Pourquoi64", "Pourquoi64.png");

        yScale = Mathf.Clamp ((float)Screen.width / 1080, 0, 1);

        for (int i=0; i < 4; i++)
        {
            PlayerScores[i] = fnt.addTextInstance("00%", 0, 0);

            PlayerHUDPositions[i].GetComponent<HUDDogeMasterControllerUIT>().percentageDisplay = PlayerScores[i];

            PlayerScores[i].setColorForAllLetters(Color.yellow);
            PlayerScores[i].textScale = scoreTextScale * yScale;
            PlayerScores[i].text = i.ToString() + "00%";
            Debug.Log (i);

            //string dogeFileName = "dogePortrait0" + (i + 1).ToString();
            //PlayerIcons[i] = new UISprite(

        }
    }
Example #12
0
	void Start()
	{
		// create a vertical layout to house our buttons
		var vBox = new UIVerticalLayout( 10 );
		vBox.edgeInsets = new UIEdgeInsets( 10, 5, 10, 0 );
		
		// create some buttons to control the positioning. we will add text to them se create the UIText we will use as well
		var text = new UIText( textToolkit, "prototype", "prototype.png" );
		
		var positions = new string[] { "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right" };
		foreach( var pos in positions )
		{			
			// create the button
			var touchable = UIButton.create( "emptyUp.png", "emptyDown.png", 0, 0 );
			touchable.userData = pos;
			touchable.onTouchUpInside += onButtonTouched;

			// add the text
			var helloText = text.addTextInstance( pos, 0, 0, 0.5f, -1, Color.white, UITextAlignMode.Center, UITextVerticalAlignMode.Middle );
			helloText.parentUIObject = touchable;
			helloText.positionCenter();
			
			vBox.addChild( touchable );
		}
		
		
		// Scores button. we will use this to demo positioning
		_scoresButton = UIContinuousButton.create( buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0 );
		_scoresButton.positionCenter();
	}
Example #13
0
 public void Start()
 {
     timeText        = new UIText(textButtonManager, "VogueCyrBold_60_ffffff", "VogueCyrBold_60_ffffff.png");
     timetext1       = timeText.addTextInstance(string.Format("{0} : 30", minutes), 0, 0);
     timetext1.color = Color.black;
     timetext1.positionFromCenter(-0.38f, 0f);
     InvokeRepeating("countDown", 1, 1);
 }
Example #14
0
    // Use this for initialization
    void Start()
    {
        var scaleFactor = ScaleFactor.GetScaleFactor();

        scoreText             = new UIText(textManager, "VogueCyrBold_60_ffffff", "VogueCyrBold_60_ffffff.png");
        scoretext1            = scoreText.addTextInstance(string.Format("{0}", Main.getScore()), 0, 0);
        scoretext1.color      = Color.black;
        scoretext1.textScale /= scaleFactor * 0.4f;

        if (Application.loadedLevelName != "gameOver")
        {
            scoretext2 = scoreText.addTextInstance(string.Format("{0}", Main.getTargetScore()), 0, 0);
            scoretext2.positionFromCenter(0.17f, 0.0f);
            scoretext2.color = Color.black;
        }
        scoretext1.positionFromCenter(0.0f, 0.0f);
    }
Example #15
0
    void Start()
    {
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText( "prototype", "prototype.png" );

        // spawn new text instances showing off the relative positioning features by placing one text instance in each corner
        var x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        var y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f );
        text1 = text.addTextInstance( "hello man.  I have a line\nbreak", x, y );

        var textSize = text.sizeForText( "testing small bitmap fonts", 0.3f );
        x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y );
        text2 = text.addTextInstance( "testing small bitmap fonts", x, y, 0.3f );

        textSize = text.sizeForText( "with only\n1 draw call\nfor everything", 0.5f );
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x );
        y = UIRelative.yPercentFrom( UIyAnchor.Top, 0f );
        text3 = text.addTextInstance( "with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow );

        textSize = text.sizeForText( "kudos" );
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, textSize.x );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y );
        text4 = text.addTextInstance( "kudos", x, y );

        textSize = text.sizeForText( "Be sure to try this with\niPhone and iPad resolutions" );
        var center = UIRelative.center( textSize.x, textSize.y );
        text.addTextInstance( "Be sure to try this with\niPhone and iPad resolutions", center.x, center.y, 1f, 4, Color.red );

        x = UIRelative.xPercentFrom( UIxAnchor.Left, 0f );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y * 3 );
        var wrapText = new UIText( "prototype", "prototype.png");
        wrapText.wrapMode = UITextLineWrapMode.MinimumLength;
        wrapText.lineWrapWidth = 200.0f;
        textWrap1 = wrapText.addTextInstance( "Testing line wrap width with small words in multiple resolutions.", x, y, 0.3f);
        wrapText.lineWrapWidth = 100.0f;
        wrapText.wrapMode = UITextLineWrapMode.AlwaysHyphenate;
        x = UIRelative.xPercentFrom( UIxAnchor.Right, 0f, 200.0f );
        y = UIRelative.yPercentFrom( UIyAnchor.Bottom, 0f, textSize.y * 3 );
        textWrap2 = wrapText.addTextInstance( "This should be hyphenated.", x, y, 0.5f );

        StartCoroutine( waitThenRemoveText() );
    }
Example #16
0
    void Start()
    {
        toolkitText = toolkitAssets.getLabelText();

        labelTimer = toolkitText.addTextInstance("0:00.0", 0, 0, 1f, 15);
        labelTimer.positionFromTopLeft(0.03f, 0.5f);

        //remove this if you will send restart level message
        // onRestartLevel();
    }
Example #17
0
        // Use this for initialization
        void Start()
        {
            uiToolkit = GetComponent <UIToolkit>();

            fnt                    = new UIText(uiToolkit, fontName, fontName + ".png");
            text                   = fnt.addTextInstance("", 0, 0, fontScale, 3);
            text.alignMode         = UITextAlignMode.Center;
            text.verticalAlignMode = UITextVerticalAlignMode.Bottom;
            Hide();
        }
Example #18
0
    void Start()
    {
        toolkitText = toolkitAssets.getLabelText();

        label = toolkitText.addTextInstance(initialText, 0, 0, fontScale, 15);
        label.positionFromTopLeft(posFromTop, posFromLeft);
        if (initiallyHidden)
        {
            label.hidden = true;
        }
    }
Example #19
0
    // Build Main Menu
    private void BuildMenu()
    {
        var brickum = UIButton.create("brickum.png", "brickum.png", 0, 0);

        brickum.scale *= menuScale;

        var buttonCampaign = UIButton.create("button_campaign.png", "button_campaign_down.png", 0, 0);

        buttonCampaign.scale           *= menuScale;
        buttonCampaign.onTouchUpInside += (sender) => ButtonCampaign();


        var buttonFreeplay = UIButton.create("button_freeplay.png", "button_freeplay_down.png", 0, 0);

        buttonFreeplay.scale           *= menuScale;
        buttonFreeplay.onTouchUpInside += (sender) => ButtonFreePlay();

        var buttonKidmode = UIButton.create("button_kidmode.png", "button_kidmode_down.png", 0, 0);

        buttonKidmode.scale           *= menuScale;
        buttonKidmode.onTouchUpInside += (sender) => ButtonKidMode();

        containerMenu = new UIVerticalLayout(5);
        containerMenu.addChild(brickum, buttonCampaign, buttonFreeplay, buttonKidmode);
        containerMenu.matchSizeToContentSize();
        containerMenu.positionCenter();

        tipText        = textSmall.addTextInstance("Tip: Tips go here", 0, 0);
        tipText.text   = "Tip: " + gameSetup.GetTip();
        tipText.scale *= menuScale;
        tipText.positionFromBottom(0.03f, 0);

        // Options Button
        buttonOptions                  = UIButton.create("options_up.png", "options_down.png", 0, 0);
        buttonOptions.scale           *= menuScale;
        buttonOptions.onTouchUpInside += (sender) => ButtonOptions();
        buttonOptions.positionFromTopRight(0, 0);
        buttonOptions.alphaTo(1, 0.3f, Easing.Linear.easeOut);
    }
Example #20
0
    // Build Options Menu
    private void BuildOptions()
    {
        // Options List box
        containerOptions = new UIScrollableVerticalLayoutContainer(0);
        containerOptions.setSize(Screen.width - backButton.width, Screen.height); //scrollable.setSize(width, height);
        containerOptions.position  = new Vector3(backButton.width, 0, 0);         //scrollable.position = new Vector3((Screen.width - width) / 2, -Screen.height + height, 0);
        containerOptions.zIndex    = 1;
        containerOptions.myPadding = backButton.width;

        UIHorizontalLayoutWrap WrapperColors = new UIHorizontalLayoutWrap(0);
        UIToggleButton         buttonColors  = UIToggleButton.create("hexbox_false.png", "hexbox_true.png", "hexbox_down.png", 0, 0);

        buttonColors.scale    *= menuScale;
        buttonColors.onToggle += (sender, newValue) => buttonOptionsColors(sender, newValue);
        buttonColors.selected  = gameSetup.showColorTransitions;

        var textColors = text.addTextInstance("Color Transitions", 0, 0);

        textColors.scale *= menuScale;
        textColors.color  = Color.white;
        textColors.zIndex = -1;
        WrapperColors.addChild(buttonColors, textColors);

        UIHorizontalLayoutWrap WrapperFPS = new UIHorizontalLayoutWrap(0);
        UIToggleButton         buttonFPS  = UIToggleButton.create("hexbox_false.png", "hexbox_true.png", "hexbox_down.png", 0, 0);

        buttonFPS.scale    *= menuScale;
        buttonFPS.onToggle += (sender, newValue) => buttonOptionsFPS(sender, newValue);
        buttonFPS.selected  = gameSetup.showFPS;

        var textFPS = text.addTextInstance("Show FPS", 0, 0);

        textFPS.scale *= menuScale;
        textFPS.color  = Color.white;
        textFPS.zIndex = -1;
        WrapperFPS.addChild(buttonFPS, textFPS);

        containerOptions.addChild(WrapperColors, WrapperFPS);
    }
Example #21
0
    void Start()
    {
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText("prototype", "prototype.png");

        // spawn new text instances showing off the relative positioning features by placing one text instance in each corner
        var x = UIRelative.xPercentFrom(UIxAnchor.Left, 0f);
        var y = UIRelative.yPercentFrom(UIyAnchor.Top, 0f);

        text1 = text.addTextInstance("hello man.  I have a line\nbreak", x, y);


        var textSize = text.sizeForText("testing small bitmap fonts", 0.3f);

        x     = UIRelative.xPercentFrom(UIxAnchor.Left, 0f);
        y     = UIRelative.yPercentFrom(UIyAnchor.Bottom, 0f, textSize.y);
        text2 = text.addTextInstance("testing small bitmap fonts", x, y, 0.3f);


        textSize = text.sizeForText("with only\n1 draw call\nfor everything", 0.5f);
        x        = UIRelative.xPercentFrom(UIxAnchor.Right, 0f, textSize.x);
        y        = UIRelative.yPercentFrom(UIyAnchor.Top, 0f);
        text3    = text.addTextInstance("with only\n1 draw call\nfor everything", x, y, 0.5f, 5, Color.yellow);


        textSize = text.sizeForText("kudos");
        x        = UIRelative.xPercentFrom(UIxAnchor.Right, 0f, textSize.x);
        y        = UIRelative.yPercentFrom(UIyAnchor.Bottom, 0f, textSize.y);
        text4    = text.addTextInstance("kudos", x, y);


        textSize = text.sizeForText("Be sure to try this with\niPhone and iPad resolutions");
        var center = UIRelative.center(textSize.x, textSize.y);

        text.addTextInstance("Be sure to try this with\niPhone and iPad resolutions", center.x, center.y, 1f, 4, Color.red);

        StartCoroutine(waitThenRemoveText());
    }
Example #22
0
    void Start()
    {
        text = UIHelper.getText();

        var x = Screen.width / 2 + 100;
        var y = Screen.height / 2 - 210;

        comboText = text.addTextInstance("X", x, y);
        comboText.setColorForAllLetters(Colors.HighlightText);
        comboText.alignMode         = UITextAlignMode.Center;
        comboText.verticalAlignMode = UITextVerticalAlignMode.Middle;
        comboText.hidden            = true;
        comboText.textScale         = 2;
    }
    IEnumerator ShowLevel()
    {
//        SoundPlayer.PlayFX(levelUp);

        var color = Colors.HighlightText;

        if (levelText == null)
        {
            var size = text.sizeForText("Level " + difficultLevel);
            levelText = text.addTextInstance("Level " + difficultLevel, (Screen.width - size.x) / 2, (Screen.height - size.y) / 2);
//            color.a = 0.8f;
            levelText.setColorForAllLetters(color);
            levelText.alignMode         = UITextAlignMode.Center;
            levelText.verticalAlignMode = UITextVerticalAlignMode.Middle;
        }
        else
        {
            var size = text.sizeForText("Level " + difficultLevel);
            levelText = text.addTextInstance("Level " + difficultLevel, (Screen.width - size.x) / 2, (Screen.height - size.y) / 2);
//            color.a = 0.8f;
            levelText.setColorForAllLetters(color);
            levelText.alignMode         = UITextAlignMode.Center;
            levelText.verticalAlignMode = UITextVerticalAlignMode.Middle;
        }

        levelText.scaleFromTo(0.5f, Vector3.one * 2, Vector3.one * 1.5f, Easing.Quartic.easeOut);
//        levelText.alphaFromTo(0.5f, 0, 1, Easing.Quartic.easeOut);

        yield return(new WaitForSeconds(0.5f));

        levelText.scaleFromTo(0.5f, Vector3.one * 1.5f, Vector3.one * 3, Easing.Quartic.easeIn);
//        levelText.alphaFromTo(0.5f, 1, 0, Easing.Linear.easeOut);

        yield return(new WaitForSeconds(0.5f));

        levelText.clear();
    }
    // TODO: Placeholder code until implementation
    // TODO: Organize the games by your turn then their turn...
    private void findCurrentGames()
    {
        // TODO: The jsonRaw variable is temporary right now. Get it from the server and mantain MVC.
        GameInfo games = new GameInfo(jsonRaw.text);

        foreach (var pair in  games.currentGames)
        {
            Game game = pair.Value;

            // Create the button
            UIButton gameButton = UIButton.create(uiTools, "currentGame.png", "currentGame.png", 0, 0, 10);

            string turn = "Your Turn";
            if (!game.playerTurn)
            {
                turn = "Their Turn";
            }

            // Turn text
            UITextInstance gameTurn = graph15White.addTextInstance(turn, 0, 0);
            gameTurn.parentUIObject = gameButton;
            gameTurn.pixelsFromTop(2);

            // Opponent Name text
            UITextInstance opponentName = graph15White.addTextInstance(game.opponentName, 0, 0);
            opponentName.parentUIObject = gameButton;
            opponentName.pixelsFromBottom(2);

            // Score Text
            string         score     = game.playerScore + "/" + game.opponentScore;
            UITextInstance scoreText = graph26White.addTextInstance(score, 0, 0);
            scoreText.parentUIObject = gameButton;
            GUIUtils.centerText(scoreText);

            currentGamesLayout.addChild(gameButton);
        }
    }
Example #25
0
    private IEnumerator createLeaderboardMenu()
    {
        Debug.Log("Create OptionsMenu");
        currentPage = PageOLD.Leaderboard;
        if (friendsButton == null)
        {
            friendsButton               = UIButton.create("RGB_button.png", "RGB_button.png", 0, 0);
            friendsButton.onTouchUp    += onTouchFriendsButton;
            globalButton                = UIButton.create("RGB_button.png", "RGB_button.png", 0, 0);
            globalButton.parentUIObject = friendsButton;
            globalButton.onTouchUp     += onTouchGlobalButton;
            leaderboardTextManager      = new UIText("font", "font.png");
            if (PlayerPrefs.HasKey("FriendsLeaderboard"))
            {
                leaderboardText = leaderboardTextManager.addTextInstance(PlayerPrefs.GetString("FriendsLeaderboard"), 0, 0, 1.0f);
            }
            else
            {
                leaderboardText = leaderboardTextManager.addTextInstance("Couldn't find a friends leaderboard.\n" +
                                                                         "Try to log in from the options menu.", 0, 0);
            }
            leaderboardText.parentUIObject = friendsButton;
            shareButton            = UIButton.create("RGB_button.png", "RGB_button.png", 0, 0);
            shareButton.onTouchUp += onTouchShareButton;
        }

        // Posizioni
        friendsButton.positionFromTopLeft(0.05f, 0.05f);
        globalButton.positionFromLeft(1.05f);            // rispetto a friendsbutton
        leaderboardText.positionFromTopLeft(1.0f, 0.0f); // rispetto a friendsbutton
        shareButton.positionFromBottomLeft(0.05f, 0.05f);

        // Animazione
        friendsButton.positionFrom(1.0f, new Vector3(-Screen.width, friendsButton.position.y, friendsButton.position.z), Easing.Quartic.easeIn);
        shareButton.positionFrom(1.0f, new Vector3(-Screen.width, shareButton.position.y, shareButton.position.z), Easing.Quartic.easeIn);
        yield return(null);
    }
    // Use this for initialization
    void Start()
    {
        //cameraController = (GameCamera) GameCamera.GetComponent(typeof(GameCamera));
        cameraController = GameCamera.GetComponent <GameCamera>();

        // create some text
        ScoreboardText         = new UIText("Trebuchet14", "Trebuchet14.png");
        ScoreboardTextInstance = ScoreboardText.addTextInstance("Initial Setup", 0f, 0f, 1f, 0);
        ScoreboardTextInstance.positionFromTop(0.05f);

        // todo set gametype based on menu choice
        //GameType = GameTypes.Single;
        State = States.Null;

        SetupGame(LoadingGame, GameType);
    }
Example #27
0
    private IEnumerator createCreditsMenu()
    {
        Debug.Log("Create OptionsMenu");
        currentPage = PageOLD.Credits;
        if (creditsText == null)
        {
            creditsTextManager = new UIText("font", "font.png");
            creditsText        = creditsTextManager.addTextInstance("Credits, Mamba pro Bacca gay everyday \n nigger nigger nigger", 0, 0);
        }
        yield return(null);

        // Posizioni
        creditsText.positionCenter();

        // Animazione
        creditsText.positionFrom(1.0f, new Vector3(-Screen.width, creditsText.position.y, creditsText.position.z), Easing.Quartic.easeIn);
    }
    void Start()
    {
        // Scores button
        var scores = UIContinuousButton.create( buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0 );
        scores.positionFromBottomRight( .02f, .02f );
        scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );

        // Options button
        var optionsButton = UIButton.create( buttonToolkit, "optionsUp.png", "optionsDown.png", 0, 0 );
        optionsButton.positionFromBottomRight( .2f, .02f );

        // Text
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText( textToolkit, "prototype", "prototype.png" );

        var helloText = text.addTextInstance( "hello man.  I have a line\nbreak", 0, 0 );
        helloText.positionFromTopLeft( 0.1f, 0.05f );
    }
    void Start()
    {
        // Scores button
        var scores = UIContinuousButton.create( buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0 );
        scores.positionFromBottomRight( .02f, .02f );
        scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );

        // Options button
        var optionsButton = UIButton.create( buttonToolkit, "optionsUp.png", "optionsDown.png", 0, 0 );
        optionsButton.positionFromBottomRight( .2f, .02f );

        // Text
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText( textToolkit, "prototype", "prototype.png" );

        var x = UIRelative.xPercentFrom( UIxAnchor.Left, .05f );
        var y = UIRelative.yPercentFrom( UIyAnchor.Top, .1f );
        text.addTextInstance( "hello man.  I have a line\nbreak", x, y );
    }
Example #30
0
    // Use this for initialization
    void Start()
    {
        var scaleFactor = ScaleFactor.GetScaleFactor();
        //high score
        var CloseBtn = UIButton.create(highscoreManager, "back_normal2.png", "back_active2.png", 0, 0);

        CloseBtn.highlightedTouchOffsets = new UIEdgeOffsets(30);
        CloseBtn.onTouchUpInside        += sender => Application.LoadLevel("AGAIN");
        CloseBtn.touchDownSound          = audioplay.getSoundClip();
        CloseBtn.positionFromCenter(0.18f, 0.05f);
        CloseBtn.setSize(CloseBtn.width / scaleFactor * 1f, CloseBtn.height / scaleFactor * 1f);

        highScore                = Main.getHighScore();
        highScoreText            = new UIText(textManager, "VogueCyrBold_60_ffffff", "VogueCyrBold_60_ffffff.png");
        highscoretext            = highScoreText.addTextInstance(string.Format("{0}", highScore), 0, 0);
        highscoretext.textScale /= scaleFactor * 0.4f;
        highscoretext.positionFromCenter(-0.03f, 0.01f);
        highscoretext.color = Color.black;
    }
Example #31
0
    void ShowRanks()
    {
        var leaderboard = Social.CreateLeaderboard();

        leaderboard.id        = LeaderboardIDs.HighScores;
        leaderboard.userScope = UnityEngine.SocialPlatforms.UserScope.Global;
        leaderboard.timeScope = UnityEngine.SocialPlatforms.TimeScope.AllTime;

        leaderboard.LoadScores(success => {
            int x = 429, y = 361 + yOffset;
            if (success)
            {
                text.addTextInstance(leaderboard.localUserScore.rank.ToString(), x, y, textScale);
            }
            else
            {
                ShowNetworkError();
            }
        });
    }
Example #32
0
    void Start()
    {
        // Scores button
        var scores = UIContinuousButton.create(buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0);

        scores.positionFromBottomRight(.02f, .02f);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);


        // Options button
        var optionsButton = UIButton.create(buttonToolkit, "optionsUp.png", "optionsDown.png", 0, 0);

        optionsButton.positionFromBottomRight(.2f, .02f);


        // Text
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText(textToolkit, "prototype", "prototype.png");

        var helloText = text.addTextInstance("hello man.  I have a line\nbreak", 0, 0);

        helloText.positionFromTopLeft(0.1f, 0.05f);
    }
Example #33
0
    void Start()
    {
        // Scores button
        var scores = UIContinuousButton.create(buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0);

        scores.positionFromBottomRight(.02f, .02f);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);


        // Options button
        var optionsButton = UIButton.create(buttonToolkit, "optionsUp.png", "optionsDown.png", 0, 0);

        optionsButton.positionFromBottomRight(.2f, .02f);


        // Text
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText(textToolkit, "prototype", "prototype.png");

        var x = UIRelative.xPercentFrom(UIxAnchor.Left, .05f);
        var y = UIRelative.yPercentFrom(UIyAnchor.Top, .1f);

        text.addTextInstance("hello man.  I have a line\nbreak", x, y);
    }
    void Start()
    {
        // add two scrollables: one with pageing enabled
        var scrollable = new UIScrollableHorizontalLayout( 10 );

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        scrollable.beginUpdates();

        var height = UI.instance.isHD ? 150 : 300;
        var width = Screen.width / 1.4f;
        scrollable.setSize( width, height );
        scrollable.position = new Vector3( ( Screen.width - width ) / 2, -Screen.height + height, 0 );
        scrollable.zIndex = 3;

        for( var i = 0; i < 20; i++ )
        {
            UITouchableSprite touchable;
            if( i == 4 ) // text sprite
            {
                touchable = UIButton.create( "emptyUp.png", "emptyDown.png", 0, 0 );
            }
            else if( i % 3 == 0 )
            {
                touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
            }
            else if( i % 2 == 0 )
            {
                touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
            }
            else
            {
                touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
            }

            if( i == 1 )
            {
                var ch = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
                ch.parentUIObject = touchable;
                ch.pixelsFromRight( 0 );
                ch.client.name = "TEST THINGY";
                ch.scale = new Vector3( 0.5f, 0.5f, 1 );
            }
            else if( i == 4 )
            {
                var text = new UIText( textManager, "prototype", "prototype.png" );

                var helloText = text.addTextInstance( "Child Text", 0, 0,0.5f,-1,Color.blue,UITextAlignMode.Center,UITextVerticalAlignMode.Middle );
                helloText.parentUIObject = touchable;
                helloText.positionCenter();

                var ch = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
                ch.parentUIObject = helloText;
                ch.pixelsFromRight( -16 );
                ch.client.name = "subsub";
                ch.scale = new Vector3( 0.25f, 0.25f, -2 );
            }

            // only add a touchUpInside handler for buttons
            if( touchable is UIButton )
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
            }

            scrollable.addChild( touchable );
        }
        scrollable.endUpdates();
        scrollable.endUpdates(); // this is a bug. it shouldnt need to be called twice

        // add another scrollable
        scrollable = new UIScrollableHorizontalLayout( 0 );

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        scrollable.beginUpdates();

        var widthAndHeight = UI.instance.isHD ? 500 : 250;
        scrollable.setSize( widthAndHeight, widthAndHeight );
        scrollable.pagingEnabled = true;

        // paging will snap to the nearest page when scrolling
        scrollable.position = new Vector3( ( Screen.width - widthAndHeight ) / 2, 0, 0 );

        for( var i = 0; i < 5; i++ )
        {
            var button = UIButton.create( "marioPanel.png", "marioPanel.png", 0, 0 );
            scrollable.addChild( button );
        }
        scrollable.endUpdates();
        scrollable.endUpdates(); // this is a bug. it shouldnt need to be called twice
    }
Example #35
0
    void Start()
    {
        text        = new UIText(textToolkit, "GhoulishFont", "GhoulishFont_0.png");
        startScript = FindObjectOfType(typeof(StartScript)) as StartScript;
        loader      = FindObjectOfType(typeof(loadingScript)) as loadingScript;
        character   = FindObjectOfType(typeof(CharacterMaster)) as CharacterMaster;
        //DontDestroyOnLoad(this.gameObject);



        AmmoText     = text.addTextInstance("Bullets: " + startScript.Ammunition.ToString(), 0, 0, textScaleFactor, 2, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Middle);
        PickupAmount = text.addTextInstance("+20", 0, 0, textScaleFactor * 5, 2, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Middle);
        PickupAmount.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        PickupAmount.hidden = true;

        LevelInstruc = text.addTextInstance("" + LvlInstructions, 0, 0, textScaleFactor, 2, Color.white, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
        LevelInstruc.positionCenter();
        LevelInstruc.alphaTo(0.01f, 0, Easing.Quartic.easeIn);

        StartCoroutine(StartLvlInstruction());
        // buttons ------------------------------------


        PauseBtn = UIButton.create(buttonUI, "PauseBtn.png", "PauseBtn.png", 0, 0, 10);
        PauseBtn.positionFromTopLeft(0.035f, 0.045f);
        PauseBtn.onTouchUpInside += onTouchPauseBtn;
        PauseBtn.touchDownSound   = buttonSound;
        PauseBtn.hidden           = false;

        PlayBtn = UIButton.create(buttonUI, "PlayBtn.png", "PlayBtn.png", 0, 0, 10);
        PlayBtn.positionFromCenter(0.2f, -0.21f);
        PlayBtn.onTouchUpInside += onTouchPlayBtn;
        PlayBtn.touchDownSound   = buttonSound;
        PlayBtn.hidden           = true;

        RetryBtn = UIButton.create(buttonUI, "RetryBtn.png", "RetryBtn.png", 0, 0, 10);
        RetryBtn.positionFromCenter(0.2f, -0.07f);
        RetryBtn.onTouchUpInside += onTouchRetryBtn;
        RetryBtn.touchDownSound   = buttonSound;
        RetryBtn.hidden           = true;

        QuitBtn = UIButton.create(buttonUI, "QuitBtn.png", "QuitBtn.png", 0, 0, 10);
        QuitBtn.positionFromCenter(0.2f, 0.07f);
        QuitBtn.onTouchUpInside += onTouchQuitBtn;
        QuitBtn.touchDownSound   = buttonSound;
        QuitBtn.hidden           = true;

        //------TOGGLE BTNS-------------------------------


        AudioBtn = UIToggleButton.create(buttonUI, "AudioOffBtn.png", "AudioBtn.png", "AudioOffBtn.png", 0, 0, 10);
        AudioBtn.positionFromCenter(0.2f, 0.21f);
        AudioBtn.onToggle += onTouchAudioBtn;
        AudioBtn.hidden    = true;
        if (PlayerPrefs.GetInt("volume") == 1)
        {
            AudioBtn.selected = true;
        }

        //-------------------HEALTH METER--------------------------------------


        HealthBG = buttonUI.addSprite("HealthBG.png", 0, 0, 10);
        HealthBG.positionFromCenter(-0.41f, 0.0f);


        HealthBar = UIProgressBar.create(buttonUI, "HealthBar.png", 0, 0, false, 5, false);
        Vector2 tempVec;

        tempVec            = new Vector2(HealthBG.position.x + 95, HealthBG.position.y - 10);
        HealthBar.position = tempVec;

        HealthBar.value = 1;


        //----------------------PICKUPS-------------------------



        HealthPickup = buttonUI.addSprite("HeartPickup.png", 0, 0, 10);
        HealthPickup.positionFromCenter(-0.0f, 0.0f);
        HealthPickup.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        HealthPickup.hidden = true;

        AmmoPickup = buttonUI.addSprite("AmmoPickup.png", 0, 0, 10);
        AmmoPickup.positionFromCenter(-0.0f, 0.0f);
        AmmoPickup.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        AmmoPickup.hidden = true;


        //-----------------------------CONTROLS------------------------------------------


        LToggle          = UIJoystick.create(buttonUI, "LToggle.png", new Rect(Screen.width * 0.01f, Screen.height * 0.45f, Screen.width * 0.4f, Screen.height * 0.6f), Screen.width * 0.175f, Screen.height * -0.3f);
        LToggle.deadZone = new Vector2(0.8f, 0.8f);
        //LToggle.setJoystickHighlightedFilename( "LToggleT.png" );
        AttackBtn = UIContinuousButton.create("AttackBtn.png", "AttackBtn.png", 0, 0);
        AttackBtn.positionFromBottomRight(0.05f, 0.05f);
        AttackBtn.centerize();         // centerize the button so we can scale it from the center
        AttackBtn.highlightedTouchOffsets = new UIEdgeOffsets(30);
        AttackBtn.onTouchIsDown          += onTouchAttackBtn;
        AttackBtn.onTouchUpInside        += onTouchAttackBtnUp;



        if (loader != null)
        {
            if (loader.ControllerCount > 0)
            {
                LToggle.hidden   = true;
                AttackBtn.hidden = true;
            }
        }
    }
Example #36
0
    // Define UI buttons
    void Start()
    {
        /*
         * if(Screen.height > 480){
         *      Debug.Log("bigger: " + Screen.height +" "+Screen.width);
         *      float perc = ((float)Screen.height / 480.0f) * 100.0f;
         *      //Screen.SetResolution (
         *      //	(int)((float)Screen.width / 100.0f * perc),
         *      //	480,
         *      //	true);
         *      Screen.SetResolution (Screen.width / 2 , Screen.height / 2, true);
         *
         * }*/
        Debug.Log("Screen: w-" + Screen.width + " h-" + Screen.height);

        if (Screen.height >= 720)
        {
            menuScale      = 2;
            UI.scaleFactor = menuScale;
        }



        text      = new UIText(textToolkit, "Arial55", "Arial55_0.tga");
        textSmall = new UIText(textToolkit, "Arial20", "Arial20_0.tga");

        // Build Back button.
        backButton                  = UIButton.create("icon_back_up.png", "icon_back_down.png", 0, 0);
        backButton.scale           *= menuScale;
        backButton.zIndex           = 0;
        backButton.onTouchUpInside += (sender) => ButtonMenu();
        backButton.hidden           = true;

        // Game Mode.
        txtGameMode        = text.addTextInstance("Campaign ", 0, 0);
        txtGameMode.color  = Color.red;
        txtGameMode.zIndex = -2;
        txtGameMode.scale *= menuScale;
        txtGameMode.positionFromTopRight(0, 0);
        txtGameMode.alphaTo(4.5f, 0.25f, Easing.Linear.easeOut);
        txtGameMode.hidden = true;

        // Load Main Menu Screen
        BuildMenu();

        BuildOptions();
        containerOptions.hidden = true;

        BuildLoading();
        HideLoading();

        // Load & Hide Level Screen.
        BuildContainerCampaign();
        HideCampaign();

        BuildContainerKidMode();
        HideKidMode();

        BuildFreePlay();
        HideFreePlay();


        if (skipToLevelSelect)
        {
            if (GameManager.gameMode == GameMode.KidMode)
            {
                ButtonKidMode();
            }
            else if (GameManager.gameMode == GameMode.Campaign)
            {
                ButtonCampaign();
            }
            else
            {
                ButtonFreePlay();
            }
        }
    }
    void Start()
    {
        // add two scrollables: one with paging enabled and one without
        var scrollable = new UIScrollableHorizontalLayout( 10 );

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        scrollable.beginUpdates();

        var height = UI.scaleFactor * 50f;
        var width = Screen.width / 1.4f;
        scrollable.setSize( width, height );
        scrollable.position = new Vector3( ( Screen.width - width ) / 2, -Screen.height + height, 0 );
        scrollable.zIndex = 3;

        for( var i = 0; i < 20; i++ )
        {
            UITouchableSprite touchable;
            if( i == 4 ) // text sprite
            {
                touchable = UIButton.create( "emptyUp.png", "emptyDown.png", 0, 0 );
            }
            else if( i % 3 == 0 )
            {
                touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
            }
            else if( i % 2 == 0 )
            {
                touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
            }
            else
            {
                touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
            }

            if( i == 1 )
            {
                var ch = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
                ch.parentUIObject = touchable;
                ch.pixelsFromRight( 0 );
                ch.client.name = "TEST THINGY";
                ch.scale = new Vector3( 0.5f, 0.5f, 1 );
            }
            else if( i % 4==0 )
            {
                var text = new UIText( textManager, "prototype", "prototype.png" );

                var helloText = text.addTextInstance( "Child Text", 0, 0,0.5f,-1,Color.blue,UITextAlignMode.Center,UITextVerticalAlignMode.Middle );
                helloText.parentUIObject = touchable;
                helloText.positionCenter();

                var ch = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
                ch.parentUIObject = helloText;
                ch.pixelsFromRight( -16 );
                ch.client.name = "subsub";
                ch.scale = new Vector3( 0.25f, 0.25f, -2 );
            }

            // only add a touchUpInside handler for buttons
            if( touchable is UIButton )
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
            }

            // add random spacers every so often
            if( i % 3 == 0 )
                scrollable.addChild( new UISpacer( Random.Range( 10, 100 ), 40 ) );

            scrollable.addChild( touchable );
        }
        scrollable.endUpdates();
        scrollable.endUpdates(); // this is a bug. it shouldnt need to be called twice

        // add another scrollable, this one with paging enabled.
        scrollable = new UIScrollableHorizontalLayout( 20 );

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        scrollable.beginUpdates();

        height = UI.scaleFactor * 250f;

        // if you plan on making the scrollable wider than the item width you need to set your edgeInsets so that the
        // left + right inset is equal to the extra width you set
        scrollable.edgeInsets = new UIEdgeInsets( 0, 75, 0, 75 );
        width = UI.scaleFactor * ( 250f + 150f ); // item width + 150 extra width
        scrollable.setSize( width, height );

        // paging will snap to the nearest page when scrolling
        scrollable.pagingEnabled = true;
        scrollable.pageWidth = 250f * UI.scaleFactor;

        // center the scrollable horizontally
        scrollable.position = new Vector3( ( Screen.width - width ) / 2, 0, 0 );

        for( var i = 0; i < 5; i++ )
        {
            var button = UIButton.create( "marioPanel.png", "marioPanel.png", 0, 0 );
            scrollable.addChild( button );
        }

        scrollable.endUpdates();
        scrollable.endUpdates(); // this is a bug. it shouldnt need to be called twice
    }
    void Start()
    {
        // add two scrollables: one with paging enabled and one without
        var scrollable = new UIScrollableHorizontalLayout(10);

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        scrollable.beginUpdates();

        var height = UI.scaleFactor * 50f;
        var width  = Screen.width / 1.4f;

        scrollable.setSize(width, height);
        scrollable.position = new Vector3((Screen.width - width) / 2, -Screen.height + height, 0);
        scrollable.zIndex   = 3;

        for (var i = 0; i < 20; i++)
        {
            UITouchableSprite touchable;
            if (i == 4)              // text sprite
            {
                touchable = UIButton.create("emptyUp.png", "emptyDown.png", 0, 0);
            }
            else if (i % 3 == 0)
            {
                touchable = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
            }
            else if (i % 2 == 0)
            {
                touchable = UIButton.create("playUp.png", "playDown.png", 0, 0);
            }
            else
            {
                touchable = UIButton.create("optionsUp.png", "optionsDown.png", 0, 0);
            }

            if (i == 1)
            {
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = touchable;
                ch.pixelsFromRight(0);
                ch.client.name = "TEST THINGY";
                ch.scale       = new Vector3(0.5f, 0.5f, 1);
            }
            else if (i == 4)
            {
                var text = new UIText(textManager, "prototype", "prototype.png");

                var helloText = text.addTextInstance("Child Text", 0, 0, 0.5f, -1, Color.blue, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
                helloText.parentUIObject = touchable;
                helloText.positionCenter();

                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = helloText;
                ch.pixelsFromRight(-16);
                ch.client.name = "subsub";
                ch.scale       = new Vector3(0.25f, 0.25f, -2);
            }


            // only add a touchUpInside handler for buttons
            if (touchable is UIButton)
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += (sender) => Debug.Log("touched button: " + j);
            }

            // add random spacers every so often
            if (i % 3 == 0)
            {
                scrollable.addChild(new UISpacer(Random.Range(10, 100), 40));
            }

            scrollable.addChild(touchable);
        }
        scrollable.endUpdates();
        scrollable.endUpdates();         // this is a bug. it shouldnt need to be called twice



        // add another scrollable, this one with paging enabled.
        scrollable = new UIScrollableHorizontalLayout(20);

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        scrollable.beginUpdates();

        height = UI.scaleFactor * 250f;

        // if you plan on making the scrollable wider than the item width you need to set your edgeInsets so that the
        // left + right inset is equal to the extra width you set
        scrollable.edgeInsets = new UIEdgeInsets(0, 75, 0, 75);
        width = UI.scaleFactor * (250f + 150f);           // item width + 150 extra width
        scrollable.setSize(width, height);

        // paging will snap to the nearest page when scrolling
        scrollable.pagingEnabled = true;
        scrollable.pageWidth     = 250f * UI.scaleFactor;

        // center the scrollable horizontally
        scrollable.position = new Vector3((Screen.width - width) / 2, 0, 0);

        for (var i = 0; i < 5; i++)
        {
            var button = UIButton.create("marioPanel.png", "marioPanel.png", 0, 0);
            scrollable.addChild(button);
        }

        scrollable.endUpdates();
        scrollable.endUpdates();         // this is a bug. it shouldnt need to be called twice
    }
	void Start()
	{
		var scrollable = new UIScrollableVerticalLayout( 10 );
		scrollable.position = new Vector3( 0, -50, 0 );
		var width = UI.instance.isHD ? 300 : 150;
		scrollable.setSize( width, Screen.height / 1.4f );
		
		for( var i = 0; i < 20; i++ )
		{
			UITouchableSprite touchable;
			if( i % 3 == 0 )
			{
				touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
			}
			else if( i % 2 == 0 )
			{
				touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
			}
			else
			{
				touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
			}
			if (i == 1) {
				var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
				ch.parentUIObject = touchable;
				ch.pixelsFromRight(0);
				ch.client.name = "TEST THINGY";
				ch.scale = new Vector3(0.5f, 0.5f, 1);
			}
			if (i == 4) {
				var text = new UIText(TextManager, "prototype", "prototype.png");

				var helloText = text.addTextInstance("Child Text", 0, 0,0.5f,-1,Color.cyan,UITextAlignMode.Center,UITextVerticalAlignMode.Middle);
				helloText.parentUIObject = touchable;
				helloText.positionCenter();

				var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
				ch.parentUIObject = helloText;
				ch.pixelsFromRight(-16);
				ch.client.name = "subsub";
				ch.scale = new Vector3(0.25f, 0.25f, -2);
			}

			
			// only add a touchUpInside handler for buttons
			if( touchable is UIButton )
			{
				var button = touchable as UIButton;
				
				// store i locally so we can put it in the closure scope of the touch handler
				var j = i;
				button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
			}

			
			scrollable.addChild( touchable );
		}
		
		
		// click to scroll to a specific offset
		var scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromTopRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -10, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromBottomRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -600, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.centerize();
		scores.positionFromTopRight( 0.5f, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			var target = scrollable.position;
			var moveBy = _movedContainer ? -100 : 100;
			if( !UI.instance.isHD )
				moveBy /= 2;
			target.x += moveBy * 2;
			target.y += moveBy;
			scrollable.positionTo( 0.4f, target, Easing.Quintic.easeIn );
			_movedContainer = !_movedContainer;
		};
	}
    void Start()
    {
        var scrollable = new UIScrollableVerticalLayout(10);

        scrollable.alignMode = UIAbstractContainer.UIContainerAlignMode.Center;
        scrollable.position  = new Vector3(0, -50, 0);
        var width = UI.isHD ? 300 : 150;

        scrollable.setSize(width, Screen.height / 1.4f);

        for (var i = 0; i < 20; i++)
        {
            UITouchableSprite touchable;
            if (i == 4)              // text sprite
            {
                touchable = UIButton.create("emptyUp.png", "emptyDown.png", 0, 0);
            }
            else if (i % 3 == 0)
            {
                touchable = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
            }
            else if (i % 2 == 0)
            {
                touchable = UIButton.create("playUp.png", "playDown.png", 0, 0);
            }
            else
            {
                touchable = UIButton.create("optionsUp.png", "optionsDown.png", 0, 0);
            }


            // extra flair added by putting some child objects in some of the buttons created above
            if (i == 1)
            {
                // add a toggle button to the first element in the list
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = touchable;
                ch.pixelsFromRight(0);
                ch.client.name = "TEST THINGY";
                ch.scale       = new Vector3(0.5f, 0.5f, 1);
            }
            else if (i == 4)
            {
                // add some text to the 4th element in the list
                var text = new UIText(textManager, "prototype", "prototype.png");

                var helloText = text.addTextInstance("Child Text", 0, 0, 0.5f, -1, Color.black, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
                helloText.parentUIObject = touchable;
                helloText.positionCenter();

                // add a scaled down toggle button as well but this will be parented to the text
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = helloText;
                ch.pixelsFromRight(-16);
                ch.client.name = "subsub";
                ch.scale       = new Vector3(0.25f, 0.25f, 0);
            }


            // only add a touchUpInside handler for buttons
            if (touchable is UIButton)
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += (sender) => Debug.Log("touched button: " + j);
            }

            scrollable.addChild(touchable);
        }


        // click to scroll to a specific offset
        var scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);

        scores.positionFromTopRight(0, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            scrollable.scrollTo(-10, true);
        };


        scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);
        scores.positionFromBottomRight(0, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            scrollable.scrollTo(-600, true);
        };


        scores = UIButton.create("scoresUp.png", "scoresDown.png", 0, 0);
        scores.centerize();
        scores.positionFromTopRight(0.5f, 0);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.onTouchUpInside        += (sender) =>
        {
            var target = scrollable.position;
            var moveBy = _movedContainer ? -100 : 100;
            if (!UI.isHD)
            {
                moveBy /= 2;
            }
            target.x += moveBy * 2;
            target.y += moveBy;
            scrollable.positionTo(0.4f, target, Easing.Quintic.easeIn);
            _movedContainer = !_movedContainer;
        };
    }
	void Start()
	{
		var scrollable = new UIScrollableVerticalLayout( 10 );
		scrollable.alignMode = UIAbstractContainer.UIContainerAlignMode.Center;
		scrollable.position = new Vector3( 0, -50, 0 );
		var width = UI.scaleFactor * 150;
		scrollable.setSize( width, Screen.height / 1.4f );
		
		for( var i = 0; i < 20; i++ )
		{
			UITouchableSprite touchable;
			if( i == 4 ) // text sprite
			{
				touchable = UIButton.create( "emptyUp.png", "emptyDown.png", 0, 0 );
			}
			else if( i % 3 == 0 )
			{
				touchable = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
			}
			else if( i % 2 == 0 )
			{
				touchable = UIButton.create( "playUp.png", "playDown.png", 0, 0 );
			}
			else
			{
				touchable = UIButton.create( "optionsUp.png", "optionsDown.png", 0, 0 );
			}
			
			
			// extra flair added by putting some child objects in some of the buttons created above
			if( i == 1 )
			{
				// add a toggle button to the first element in the list
				var ch = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
				ch.parentUIObject = touchable;
				ch.pixelsFromRight( 0 );
				ch.client.name = "TEST THINGY";
				ch.scale = new Vector3( 0.5f, 0.5f, 1 );
			}
			else if( i == 4 )
			{
				// add some text to the 4th element in the list
				var text = new UIText( textManager, "prototype", "prototype.png" );

				var helloText = text.addTextInstance( "Child Text", 0, 0, 0.5f, -1, Color.black, UITextAlignMode.Center, UITextVerticalAlignMode.Middle );
				helloText.parentUIObject = touchable;
				helloText.positionCenter();
				
				// add a scaled down toggle button as well but this will be parented to the text
				var ch = UIToggleButton.create( "cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0 );
				ch.parentUIObject = helloText;
				ch.pixelsFromRight( -16 );
				ch.client.name = "subsub";
				ch.scale = new Vector3( 0.25f, 0.25f, 0 );
			}

			
			// only add a touchUpInside handler for buttons
			if( touchable is UIButton )
			{
				var button = touchable as UIButton;
				
				// store i locally so we can put it in the closure scope of the touch handler
				var j = i;
				button.onTouchUpInside += ( sender ) => Debug.Log( "touched button: " + j );
			}

			scrollable.addChild( touchable );
		}
		
		
		// click to scroll to a specific offset
		var scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromTopRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -10, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.positionFromBottomRight( 0, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			scrollable.scrollTo( -600, true );
		};
		
		
		scores = UIButton.create( "scoresUp.png", "scoresDown.png", 0, 0 );
		scores.centerize();
		scores.positionFromTopRight( 0.5f, 0 );
		scores.highlightedTouchOffsets = new UIEdgeOffsets( 30 );
		scores.onTouchUpInside += ( sender ) =>
		{
			var target = scrollable.position;
			var moveBy = _movedContainer ? -50 : 50;
			moveBy *= UI.scaleFactor;
			target.x += moveBy * 2;
			target.y += moveBy;
			scrollable.positionTo( 0.4f, target, Easing.Quintic.easeIn );
			_movedContainer = !_movedContainer;
		};
	}
    // Use this for initialization
    void Start()
    {
        //cameraController = (GameCamera) GameCamera.GetComponent(typeof(GameCamera));
        cameraController = GameCamera.GetComponent<GameCamera>();

        // create some text
        ScoreboardText = new UIText( "Trebuchet14", "Trebuchet14.png" );
        ScoreboardTextInstance = ScoreboardText.addTextInstance( "Initial Setup", 0f, 0f, 1f, 0 );
        ScoreboardTextInstance.positionFromTop( 0.05f );

        // todo set gametype based on menu choice
        //GameType = GameTypes.Single;
        State = States.Null;

        SetupGame( LoadingGame, GameType );
    }
Example #43
0
    public void Show()
    {
        board.guiTexture.enabled = true;

        text                   = UIHelper.getText();
        text.alignMode         = UITextAlignMode.Right;
        text.verticalAlignMode = UITextVerticalAlignMode.Middle;

        int medals = 0;

        // star
//       int x = 376;
//       int y = 40;
//       var starNum = Mathf.Clamp(LevelHandler.current.score / 100000, 0, 5);
//       for (int i = 0; i < 5; i++) {
//           UIToolkit.instance.addSprite(i < starNum ? "star.png" : "star_frame.png", x + i * 42, y);
//       }


        int firstColumn  = 429 + xOffset;
        int secondColumn = 613 + xOffset;
        int medalColumn  = 720 + xOffset;

        // time
        int y        = 190 + yOffset;
        var time     = LevelHandler.instance.timer;
        var timeText = text.addTextInstance(LevelHandler.instance.formattedTimer, firstColumn, y, textScale, 1, Colors.HighlightText);

        var timeRecord = Player.getTimeRecord();

        if (time > timeRecord)
        {
            timeRecord = time;
            Player.setTimeRecord(time);
        }
        text.addTextInstance(timeRecord.getTimeFormat(), secondColumn, y, textScale, 1, Colors.HighlightText);

        if (time > 120)
        {
            var timeMedals = 1 + (int)(time - 120) / 60;
            spriteManager.addSprite("medal.png", medalColumn, y);
            text.addTextInstance("x" + timeMedals, medalColumn + 25, y, textScale, 1, Colors.HighlightText);

            medals += timeMedals;
        }

        // level
        y = 225 + yOffset;
        var level     = LevelHandler.instance.level;
        var levelText = text.addTextInstance(level.ToString(), firstColumn - 1, y, textScale, 1, Colors.HighlightText);

        var levelRecord = Player.getLevelRecord();

        if (level > levelRecord)
        {
            levelRecord = level;
            Player.setLevelRecord(level);
        }
        text.addTextInstance(levelRecord.ToString(), secondColumn, y, textScale, 1, Colors.HighlightText);

        if (level > 5)
        {
            var levelMedals = 1 + (level - 5) / 5;
            spriteManager.addSprite("medal.png", medalColumn, y);
            text.addTextInstance("x" + levelMedals, medalColumn + 25, y, textScale, 1, Colors.HighlightText);

            medals += levelMedals;
        }

        // max combo
        y = 260 + yOffset;
        var maxCombo  = ComboHandler.current.maxCombo;
        var comboText = text.addTextInstance(maxCombo.ToString(), firstColumn, y, textScale, 1, Colors.HighlightText);

        var comboRecord = Player.getComboRecord();

        if (maxCombo > comboRecord)
        {
            comboRecord = maxCombo;
            Player.setComboRecord(maxCombo);
        }
        text.addTextInstance(comboRecord.ToString(), secondColumn, y, textScale, 1, Colors.HighlightText);

        if (maxCombo > 10)
        {
            var comboMedals = 1 + (maxCombo - 10) / 5;
            spriteManager.addSprite("medal.png", medalColumn, y);
            text.addTextInstance("x" + comboMedals, medalColumn + 25, y, textScale, 1, Colors.HighlightText);

            medals += comboMedals;
        }

        // clean count
        y = 295 + yOffset;
        var cleanCount     = LevelHandler.instance.cleanCount;
        var cleanCountText = text.addTextInstance(cleanCount.ToString(), firstColumn, y, textScale, 1, Colors.HighlightText);

        var cleanCountRecord = Player.getCleanCountRecord();

        if (cleanCount > cleanCountRecord)
        {
            cleanCountRecord = cleanCount;
            Player.setCleanCountRecord(cleanCount);
        }
        text.addTextInstance(cleanCountRecord.ToString(), secondColumn, y, textScale, 1, Colors.HighlightText);

        if (cleanCount > 300)
        {
            var cleanMedals = cleanCount / 300;
            spriteManager.addSprite("medal.png", medalColumn, y);
            text.addTextInstance("x" + cleanMedals, medalColumn + 25, y, textScale, 1, Colors.HighlightText);

            medals += cleanMedals;
        }

        var totalClean = Player.getTotalCleanCount();

        Player.setTotalCleanCount(totalClean + cleanCount);

        // score
        y = 355 + yOffset;
        var score     = LevelHandler.instance.score;
        var scoreText = text.addTextInstance(score.ToString(), 377 + xOffset, y, 1.3f, 1, Colors.HighlightText);

        y = 383 + yOffset;
        var scoreRecord = Player.getScoreRecord();

        if (score > scoreRecord)
        {
            scoreRecord = score;
            Player.setScoreRecord(score);
            text.addTextInstance("New Record", 613 + xOffset, y, 0.8f, 1, Colors.HighlightText);
        }
        else
        {
            text.addTextInstance(scoreRecord.ToString(), 613 + xOffset, y, 0.8f, 1, Colors.HighlightText);
        }

        Player.medals += medals;

//       y = 238;
//       var cleanWeightText = text.addTextInstance("54321", x, y, 1, 1, Colors.PanelText);
//
//       y = 355;
//       var rankText = text.addTextInstance("439", x, y, 1, 1, Colors.PanelText);
//
//       y = 400;
//       var record = Player.getLevelRecord(Application.loadedLevel);
//       if (score > record) {
//           record = score;
//           Player.setLevelRecord(Application.loadedLevel, score);
//       }
//       var recordText = text.addTextInstance(record.ToString(), x, y, 1, 1, Colors.PanelText);
//
//       y = 445;
//       var totalCleanText = text.addTextInstance("24357230", x, y, 1, 1, Colors.PanelText);


//       y += 30;
//

        var buttonOffset = new UIEdgeOffsets(40);

        int x = 170 + xOffset;

        y = 442 + yOffset;
        var backButton = UIButton.create("button_back.png", "button_back.png", x, y);

        backButton.normalTouchOffsets = buttonOffset;
        backButton.onTouchUpInside   += delegate(UIButton obj) {
            LevelLoader.Load("MainMenu");
        };

//        x = (Screen.width - 395) / 2;
//        var facebookButton = UIButton.create("facebook.png", "facebook.png", x, y);
//
//        x += 70;
//        var twitterButton = UIButton.create("twitter.png", "twitter.png", x, y);

        x = (Screen.width - 255) / 2;
        var leaderboardButton = UIButton.create("button_leaderboard.png", "button_leaderboard.png", x, y);

        leaderboardButton.onTouchUpInside += delegate(UIButton obj) {
            Social.ShowLeaderboardUI();
        };

        x = Screen.width - 230 - xOffset;
        var restartButton = UIButton.create("button_restart.png", "button_restart.png", x, y);

        restartButton.normalTouchOffsets = buttonOffset;
        restartButton.onTouchUpInside   += delegate(UIButton obj) {
            LevelLoader.Load("Level01");
        };


        // social report

        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            if (Social.localUser.authenticated)
            {
                ReportLeaderboards(score, level);
                ReportAchievements();
            }
            else
            {
                Social.localUser.Authenticate(success => {
                    if (success)
                    {
                        ReportLeaderboards(score, level);
                        ReportAchievements();
                    }
                });
            }
        }
    }
Example #44
0
    void InitUI()
    {
        text             = UIHelper.getText();
        text.lineSpacing = 1.6f;

        var buttonOffset = new UIEdgeOffsets(5);

        var x = Screen.width / 2;
        var y = Screen.height / 2 + 40;

        var medals = Player.medals;

        if (medals > 0)
        {
            medalSprite = UI.firstToolkit.addSprite("medal_highlight.png", x - 28, y + 6);
            medalText   = text.addTextInstance(Player.medals.ToString(), x, y, 0.8f, 1, Colors.HighlightText);
//            y += 30;
        }

//        var record = Player.getScoreRecord();
//        if (record > 0) {
//            recordText = text.addTextInstance("Record: " + record, x, y, 0.8f, 1, Colors.HighlightText);
//            recordText.xPos -= recordText.width / 2;
//        }

        y          += 50;
        startButton = UIButton.create("button_start.png", "button_start.png", x - 150, y);
        startButton.onTouchUpInside += delegate(UIButton obj) {
            StartCoroutine(LoadGame());
        };

        y += 95;
        leaderboardButton = UIButton.create("button_leaderboard.png", "button_leaderboard.png", x - 127, y);
        leaderboardButton.onTouchUpInside   += ShowLeaderboard;
        leaderboardButton.normalTouchOffsets = buttonOffset;

        creditsButton = UIButton.create("button_notice.png", "button_notice.png", Screen.width - 70, Screen.height - 70);
        creditsButton.normalTouchOffsets = buttonOffset;
        creditsButton.onTouchUpInside   += ShowCredits;

//        buttonOffset = new UIEdgeOffsets(2);

//        x = Screen.width - 140;
//        y = Screen.height - 70;
//        facebookButton = UIButton.create("facebook.png", "facebook.png", x, y);
//        facebookButton.normalTouchOffsets = buttonOffset;
//        facebookButton.onTouchUpInside += ConnectFacebook;
//
//        x += 65;
//        twitterButton = UIButton.create("twitter.png", "twitter.png", x, y);
//        twitterButton.normalTouchOffsets = buttonOffset;
//        twitterButton.onTouchUpInside += ConnectTwitter;

        if (!Social.localUser.authenticated)
        {
            Social.localUser.Authenticate(success => {
                if (success)
                {
                    Achievement.SyncServerAchievements();
                }
            });
        }
    }
Example #45
0
    void Start()
    {
        // setup our UIText which will parse our .fnt file and allow us to create instances that use it
        var text = new UIText("prototype", "prototype.png");


        // spawn new text instances showing off the relative positioning features by placing one text instance in each corner
        // Uses default color, scale, alignment, and depth.
        text1 = text.addTextInstance("hello man.  I have a line\nbreak.", 0, 0);
        text1.pixelsFromTop(0, 0);

        text2 = text.addTextInstance("testing small bitmap fonts", 0, 0, 0.3f);
        text2.pixelsFromBottomLeft(2, 2);


        // Centering using alignment modes.
        text3 = text.addTextInstance("with only\n1 draw call\nfor everything", 0, 0, 0.5f, 5, Color.yellow, UITextAlignMode.Right, UITextVerticalAlignMode.Top);
        text3.positionFromTopLeft(0.5f, 0.2f);


        // High Ascii forcing crash demo. To test this,
        // Disable "Set Low ASCII Forcing Mode" in the TextManager inspector and see the crash.
        // Not as handy if you don't need to paste in large amounts of text from word.
        text.forceLowAscii = setLowAsciiForcingMode;

        text4 = text.addTextInstance(highAsciiString, 0, 0, 0.4f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Bottom);
        text4.positionFromBottomRight(0f, 0f);


        // Centering using text size calculation offset and per-char color
        var centeredText = "Be sure to try this with\niPhone and iPad resolutions";
        var colors       = new List <Color>();

        for (var i = 0; i < centeredText.Length; i++)
        {
            colors.Add(Color.Lerp(Color.white, Color.magenta, (float)i / centeredText.Length));
        }

        text5 = text.addTextInstance(centeredText, 0, 0, 1f, 4, colors.ToArray(), UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
        text5.positionCenter();


        // Now center on right side.
        text6 = text.addTextInstance("Vert-Centering on right side", 0, 0, 0.5f, 1, Color.white, UITextAlignMode.Right, UITextVerticalAlignMode.Middle);
        text6.positionFromTopRight(0.3f, 0f);


        var wrapText = new UIText("prototype", "prototype.png");

        wrapText.wrapMode      = UITextLineWrapMode.MinimumLength;
        wrapText.lineWrapWidth = 100.0f;
        textWrap1 = wrapText.addTextInstance("Testing line wrap width with small words in multiple resolutions.\n\nAnd manual L/B.", 0, 0, 0.3f, 1, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Bottom);
        textWrap1.positionFromBottomLeft(0.1f, 0.1f);

        wrapText.lineWrapWidth = 100.0f;
        wrapText.wrapMode      = UITextLineWrapMode.AlwaysHyphenate;

        textWrap2 = wrapText.addTextInstance("This should be hyphenated. Check baseline - tytyt", 0, 0, 0.5f, 1, Color.green, UITextAlignMode.Center, UITextVerticalAlignMode.Bottom);
        textWrap2.positionFromBottom(0f);

        StartCoroutine(modifyTextInstances());
    }
    // Use this for initialization
    void Start()
    {
        stage = GameObject.Find( "Floor").GetComponent<Stage>();
        GameObject objUser = GameObject.Find( "User");
        statusUser = objUser.GetComponent<StatusUser>();
        motionUser = objUser.GetComponent<MotionUser>();
        attackUser = objUser.GetComponent<AttackUser>();
        motionCamera = Camera.mainCamera.GetComponent<MotionCamera>();

        // Se calcula la relación entre la resolución virtual de referencia y la resolución actual de pantalla
        fRatioX = Screen.width * 1.0f / iWidthScreen;
        fRatioY = Screen.height * 1.0f / iHeightScreen;

        // Se crea la barra de energía y se inicializan los parámetros relacionados.
        barUserEnergy = UIStateSprite.create( "Energy.png", 0, 0);
        barUserEnergy.hidden = false;
        barGunEnergy = UIStateSprite.create( "Level.png", 0, 0);
        barGunEnergy.hidden = false;
        textKilled = new UIText( "prototype", "prototype.png");
        textEnemies = new UIText( "prototype", "prototype.png");
        textRecord = new UIText( "prototype", "prototype.png");
        textEnemiesInstance = textEnemies.addTextInstance( "Enemigos: 0", iXTextEnemies * fRatioX, iYTextEnemies * fRatioY, 0.8f, 1, Color.green);
        textKilledInstance = textKilled.addTextInstance( "Asesinatos: 0", iXTextKilled * fRatioX, iYTextKilled * fRatioY, 0.8f, 1, Color.red);
        textRecordInstance = textRecord.addTextInstance( "Record: " + PlayerPrefs.GetInt( "Record", 0),
                                                         iXTextRecord * fRatioX, iYTextRecord * fRatioY, 0.8f, 1, Color.black);
        buttonPersp = UIButton.create( "emptyUp.png", "emptyDown.png", 0, 0);
        buttonPersp.hidden = false;
        textPersp = new UIText( "prototype", "prototype.png");
        textPerspInstance = textPersp.addTextInstance( motionCamera.strCameraPersp, iXTextPersp * fRatioX, iYTextPersp * fRatioY, 0.9f, 1, Color.blue);
    }
    void Start()
    {
        m_ui = GameObject.Find("UIToolkit-Score").GetComponent<UIToolkit>();
        m_uiText = GameObject.Find("UIToolkit-Scoretext").GetComponent<UIToolkit>();

        //--- Fond sombre
        //m_mask = m_ui.addSprite("selected_background.png", 0, 0);
        //m_mask.position = new Vector3(-1, -1, -5f);
        //m_mask.setSize(Screen.width + 1, -Screen.height + 1);
        //m_mask.hidden = true;
        //---

        //--- Texte de score
        UIText text = new UIText(m_uiText, "prototype", "prototype.png");

        if (IsTop)
        {
            _txtScore = text.addTextInstance("$0", 0.1f * Screen.width, -Screen.height * 0.41f, -0.8f, -6, Color.yellow, UITextAlignMode.Center, UITextVerticalAlignMode.Top);
            _txtScoreTotal = text.addTextInstance("Total\r\n\r\n$0", 0.305f * Screen.width, -Screen.height * 0.36f, -0.5f, -6, new Color(1f, 1f, 1f, 0.5f), UITextAlignMode.Left, UITextVerticalAlignMode.Bottom);
        }
        else
        {
            _txtScore = text.addTextInstance("$0", 0.395f * Screen.width, -Screen.height * 0.084f, 0.8f, -6, Color.yellow, UITextAlignMode.Center, UITextVerticalAlignMode.Bottom);
            _txtScoreTotal = text.addTextInstance("Total\r\n\r\n$0", 0.2f * Screen.width, -Screen.height * 0.14f, 0.5f, -6, new Color(1f, 1f, 1f, 0.5f), UITextAlignMode.Left, UITextVerticalAlignMode.Bottom);
        }

        _txtScore.hidden = true;
        _txtScoreTotal.hidden = true;
        //---
    }
    void Start()
    {
        // add two scrollables: one with pageing enabled
        var scrollable = new UIScrollableHorizontalLayout(10);

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        scrollable.beginUpdates();

        var height = UI.instance.isHD ? 150 : 300;
        var width  = Screen.width / 1.4f;

        scrollable.setSize(width, height);
        scrollable.position = new Vector3((Screen.width - width) / 2, -Screen.height + height, 0);
        scrollable.zIndex   = 3;

        for (var i = 0; i < 20; i++)
        {
            UITouchableSprite touchable;
            if (i == 4)              // text sprite
            {
                touchable = UIButton.create("emptyUp.png", "emptyDown.png", 0, 0);
            }
            else if (i % 3 == 0)
            {
                touchable = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
            }
            else if (i % 2 == 0)
            {
                touchable = UIButton.create("playUp.png", "playDown.png", 0, 0);
            }
            else
            {
                touchable = UIButton.create("optionsUp.png", "optionsDown.png", 0, 0);
            }


            if (i == 1)
            {
                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = touchable;
                ch.pixelsFromRight(0);
                ch.client.name = "TEST THINGY";
                ch.scale       = new Vector3(0.5f, 0.5f, 1);
            }
            else if (i == 4)
            {
                var text = new UIText(textManager, "prototype", "prototype.png");

                var helloText = text.addTextInstance("Child Text", 0, 0, 0.5f, -1, Color.blue, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
                helloText.parentUIObject = touchable;
                helloText.positionCenter();

                var ch = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
                ch.parentUIObject = helloText;
                ch.pixelsFromRight(-16);
                ch.client.name = "subsub";
                ch.scale       = new Vector3(0.25f, 0.25f, -2);
            }


            // only add a touchUpInside handler for buttons
            if (touchable is UIButton)
            {
                var button = touchable as UIButton;

                // store i locally so we can put it in the closure scope of the touch handler
                var j = i;
                button.onTouchUpInside += (sender) => Debug.Log("touched button: " + j);
            }


            scrollable.addChild(touchable);
        }
        scrollable.endUpdates();
        scrollable.endUpdates();         // this is a bug. it shouldnt need to be called twice



        // add another scrollable
        scrollable = new UIScrollableHorizontalLayout(0);

        // we wrap the addition of all the sprites with a begin updates so it only lays out once when complete
        scrollable.beginUpdates();

        var widthAndHeight = UI.instance.isHD ? 500 : 250;

        scrollable.setSize(widthAndHeight, widthAndHeight);
        scrollable.pagingEnabled = true;

        // paging will snap to the nearest page when scrolling
        scrollable.position = new Vector3((Screen.width - widthAndHeight) / 2, 0, 0);

        for (var i = 0; i < 5; i++)
        {
            var button = UIButton.create("marioPanel.png", "marioPanel.png", 0, 0);
            scrollable.addChild(button);
        }
        scrollable.endUpdates();
        scrollable.endUpdates();         // this is a bug. it shouldnt need to be called twice
    }
Example #49
0
    // Use this for initialization
    protected void Start()
    {
        CoreBoard = (BoardBehavior) GetComponent("BoardBehavior");

        progressBar_Base = UIProgressBar.create(buttonToolkit, "UI_Base.png", 0, 0,true,2  );
        //progressBar_Science.positionFromBottomLeft( .15f, .02f );
        progressBar_Base.positionFromTopLeft( 20f/Screen.height, 960f/Screen.width );
        progressBar_Base.resizeTextureOnChange = true;
        progressBar_Base.value = 1f;

        //		debugString = "";
        // Progress/Health bar
        progressBar_Culture = UIProgressBar.create( buttonToolkit,"UI_Ball.png", 0, 0,false,1 );
        //progressBar_Culture = UIProgressBar.create( "UI_Ball.png", 0, 0 );
        //progressBar.positionFromLeft
        //progressBar_Culture.positionFromTopRight( .17f, .40f );
        progressBar_Culture.positionFromTopLeft(  30f/Screen.height,   685f/Screen.width);

        progressBar_Culture.resizeTextureOnChange = true;
        progressBar_Culture.value = 0.0f;

        progressBar_Healtth = UIProgressBar.create(buttonToolkit, "UI_Ball.png", 0, 0 ,true,1 );
        progressBar_Healtth.positionFromTopLeft(30f/Screen.height, 830f/Screen.width);
        progressBar_Healtth.resizeTextureOnChange = true;
        progressBar_Healtth.value = 1.0f;

        progressBar_Science = UIProgressBar.create(buttonToolkit, "UI_Ball.png", 0, 0,true,1  );
        //progressBar_Science.positionFromBottomLeft( .15f, .02f );
        progressBar_Science.positionFromTopLeft(30f/Screen.height, 916f/Screen.width );
        progressBar_Science.resizeTextureOnChange = true;
        progressBar_Science.value = 1.0f;

        //StartCoroutine( animateProgressBar( progressBar_Culture ) );

        UIText_Era = new UIText( textToolkit, "prototype", "prototype.png" );
        TextUI_ERA = UIText_Era.addTextInstance( m_ERA_NAMEDic[  m_currentERA ], 0, 0 );
        //helloText.positionFromTopLeft( 0.1f, 0.05f );
        TextUI_ERA.positionFromTopLeft( 0.1f, 0.05f );
    }