/// <summary> /// Update this visualisation /// </summary> /// <param name="input">The player to view</param> public void SetVisualisation(TreeInputAgent input) { currentTarget = input; // Clear columns foreach (KeyValueText kv in leftColumn) { Destroy(kv.gameObject); } foreach (KeyValueText kv in rightColumn) { Destroy(kv.gameObject); } leftColumn.Clear(); rightColumn.Clear(); // Create new columns if (currentTarget != null) { // Left column is agent vars int i = 0; foreach (var pair in currentTarget.tree.agentProfile.variables) { KeyValueText kv = Instantiate(leftColumnDefault, leftColumnDefault.transform.parent); RectTransform trans = kv.GetComponent <RectTransform>(); trans.position = trans.position + new Vector3(0, -trans.rect.height * i * 1.25f, 0); kv.Key = pair.Key; kv.Value = "" + pair.Value; kv.gameObject.SetActive(true); leftColumn.Add(kv); ++i; } // Right column is global vars i = 0; foreach (var pair in currentTarget.tree.globalVars.variables) { KeyValueText kv = Instantiate(rightColumnDefault, rightColumnDefault.transform.parent); RectTransform trans = kv.GetComponent <RectTransform>(); trans.position = trans.position + new Vector3(0, -trans.rect.height * i * 1.25f, 0); kv.Key = pair.Key; kv.Value = "" + pair.Value; kv.gameObject.SetActive(true); rightColumn.Add(kv); ++i; } } }
private void AddClick(Object sender, RoutedEventArgs e) { var text = KeyValueText.Text; var index = text.IndexOf('='); if (index >= 0) { var key = text.Substring(0, index).Trim(); var value = text.Substring(index + 1).Trim(); _content.Add(new KeyValuePair <String, String>(key, value)); KeyValueText.Clear(); } }
public StoreScreen(Action <Store> HireAgentFunction, Action <Store> FireAgentFunction) : base() { Layout.PushLayout("storeScreen"); this.HireAgentFunction = HireAgentFunction; this.FireAgentFunction = FireAgentFunction; Padding = new Point(10, 10); Margin = 10; SetFixedSize(700, 500); VerticalLayout leftSide = new VerticalLayout(); leftSide.SetFixedWidth(300); deliveredPizzas = new KeyValueText("deliveredPizzas", "0"); outStandingOrders = new KeyValueText("outstandingOrders", "0"); avgDeliveryTime = new KeyValueText("avgDeliveryTime", "5"); deliveryEmployeesCount = new KeyValueText("deliveryEmployees", "3"); HorizontalLayout buttonsHor = new HorizontalLayout(); Button hireButton = new Button("hireEmployee"); Button fireButton = new Button("fireEmployee"); hireButton.OnMouseClick = () => { HireAgentFunction(store); UpdateTexts(); }; fireButton.OnMouseClick = () => { FireAgentFunction(store); UpdateTexts(); }; buttonsHor.AddChild(hireButton, fireButton); lastWeeksIncome = new KeyValueText("lastWeekIncome", "0"); costs = new Text("costs"); weeklyRent = new KeyValueText("rent", "0"); weeklyEmployeeWage = new KeyValueText("employees", "0"); weeklyTotalCost = new KeyValueText("total", "0"); leftSide.AddChild(deliveryEmployeesCount); leftSide.AddChild(deliveredPizzas); leftSide.AddChild(outStandingOrders); leftSide.AddChild(avgDeliveryTime); leftSide.AddChild(buttonsHor); leftSide.AddChild(lastWeeksIncome); leftSide.AddChild(costs); leftSide.AddChild(weeklyRent); leftSide.AddChild(weeklyEmployeeWage); leftSide.AddChild(weeklyTotalCost); AddChild(leftSide); Layout.PopLayout("storeScreen"); }
public CityEntry(City city) { Padding = Point.Zero; this.city = city; name = new Text("aaaaaaaaaaaaaaaaaaa"); lvl1 = new KeyValueText("level1", "123111"); lvl2 = new KeyValueText("level2", "123111"); lvl3 = new KeyValueText("level3", "123111"); buttonDetail = new Button("seeDetails"); AddChild(name, lvl1, lvl2, lvl3, buttonDetail); UpdateTexts(); }
public UnitPanel(Func <Actor> GetActor, Dictionary <string, Sprite> uiSprites) { this.uiSprites = uiSprites; Padding = new Point(10, 4); this.SetAnchor(AnchorX.Left, AnchorY.Bottom); this.SetLayoutSize(LayoutSize.FixedSize, LayoutSize.WrapContent).SetFixedWidth(250); getStandardSprite = true; this.GetActor = GetActor; movesLeft = new KeyValueText("movesLeft", "1/1"); actionsLeft = new KeyValueText("actionsLeft", "1/1"); ammo = new KeyValueText("ammo", "3/4"); damage = new KeyValueText("damage", "1"); health = new KeyValueText("health", "1"); moveRange = new KeyValueText("moveRange", "1"); skillRange = new KeyValueText("skillRange", "1"); buttonTooltip = new Text("MOvement"); buttonTooltip.SetFontSize(FontSize.Small); buttonTooltip.SetColor(Color.LightSlateGray); HorizontalLayout buttonLayout = new HorizontalLayout(); buttons = new Button[(int)Skills.Num]; buttonLayout.Padding = new Point(6, 6); buttonLayout.SetMargin(10).SetLayoutSize(LayoutSize.MatchParent, LayoutSize.FixedSize); buttonLayout.SetFixedHeight(44); for (int i = 1; i < (int)Skills.Num; i++) { Skills s = (Skills)i; string sprite = s.ToString(); string otherSprite = s.ToString() + "Selected"; Button b = new Button(uiSprites[sprite]); b.OnMouseEnter = () => buttonTooltip.SetText(s.ToString()); b.OnMouseExit = () => buttonTooltip.SetText(""); b.OnMouseClick = () => SelectSkill(s); buttons[i] = b; buttonLayout.AddChild(b); } AddChild(actionsLeft, movesLeft, health, ammo, damage, moveRange, skillRange, buttonTooltip, buttonLayout); }
public EnemyInfoPanel(Func <Enemy> GetEnemy) { this.GetEnemy = GetEnemy; Padding = new Point(10, 4); this.SetAnchor(AnchorX.Right, AnchorY.Bottom); this.SetLayoutSize(LayoutSize.FixedSize, LayoutSize.WrapContent).SetFixedWidth(250); getStandardSprite = true; name = new Text("wuhuhuudedasda"); name.SetColor(Color.LightSlateGray); name.SetFontSize(FontSize.Medium); damage = new KeyValueText("damage", "1"); health = new KeyValueText("health", "1"); ammo = new KeyValueText("ammo", "1"); moveRange = new KeyValueText("moveRange", "1"); skillRange = new KeyValueText("skillRange", "1"); AddChild(name, health, ammo, damage, moveRange, skillRange); Close(); }
public TestScreen(Sprite houseSpr, Sprite frameSpr) { this.frameSpr = frameSpr; Padding = new Point(10, 10); Margin = 10; SetFixedSize(700, 500); HorizontalLayout mainHor = new HorizontalLayout(); mainHor.SetLayoutSizeForBoth(LayoutSize.MatchParent); VerticalLayout leftOverview = new VerticalLayout(); leftOverview.SetFixedSize(200, 300).SetLayoutSize(LayoutSize.FixedSize, LayoutSize.MatchParent); leftOverview.AddScrollbar(); leftOverview.Margin = 6; leftOverview.Padding = new Point(6, 2); int buildingsCount = 12; buildings = new VerticalLayout[buildingsCount]; for (int i = 0; i < buildingsCount; i++) { int index = i; VerticalLayout inner = new VerticalLayout(); inner.OnMouseEnter = () => { MouseOvered(index); }; buildings[i] = inner; inner.Padding = new Point(0, 4); inner.SetLayoutSize(LayoutSize.MatchParent, LayoutSize.WrapContent); Image im = new Image(houseSpr); inner.OnMouseClick = () => { SelectBuilding(index); }; inner.AddChild(im); inner.AddChild(new Text($"Name {i}").SetAllignments(Allignment.Middle, Allignment.Middle)); leftOverview.AddChild(inner); } selectedText = new KeyValueText("Selected Buildings:", selected.ToString()); selectedText.layoutSizeX = LayoutSize.WrapContent; VerticalLayout specifics = new VerticalLayout(); specifics.overwriteChildLayout = false; specifics.SetMargin(6); specifics.SetLayoutSizeForBoth(LayoutSize.MatchParent); //specifics.SetChildAllignment(Allignment.Bottom); specifics.childAllignX = AnchorX.Right; VerticalLayout buildingInfos = new VerticalLayout(); buildingInfos.Padding = new Point(10); //buildingInfos.GetStandardSprite(true); buildingInfos.SetLayoutSize(LayoutSize.MatchParent, LayoutSize.WrapContent); buildingName = new Text("Building Name"); buildingInfos.AddChild(buildingName); buildingStats = new KeyValueText[] { new KeyValueText("building info Test", "12"), new KeyValueText("and more", "13"), new KeyValueText("even more", "14"), new KeyValueText("even more", "15"), new KeyValueText("even more", "15") }; foreach (var el in buildingStats) { buildingInfos.AddChild(el); } specifics.AddChild(selectedText); specifics.AddChild(buildingInfos); mainHor.AddChild(leftOverview); mainHor.AddChild(specifics); HorizontalLayout buttons = new HorizontalLayout(); //buttons.SetChildAllignment(Allignment.Right).SetMargin(10); buttons.SetLayoutSize(LayoutSize.MatchParent, LayoutSize.WrapContent); finishButton = new Button("Finish Selection"); buttons.AddChild(finishButton); buttons.AddChild(new Button("Cancel")); specifics.AddChild(buttons); AddChild(mainHor); }
private void CreateUI() { Style.PushStyle("mapMain"); Layout.PushLayout("mapMain"); Style.PushStyle("panelSpriteOn"); VerticalLayout main = new VerticalLayout(); main.SetFixedWidth(250); Style.PopStyle("panelSpriteOn"); KeyValueText currSeedLabel = new KeyValueText("currSeed", "123456789"); currSeedLabel.SetValueTextUpdate(() => { return(mapParameter.randomSeed.ToString()); }); Checkbox keepOldSeedCheck = new Checkbox("keepCurrSeed", (val) => keepCurrentSeed = val, false, keepCurrentSeed); //Slider values: 0 -> Map Size 32, Slider 4 -> Map Size 512 KeyValueText xDesc = new KeyValueText("mapWidth", "128"); xDesc.SetValueTextUpdate(() => { return($"{mapParameter.size.X}"); }); Slider sizeX = new Slider((xVal) => SetMapSize(xVal, true), 0, 4, 1, GetMapSizeSliderVal(mapParameter.size.X)); KeyValueText yDesc = new KeyValueText("mapHeight", "512"); yDesc.SetValueTextUpdate(() => { return($"{mapParameter.size.Y}"); }); Slider sizeY = new Slider((yVal) => SetMapSize(yVal, false), 0, 4, 1, GetMapSizeSliderVal(mapParameter.size.Y)); /*Text terrainLabel = new Text("terrain"); * * KeyValueText minHeightDesc = new KeyValueText("minHeight", ""); * minHeightDesc.SetValueTextUpdate(() => $"{mapParameter.minHeight}"); * Slider minHeight = new Slider((val) => mapParameter.minHeight = val, 6, 12, 1, mapParameter.minHeight); * * KeyValueText maxHeightDesc = new KeyValueText("maxHeight", ""); * maxHeightDesc.SetValueTextUpdate(() => $"{mapParameter.maxHeight}"); * Slider maxHeight = new Slider((val) => mapParameter.maxHeight = val, 12, 20, 1, mapParameter.maxHeight); * * KeyValueText waterDiffDesc = new KeyValueText("waterDiff", ""); * waterDiffDesc.SetValueTextUpdate(() => $"{mapParameter.waterMinDiff}"); * Slider waterDiff = new Slider((val) => mapParameter.waterMinDiff = val, 0, 6, 1, mapParameter.waterMinDiff);*/ Checkbox checkWater = new Checkbox("hasWater", (val) => { mapParameter.hasWater = val; }, startValue: mapParameter.hasWater); Checkbox checkRivers = new Checkbox("hasRivers", (val) => { mapParameter.hasRivers = val; }, startValue: mapParameter.hasRivers); Checkbox checkCitiesConnect = new Checkbox("hasCityConnections", (val) => mapParameter.hasCityConnections = val, false, mapParameter.hasCityConnections); KeyValueText cityNumText = new KeyValueText("cityNum", "100%"); cityNumText.SetValueTextUpdate(() => { return($"{(int)(mapParameter.citiesNumber * 100f)}%"); }); Slider cityNumSlider = new Slider((val) => mapParameter.citiesNumber = val / 100f, 0, 100, 5, (int)(mapParameter.citiesNumber * 100f)); KeyValueText forestText = new KeyValueText("forestSize", $"{100}%"); forestText.SetValueTextUpdate(() => { return($"{(int)(mapParameter.forestSize * 100)}%"); }); Slider forestSlider = new Slider((val) => mapParameter.forestSize = val / 100f, 0, 100, 10, (int)(mapParameter.forestSize * 100)); KeyValueText resourceText = new KeyValueText("resourceSize", $"{100}%"); resourceText.SetValueTextUpdate(() => { return($"{(int)(mapParameter.resourceSize * 100)}%"); }); Slider resourceSlider = new Slider((val) => mapParameter.resourceSize = val / 100f, 0, 100, 10, (int)(mapParameter.resourceSize * 100)); KeyValueText citySizeText = new KeyValueText("citySize", $"{100}%"); citySizeText.SetValueTextUpdate(() => { return($"{mapParameter.citySize}"); }); Slider citySizeSlider = new Slider((val) => { mapParameter.citySize = citySizeBaseValue + (val / 100f * citySizeRange - citySizeRange / 2); }, 0, 100, 5, 50); KeyValueText citySizeOffsetText = new KeyValueText("citySizeRandomOffset", $"{100}%"); citySizeOffsetText.SetValueTextUpdate(() => { return($"{mapParameter.citySizeRandomOffset}"); }); Slider citySizeOffsetSlider = new Slider((val) => { mapParameter.citySizeRandomOffset = val / 100f * citySizeOffsetMax; }, 0, 100, 5, 50); Text mouseOverText = new Text("aaaaaaaaaaaaaaaaaaaaaaaaaaaaa").SetTextUpdateFunction(UpdateMouseOverTileText); mapGenButton = new GeneratingButton(); mapGenButton.OnMouseClick = GenerateNewMap; cancelButton = new GeneratingCancelButton(); cancelButton.OnMouseClick = CancelMapGeneration; Button exitButton = new Button("exit"); exitButton.OnMouseClick = game.Exit; main.AddChild(mouseOverText, new Space(6), currSeedLabel, keepOldSeedCheck, new Space(6), xDesc, sizeX, yDesc, sizeY, new Space(6), //minHeightDesc, minHeight, maxHeightDesc, maxHeight, waterDiffDesc, waterDiff , new Space(6), checkWater, checkRivers, checkCitiesConnect, cityNumText, cityNumSlider, new Space(6), citySizeText, citySizeSlider, new Space(6), citySizeOffsetText, citySizeOffsetSlider, new Space(6), forestText, forestSlider, resourceText, resourceSlider, new Space(6), mapGenButton, cancelButton, exitButton); uiCanvas.AddChild(main); Style.PopStyle("mapMain"); Layout.PopLayout("mapMain"); uiCanvas.FinishCreation(); }
private void CreateUI() { mainMenu = new MainMenu(Content, StartNewGame, game.Exit); mainMenuCanvas.AddChild(mainMenu); mainMenuCanvas.Finish(); Dictionary <string, SoundEffect> sounds = new Dictionary <string, SoundEffect>() { { "level0Intro", Content.Load <SoundEffect>("Sounds/level0Intro") }, { "level1Intro", Content.Load <SoundEffect>("Sounds/level1Intro") }, { "level2Intro", Content.Load <SoundEffect>("Sounds/level2Intro") }, { "gameFinished", Content.Load <SoundEffect>("Sounds/gameFinished") }, { "gameOver", Content.Load <SoundEffect>("Sounds/gameOver") }, }; transitionText = new MapTransitionText(TransitionContinueClicked, BackToMenu, game.Exit, sounds); transitionCanvas.AddChild(transitionText); transitionCanvas.Finish(); mapCanvas.AddChild(new UnitPanel(() => { if (currentMap != null) { return(currentMap.GetSelectedUnit()); } else { return(null); } }, mapCanvas.sprites)); mapCanvas.AddChild(new EnemyInfoPanel(() => { if (currentMap != null) { return(currentMap.GetMouseOverEnemy()); } else { return(null); } })); damagePopup = new DamagePopup(camera); Map.damagePopup = damagePopup; mapCanvas.AddChild(damagePopup); HorizontalLayout mainButtons = new HorizontalLayout(); mainButtons.SetMargin(6).Padding = new Point(6, 6); mainButtons.SetLayoutSize(LayoutSize.WrapContent, LayoutSize.FixedSize); mainButtons.SetFixedHeight(44); mainButtons.SetFixedWidth(270); mainButtons.sprite = mapCanvas.sprites["panel"]; Button menuButton = new Button(mapCanvas.sprites["menu"]); menuButton.SetFixedSize(32, 32); Button musicButton = new Button(Config.musicPlaying ? mapCanvas.sprites["musicOn"] : mapCanvas.sprites["musicOff"]); musicButton.SetFixedSize(32, 32); musicButton.OnMouseClick = () => { Config.musicPlaying = !Config.musicPlaying; if (Config.musicPlaying) { musicButton.sprite = mapCanvas.sprites["musicOn"]; } else { musicButton.sprite = mapCanvas.sprites["musicOff"]; } }; Button nextTurnButton = new Button(mapCanvas.sprites["nextTurn"]); nextTurnButton.SetFixedSize(32, 32); nextTurnButton.OnMouseClick = () => { if (currentMap != null) { currentMap.EndTurn(); } }; KeyValueText turnText = new KeyValueText("turns", "12"); turnText.SetLayoutSizeForBoth(LayoutSize.MatchParent); turnText.SetValueTextUpdate(() => { return(currentMap != null ? currentMap.turnCounter.ToString() : ""); }); mainButtons.AddChild(menuButton, musicButton, nextTurnButton, turnText); mapCanvas.AddChild(mainButtons); EnemyTurnSign enemyTurnSign = new EnemyTurnSign(() => { return(currentMap); }); mapCanvas.AddChild(enemyTurnSign); ControlsPanel controls = new ControlsPanel(mapCanvas.sprites); mapCanvas.AddChild(controls); mapCanvas.Finish(); }