private void BuildContainerKidMode() { // Campaign List Scroll Box. containerKidMode = new UIScrollableVerticalLayoutContainer(2); containerKidMode.setSize(Screen.width - backButton.width, Screen.height); //scrollable.setSize(width, height); containerKidMode.position = new Vector3(backButton.width, 0, 0); //scrollable.position = new Vector3((Screen.width - width) / 2, -Screen.height + height, 0); containerKidMode.zIndex = 1; containerKidMode.myPadding = backButton.width; ListLevels(containerKidMode, GameMode.KidMode); }
// 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); }
public void ListLevels(UIScrollableVerticalLayoutContainer container, GameMode gameMode) { // List of Campaigns. for (int c = 0; c < gameSetup.gameCampaigns.Length; c++) { var campaign = c; GameCampaign tempCampaign = gameSetup.gameCampaigns[campaign]; var txtCampaignName = text.addTextInstance(tempCampaign.campaignName, 0, 0); txtCampaignName.scale *= menuScale; txtCampaignName.color = tempCampaign.campaignNameColor; container.addChild(txtCampaignName); // List of Levels. var horizontalList = new UIHorizontalLayoutWrap(10); for (int l = 0; l < gameSetup.gameCampaigns[campaign].campaignLevels.Length; l++) { var level = l; GameLevel tempLevel = gameSetup.gameCampaigns[campaign].campaignLevels[level]; // Level string tempUp = (tempLevel.icon_up_override != "") ? tempLevel.icon_up_override : tempCampaign.icon_up; string tempDown = (tempLevel.icon_down_override != "") ? tempLevel.icon_down_override : tempCampaign.icon_down; var levelButton = UIButton.create(tempUp, tempDown, 0, 0); levelButton.scale *= menuScale; if (tempLevel.useButtonColor) { levelButton.color = tempLevel.buttonColor; } var buttonbox = new UIAbsoluteLayoutWrap(0); levelButton.localPosition = new Vector3(0, 0, 0); buttonbox.addChild(levelButton); // Score Text var scoreText = textSmall.addTextInstance(" ", 0, 0); scoreText.scale *= menuScale; scoreText.color = tempCampaign.campaignNameColor; scoreText.zIndex = -1; if (isLocked(c, l, gameMode)) { var lockedButton = UIButton.create("lock.png", "lock.png", 0, 0); lockedButton.scale *= menuScale; lockedButton.zIndex = -1; lockedButton.localPosition = new Vector3((levelButton.width / 2) - (lockedButton.width / 2), -((levelButton.height / 2) - (lockedButton.height / 1.5f)), 0); lockedButton.zIndex = -1; buttonbox.addChild(lockedButton); } else { // Level is playable levelButton.onTouchUpInside += (sender) => { StartLevel(sender, campaign, level); }; scoreText.text = (GetScore(c, l, gameMode) > 0) ? GetScore(c, l, gameMode).ToString() : "Play!"; if (tempCampaign.showLevelNumber) { // Level Text var levelText = text.addTextInstance((l + 1).ToString(), 0, 0); levelText.scale *= menuScale; levelText.color = Color.white; levelText.zIndex = -1; levelText.text = "" + (l + 1); levelText.localPosition = new Vector3((levelButton.width / 2) - (levelText.width / 2), -((levelButton.height / 2) - (levelText.height / 1.5f)), 0); levelText.zIndex = -1; buttonbox.addChild(levelText); } } // Absolute container to center the score text var scorebox = new UIAbsoluteLayoutWrap(0); scoreText.localPosition = new Vector3((levelButton.width / 2) - (scoreText.width / 2), 0, 0); scorebox.addChild(scoreText); var inBox = new UIVerticalLayoutWrap(0); //<----- fix the vertical layout issues w/ Text. inBox.addChild(buttonbox, scorebox); horizontalList.addChild(inBox); } container.addChild(horizontalList); } }