void Start() { UITextInfo backTextInfo = new UITextInfo(); backTextInfo.SetFont(fontBack).SetFontSize(24).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.LEFT_TOP); UITextInfo backTextLargerInfo = new UITextInfo(); backTextLargerInfo.SetFont(fontBack).SetFontSize(28).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.LEFT_TOP); UIRelativeLayout rootLayout = new UIRelativeLayout("rootLayout", 0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); UIStringLabel backLabelSmall = new UIStringLabel(0.01f, 0.99f, 0.2f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, backTextInfo, "Back"); UIStringLabel backLabelLarge = new UIStringLabel(0.01f, 0.99f, 0.2f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, backTextLargerInfo, "Back"); UIStaticButton backButton = new UIStaticButton(0.01f, 0.99f, 0.1f, 0.08f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, new MenuButtonListener(hover, dehover, "MainMenu")); backButton.SetUIComponentIdle(backLabelSmall).SetUIComponentHighlighted(backLabelLarge); UITextInfo mainTextInfo = new UITextInfo(); mainTextInfo.SetFont(fontMain).SetFontSize(48).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.LEFT_TOP); UIStringLabel mainTextLabel = new UIStringLabel(0.15f, 0.8f, 0.9f, 0.5f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, mainTextInfo, mainText); rootLayout.AddUIComponent(backButton) .AddUIComponent(mainTextLabel); m_panel = new UI(rootLayout); m_panel.SetStartMenu(1); screenWidth = Screen.width; screenHeight = Screen.height; }
void Start() { UITextInfo buttonsTextInfo = new UITextInfo(); buttonsTextInfo.SetFont(fontLevels).SetFontSize(64).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.CENTER); UITextInfo buttonsLargerTextInfo = new UITextInfo(); buttonsLargerTextInfo.SetFont(fontLevels).SetFontSize(80).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.CENTER); UITextInfo backTextInfo = new UITextInfo(); backTextInfo.SetFont(fontBack).SetFontSize(24).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.LEFT_TOP); UITextInfo backTextLargerInfo = new UITextInfo(); backTextLargerInfo.SetFont(fontBack).SetFontSize(28).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.LEFT_TOP); UIRelativeLayout rootLayout = new UIRelativeLayout("rootLayout", 0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); UIStringLabel backLabelSmall = new UIStringLabel(0.01f, 0.99f, 0.2f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, backTextInfo, "Back"); UIStringLabel backLabelLarge = new UIStringLabel(0.01f, 0.99f, 0.2f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, backTextLargerInfo, "Back"); UIStaticButton backButton = new UIStaticButton(0.01f, 0.99f, 0.1f, 0.08f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, new MenuButtonListener(hover, dehover, "MainMenu")); backButton.SetUIComponentIdle(backLabelSmall).SetUIComponentHighlighted(backLabelLarge); rootLayout.AddUIComponent(backButton); UIGridLayout gridLayout = new UIGridLayout("GridLayout", 0.5f, 0.5f, 0.85f, 0.8f, null, UIAnchorLocation.CENTER, xGridSections, yGridSections); for (int n = 0; n < levelNames.Length; ++n) { UIRelativeLayout highlightedLayout = new UIRelativeLayout(0.015f, 0.05f, 0.97f, 0.90f, null, UIAnchorLocation.LEFT_BOT); highlightedLayout.AddUIComponent(new UITextureLabel(0f, 0f, 1f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, levelBorderTexture)) .AddUIComponent(new UIStringLabel(0f, 0f, 1f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonsLargerTextInfo, "Level " + (n+1))); UIRelativeLayout notHighlightedLayout = new UIRelativeLayout(0.015f, 0.05f, 0.97f, 0.90f, null, UIAnchorLocation.LEFT_BOT); notHighlightedLayout.AddUIComponent(new UITextureLabel("Level" + (n+1) + "relativeLayout", 0f, 0f, 1f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, levelBorderTexture)) .AddUIComponent(new UIStringLabel(0f, 0f, 1f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonsTextInfo, "Level " + (n+1))); UIStaticButton levelButton = new UIStaticButton(0.015f, 0.05f, 0.97f, 0.90f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, new MenuButtonListener(hover, dehover, levelNames[n])); levelButton.SetUIComponentIdle(notHighlightedLayout).SetUIComponentHighlighted(highlightedLayout); gridLayout.AddUIComponent(levelButton, n % xGridSections, n / xGridSections, 1, 1); } rootLayout.AddUIComponent(gridLayout); m_panel = new UI(rootLayout); m_panel.SetStartMenu(1); screenWidth = Screen.width; screenHeight = Screen.height; }
public void Setup(int startingHealth, int startingResources) { UITextInfo backTextInfo = new UITextInfo(); backTextInfo.SetFont(font).SetFontSize(24).SetColor(new Color(0f, 0f, 0f)).SetTextAlignment(UIAnchorLocation.LEFT_TOP); UITextInfo backTextLargerInfo = new UITextInfo(); backTextLargerInfo.SetFont(font).SetFontSize(28).SetColor(new Color(0f, 0f, 0f)).SetTextAlignment(UIAnchorLocation.LEFT_TOP); UITextInfo healthTextInfo = new UITextInfo(); healthTextInfo.SetFont(font).SetFontSize(28).SetColor(new Color(1f, 0f, 0f)).SetTextAlignment(UIAnchorLocation.RIGHT_MID); UITextInfo healthNumberTextInfo = new UITextInfo(); healthNumberTextInfo.SetFont(font).SetFontSize(28).SetColor(new Color(1f, 0f, 0f)).SetTextAlignment(UIAnchorLocation.LEFT_MID); UITextInfo resourcesTextInfo = new UITextInfo(); resourcesTextInfo.SetFont(font).SetFontSize(28).SetColor(new Color(0f, 0f, 0f)).SetTextAlignment(UIAnchorLocation.RIGHT_MID); UITextInfo resourcesNumberTextInfo = new UITextInfo(); resourcesNumberTextInfo.SetFont(font).SetFontSize(28).SetColor(new Color(0f, 0f, 0f)).SetTextAlignment(UIAnchorLocation.LEFT_MID); UITextInfo everythingElseTextInfo = new UITextInfo(); everythingElseTextInfo.SetFont(font).SetFontSize(32).SetColor(new Color(0f, 0f, 0f)).SetTextAlignment(UIAnchorLocation.LEFT_TOP); UIRelativeLayout rootLayout = new UIRelativeLayout("rootLayout", 0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); UIStringLabel backLabelSmall = new UIStringLabel(0.01f, 0.99f, 0.2f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, backTextInfo, "Back"); UIStringLabel backLabelLarge = new UIStringLabel(0.01f, 0.99f, 0.2f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, backTextLargerInfo, "Back"); UIStaticButton backButton = new UIStaticButton(0.01f, 0.99f, 0.1f, 0.08f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, new MenuButtonListener(hover, dehover, "MainMenu")); backButton.SetUIComponentIdle(backLabelSmall).SetUIComponentHighlighted(backLabelLarge); UIStringLabel healthWord = new UIStringLabel(0.9f, 1.0f, 0.4f, 0.05f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.RIGHT_TOP, healthTextInfo, "Health:"); UIStringLabel resourcesWord = new UIStringLabel(0.9f, 0.96f, 0.4f, 0.05f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.RIGHT_TOP, resourcesTextInfo, "Resources:"); healthNumber = new UIStringLabel(0.91f, 1.0f, 0.4f, 0.05f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, healthNumberTextInfo, startingHealth.ToString()); resourcesNumber = new UIStringLabel(0.91f, 0.96f, 0.4f, 0.05f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_TOP, resourcesNumberTextInfo, startingResources.ToString()); rootLayout.AddUIComponent(backButton) .AddUIComponent(healthWord) .AddUIComponent(resourcesWord) .AddUIComponent(healthNumber) .AddUIComponent(resourcesNumber); m_panel = new UI(rootLayout); m_panel.SetStartMenu(1); screenWidth = Screen.width; screenHeight = Screen.height; }
void Start() { UITextInfo titleTextInfo = new UITextInfo(); titleTextInfo.SetFont(fontTitle).SetFontSize(72).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.MID_TOP); UITextInfo buttonsTextInfo = new UITextInfo(); buttonsTextInfo.SetFont(fontButtons).SetFontSize(36).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.CENTER); UITextInfo buttonsLargerTextInfo = new UITextInfo(); buttonsLargerTextInfo.SetFont(fontButtons).SetFontSize(48).SetColor(new Color(1f, 1f, 1f)).SetTextAlignment(UIAnchorLocation.CENTER); UIRelativeLayout rootLayout = new UIRelativeLayout(0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); UIStringLabel titleLabel = new UIStringLabel(0.5f, 0.7f, 1f, 0.5f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, titleTextInfo, start + end[Random.Range (0, end.Length)]); UIStringLabel playLabelSmall = new UIStringLabel(0.5f, 0.3f, 0.8f, 0.2f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, buttonsTextInfo, "Play"); UIStringLabel creditsLabelSmall = new UIStringLabel(0.5f, 0.2f, 0.8f, 0.2f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, buttonsTextInfo, "Credits"); UIStringLabel instructionsLabelSmall = new UIStringLabel(0.5f, 0.1f, 0.8f, 0.2f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, buttonsTextInfo, "Instructions"); UIStringLabel playLabelLarge = new UIStringLabel(0.5f, 0.3f, 0.8f, 0.2f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, buttonsLargerTextInfo, "Play"); UIStringLabel creditsLabelLarge = new UIStringLabel(0.5f, 0.2f, 0.8f, 0.2f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, buttonsLargerTextInfo, "Credits"); UIStringLabel instructionsLabelLarge = new UIStringLabel(0.5f, 0.1f, 0.8f, 0.2f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, buttonsLargerTextInfo, "Instructions"); UIStaticButton playButton = new UIStaticButton(0.5f, 0.3f, 0.8f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, new MenuButtonListener(hover, dehover, "Levels")); UIStaticButton creditsButton = new UIStaticButton(0.5f, 0.2f, 0.8f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, new MenuButtonListener(hover, dehover, "Credits")); UIStaticButton instructionsButton = new UIStaticButton(0.5f, 0.1f, 0.8f, 0.1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, new MenuButtonListener(hover, dehover, "Instructions")); playButton. SetUIComponentIdle(playLabelSmall). SetUIComponentHighlighted(playLabelLarge); creditsButton. SetUIComponentIdle(creditsLabelSmall). SetUIComponentHighlighted(creditsLabelLarge); instructionsButton. SetUIComponentIdle(instructionsLabelSmall). SetUIComponentHighlighted(instructionsLabelLarge); rootLayout.AddUIComponent(titleLabel) .AddUIComponent(playButton) .AddUIComponent(creditsButton) .AddUIComponent(instructionsButton); m_panel = new UI(rootLayout); m_panel.SetStartMenu(1); screenWidth = Screen.width; screenHeight = Screen.height; }
void Start() { menu1Group = new UIGridLayout(0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT, 6, 5); buttonTextInfo = new UITextInfo(); buttonTextInfo.SetFontSize(48).SetFontStyle(UIFontStyle.BOLD).SetColor(new Color(1f, 1f, 1f)).SetFont(m_font).SetTextAlignment(UIAnchorLocation.LEFT_MID); // Texture2D menuBackgroundTexture = Resources.Load<Texture2D>("UITextures/MidBackground"); // Texture2D menuLeftSideTexture = Resources.Load<Texture2D>("UITextures/LeftSideThing"); // Texture2D buttonBorderTexture = Resources.Load<Texture2D>("UITextures/ButtonBorder"); playButtonLayoutGroupIdle = new UIRelativeLayout(0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); playButtonLayoutGroupHighlighted = new UIRelativeLayout(0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); tutorialButtonLayoutGroupIdle = new UIRelativeLayout(0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); tutorialButtonLayoutGroupHighlighted = new UIRelativeLayout(0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); creditsButtonLayoutGroupIdle = new UIRelativeLayout(0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); creditsButtonLayoutGroupHighlighted = new UIRelativeLayout(0f, 0f, 1f, 1f, null, UIAnchorLocation.LEFT_BOT); playButtonBorderIdle = new UITextureLabel(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonBorderTexture); playButtonBorderHighlighted = new UITextureLabel(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonBorderTexture); tutorialButtonBorderIdle = new UITextureLabel(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonBorderTexture); tutorialButtonBorderHighlighted = new UITextureLabel(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonBorderTexture); creditsButtonBorderIdle = new UITextureLabel(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonBorderTexture); creditsButtonBorderHighlighted = new UITextureLabel(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonBorderTexture); playButtonStringLabelIdle = new UIStringLabel(0.14f, 0f, 0.8f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonTextInfo, "Play"); playButtonStringLabelHighlighted = new UIStringLabel(0.24f, 0f, 0.8f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonTextInfo, "Play"); tutorialButtonStringLabelIdle = new UIStringLabel(0.14f, 0f, 0.8f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonTextInfo, "Tutorial"); tutorialButtonStringLabelHighlighted = new UIStringLabel(0.24f, 0f, 0.8f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonTextInfo, "Tutorial"); creditsButtonStringLabelIdle = new UIStringLabel(0.14f, 0f, 0.8f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonTextInfo, "Credits"); creditsButtonStringLabelHighlighted = new UIStringLabel(0.24f, 0f, 0.8f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, buttonTextInfo, "Credits"); menuBackgroundLabel = new UITextureLabel(0.5f, 0.5f, 1.2f, 1.2f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.CENTER, menuBackgroundTexture); menuLeftSideLabel = new UITextureLabel(0f, 0f, 1f, 1f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, menuLeftSideTexture); playButtonLayoutGroupIdle.AddUIComponent(playButtonBorderIdle).AddUIComponent(playButtonStringLabelIdle); tutorialButtonLayoutGroupIdle.AddUIComponent(tutorialButtonBorderIdle).AddUIComponent(tutorialButtonStringLabelIdle); creditsButtonLayoutGroupIdle.AddUIComponent(creditsButtonBorderIdle).AddUIComponent(creditsButtonStringLabelIdle); playButtonLayoutGroupHighlighted.AddUIComponent(playButtonBorderHighlighted).AddUIComponent(playButtonStringLabelHighlighted); tutorialButtonLayoutGroupHighlighted.AddUIComponent(tutorialButtonBorderHighlighted).AddUIComponent(tutorialButtonStringLabelHighlighted); creditsButtonLayoutGroupHighlighted.AddUIComponent(creditsButtonBorderHighlighted).AddUIComponent(creditsButtonStringLabelHighlighted); playButton = new UIStaticButton(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, new DoNothingButtonListener()); tutorialButton = new UIStaticButton(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, new DoNothingButtonListener()); creditsButton = new UIStaticButton(0.1f, 0.1f, 0.8f, 0.8f, null, UILayoutType.RELATIVE_LAYOUT, UIAnchorLocation.LEFT_BOT, new DoNothingButtonListener()); playButton.SetUIComponentIdle(playButtonLayoutGroupIdle).SetUIComponentHighlighted(playButtonLayoutGroupHighlighted); tutorialButton.SetUIComponentIdle(tutorialButtonLayoutGroupIdle).SetUIComponentHighlighted(tutorialButtonLayoutGroupHighlighted); creditsButton.SetUIComponentIdle(creditsButtonLayoutGroupIdle).SetUIComponentHighlighted(creditsButtonLayoutGroupHighlighted); menu1Group.AddUIComponent(menuBackgroundLabel, 1, 1, 4, 3) .AddUIComponent(menuLeftSideLabel, 0, 0, 1, 5) .AddUIComponent(playButton, 1, 1, 4, 1) .AddUIComponent(tutorialButton, 1, 2, 4, 1) .AddUIComponent(creditsButton, 1, 3, 4, 1); m_ui = new UI(menu1Group); m_ui.SetStartMenu(1); screenWidth = Screen.width; screenHeight = Screen.height; }