public InventoryPlayer(InventoryScreen parent, string inventoryFont, Point position) { contentList = new List <InventorySlot>(); itemsToDraw = GuiList.createNewList(position, 10, new List <GuiLabel>(), 300); parent.addElement(itemsToDraw); fontName = inventoryFont; }
public OverlayEconomyState() { // Add the end turn button buttonEndTurn = GuiButton.createButtonWithLabel(MaxOfEmpires.overlayPos.ToPoint(), "End turn", null, "font"); addElement(buttonEndTurn); // Add a label showing whose turn it currently is labelCurrentPlayer = GuiLabel.createNewLabel(new Vector2(buttonEndTurn.Bounds.Right + 2, buttonEndTurn.Bounds.Top + 2), "Current player: ", "font"); addElement(labelCurrentPlayer); // Add a label telling the player how much money they have labelPlayerMoney = GuiLabel.createNewLabel(new Vector2(labelCurrentPlayer.Bounds.Left, labelCurrentPlayer.Bounds.Bottom + 5), "Money: 0G", "font"); addElement(labelPlayerMoney); labelPlayerMoneyPerTurn = GuiLabel.createNewLabel(new Vector2(labelCurrentPlayer.Bounds.Left, labelPlayerMoney.Bounds.Bottom + 5), "Money per turn: 0G", "font"); addElement(labelPlayerMoneyPerTurn); // Add a label telling the player how much population they have labelPlayerPopulation = GuiLabel.createNewLabel(new Vector2(labelCurrentPlayer.Bounds.Left, labelPlayerMoneyPerTurn.Bounds.Bottom + 5), "Free Population: 0", "font"); addElement(labelPlayerPopulation); // Add labels for unit stats listArmySoldiers = GuiList.createNewList(new Point(labelPlayerMoneyPerTurn.Bounds.Location.X, labelPlayerPopulation.Bounds.Bottom + 5), 5, new List <GuiElement>(), 300); listArmySoldiers.addElement(ElementArmySelection.CreateBuildButton(Point.Zero, "1", null, null)); // Add this so that the size is calculated correctly addElement(listArmySoldiers); buildingInfoPosition = new Point(buttonEndTurn.Bounds.Left, listArmySoldiers.Bounds.Bottom + listArmySoldiers.MaxHeight + 5); // Remove this label so that it doesn't display bullshit :) listArmySoldiers.removeElement(0); }
protected void AddUpgradeButton(GuiList buildingActions, string unitToUpgrade, int tier, Player player) { StringBuilder buttonText = new StringBuilder(); buttonText.Append("Upgrade to tier ").Append(tier + 1).Append(": ("); buttonText.Append(SoldierRegistry.GetUpgradeCost(unitToUpgrade, player.soldierTiers[unitToUpgrade])).Append("G): "); // Soldier ('cost'G) buildingActions.addElement(ElementBuildButton.CreateBuildButton(buildingActions.Bounds.Location, buttonText.ToString(), () => { TryUpgradeUnit(unitToUpgrade); }, "Upgrade")); }
protected void AddRecruitingButton(GuiList buildingActions, string unitToRecruit) { StringBuilder labelNextToButtonText = new StringBuilder(); labelNextToButtonText.Append(Translations.GetTranslation(unitToRecruit)).Append(" ("); // Soldier ( labelNextToButtonText.Append(SoldierRegistry.GetSoldierCost(unitToRecruit)).Append("G): "); // Soldier ('cost'G) buildingActions.addElement(ElementBuildButton.CreateBuildButton(buildingActions.Bounds.Location, labelNextToButtonText.ToString(), () => TrySpawnUnit(unitToRecruit), "Recruit")); }
void OnGUI() { GUILayout.Space(10); GuiList.Show(targetObject.targets, () => { Selection.activeObject = AssetDatabase.LoadMainAssetAtPath("Assets/SweetSugar/Resources/Levels/TargetEditorScriptable.asset"); }); GUILayout.Space(30); if (GUILayout.Button("Save")) { SaveSettings(); } }
public static List <GuiList> getBattleLabels(string fontName) { // Create a list of labels List <GuiList> battlesInformation = new List <GuiList>(); for (int i = 0; i < ongoingBattleList.Count; ++i) { GuiList battleLabels = ongoingBattleList[i].getLabels(300 * i, fontName); battlesInformation.Add(battleLabels); } // Return the created list return(battlesInformation); }
private void AddBuilderButton(EconomyGrid grid, GuiList listBuilderActions, string buildingName, Type buildingType) { // Create the label for the element StringBuilder label = new StringBuilder(); label.Append(Translations.GetTranslation(buildingName)).Append(" ("); label.Append(BuildingRegistry.GetCost(buildingName)).Append("G): "); // Create the element using the label, and add a BuildBuilding clickhandler listBuilderActions.addElement(ElementBuildButton.CreateBuildButton(listBuilderActions.Bounds.Location, label.ToString(), BuildBuilding(grid, buildingName, buildingType))); // Also add this buildingID-Type pair to the BuildingRegistry BuildingRegistry.buildingTypeById[buildingName] = buildingType; }
public OverlayEconomyState() { // Add the end turn button buttonEndTurn = GuiButton.createButtonWithLabel(new Point((int)MaxOfEmpires.OverlayPos.X + 20, 10), "End turn", null, "font"); addElement(buttonEndTurn); // Add a label showing whose turn it currently is labelCurrentPlayer = GuiLabel.createNewLabel(new Vector2(buttonEndTurn.Bounds.Right + 2, buttonEndTurn.Bounds.Top + 2), "Current player: ", "font"); addElement(labelCurrentPlayer); // Add labels for unit stats listArmySoldiers = GuiList.createNewList(new Point(buttonEndTurn.Bounds.Location.X, labelCurrentPlayer.Bounds.Bottom + 5), 5, new System.Collections.Generic.List <GuiLabel>(), 300); addElement(listArmySoldiers); }
public override void PopulateBuildingActions(GuiList buildingActions) { // Get this building's trainees IList <string> trainees = BuildingRegistry.GetTrainees(BUILDING_ID); // Add a button for every trainee foreach (string trainee in trainees) { AddRecruitingButton(buildingActions, trainee + "." + Owner.soldierTiers[trainee]); if (Owner.soldierTiers[trainee] < 3) { AddUpgradeButton(buildingActions, trainee, Owner.soldierTiers[trainee], Owner); } } // Add the basic building actions base.PopulateBuildingActions(buildingActions); }
public void InitBuildingList(EconomyGrid grid) { // Create the list of building possibilities listBuilderActions = GuiList.createNewList(BuildingInfoPosition, 5, new List <GuiElement>(), 300); // Add all the corresponding elements to the building actions list AddBuilderButton(grid, listBuilderActions, "building.town", typeof(Town)); AddBuilderButton(grid, listBuilderActions, "building.mine", typeof(Mine)); AddBuilderButton(grid, listBuilderActions, "building.trainingGrounds", typeof(TrainingGrounds)); AddBuilderButton(grid, listBuilderActions, "building.academy", typeof(Academy)); // Also add the capital to the building registry, for saving and loading from files BuildingRegistry.buildingTypeById["building.capital"] = typeof(Capital); // Make sure the list knows how big it is and add it to the screen listBuilderActions.calculateElementPositions(); addElement(listBuilderActions); // Create the building actions list and add it to the screen listBuildingActions = GuiList.createNewList(BuildingInfoPosition, 5, new List <GuiElement>(), 300); addElement(listBuildingActions); }
public GuiList getLabels(int xPos, string fontName) { // Create a list of labels List <GuiLabel> allLabels = new List <GuiLabel>(); // Initialize the labels and add them to the list // TODO it would be better to make these labels fields and update them, rather than creating new ones every update. // This would also eliminate the need to re-add them to another list every update, as the reference stays equal. -Ebilkill labelHeroStats = GuiLabel.createNewLabel(new Vector2(xPos, 0), "Hero " + heroes[0].Name + " has " + heroes[0].Stats.HP + " HP.", fontName); labelEnemyStats = GuiLabel.createNewLabel(new Vector2(xPos, 200), "Enemy " + enemies[0].Name + " has " + enemies[0].Stats.HP + " HP.", fontName); labelElapsedTime = GuiLabel.createNewLabel(new Vector2(xPos, 300), "Elapsed time " + Math.Round(elapsedTime, 2), fontName); labelCountdown = GuiLabel.createNewLabel(new Vector2(xPos, 400), "Countdown " + Math.Round(countdown, 2), fontName); allLabels.Add(labelHeroStats); allLabels.Add(labelEnemyStats); allLabels.Add(labelElapsedTime); allLabels.Add(labelCountdown); // Return the generated list return(GuiList.createNewList(new Point(xPos, 0), 3, allLabels)); }
public override void PopulateBuildingActions(GuiList buildingActions) { buildingActions.addElement(ElementBuildButton.CreateBuildButton(buildingActions.Bounds.Location, "Builder (500G)", () => TrySpawnBuilder())); }
public void ShowList(IList list) { GuiList.Show(list); }
/// <summary> /// Erstellt alle notwendigen komponenten /// </summary> public override void Init() { update = true; Components.Add(new GuiButton("Suche") { Location = new Vector(-100, 155), RX = 0.5f, Size = new Vector(200, 50), BackColor = Color.LawnGreen, FontColor = Color.White }); GetComponent <GuiButton>("Suche").OnClick += OnClick_NewGame; //holt alle notwendigen informationen vom server Update().Wait(); base.Init(); //liste von aktiven spielen GuiList <GuiGameInfo> games = new GuiList <GuiGameInfo>("Aktive Spiele") { Location = new Vector(10, 200), RWidth = 1, Size = new Vector(0, 0) }; //liste von vergangenen spielen GuiList <GuiGameInfo> gamesClosed = new GuiList <GuiGameInfo>("Vergangene Spiele") { Location = new Vector(10, 200), RWidth = 1, Size = new Vector(0, 0) }; games.SetLocationAndSize(this, Size); gamesClosed.SetLocationAndSize(this, Size); //hinzufügen der spiele foreach (Game g in this.games) { GuiGameInfo info = new GuiGameInfo(g) { RWidth = 1, Size = new Vector(-50, 100), BackColor = Color.White, }; info.InfoClick += ActiveGameClick; if (!g.Active) { gamesClosed.Add(info); } else { games.Add(info); } } gamesClosed.Init(); games.Init(); //liste von anfragen GuiList <GuiPlayerInfo> friendRequests = new GuiList <GuiPlayerInfo>("Freundschaftsanfragen") { Location = new Vector(10, 200), RWidth = 1, Size = new Vector(0, 0) }; { friendRequests.SetLocationAndSize(this, Size); //hinzufügen der anfragen foreach (Player p in this.friendRequests) { GuiPlayerInfo info = new GuiPlayerInfo(p, "möchte dein Freund sein", 2) { RWidth = 1, Size = new Vector(-50, 100), BackColor = Color.White, }; info.InfoClick += HandleFriendRequest; friendRequests.Add(info); } friendRequests.Init(); if (friendRequests.Components.Count > 0) { Components.Add(friendRequests); } } //liste von anfragen GuiList <GuiPlayerInfo> gameRequests = new GuiList <GuiPlayerInfo>("Spielanfragen") { Location = new Vector(10, 200), RWidth = 1, Size = new Vector(0, 0) }; { gameRequests.SetLocationAndSize(this, Size); //hinzufügen der anfragen foreach (Player p in this.gameRequests) { GuiPlayerInfo info = new GuiPlayerInfo(p, "möchte spielen", 2) { RWidth = 1, Size = new Vector(-50, 100), BackColor = Color.White, }; info.InfoClick += HandleGameRequest;; gameRequests.Add(info); } gameRequests.Init(); if (gameRequests.Components.Count > 0) { Components.Add(gameRequests); } } //fügt die listen hinzu falls diese elemente beinhalten if (games.Components.Count > 0) { Components.Add(games); } if (gamesClosed.Components.Count > 0) { Components.Add(gamesClosed); } SearchForUpdates(); }
public virtual void PopulateBuildingActions(GuiList buildingActions) { }