|
| 1 | +using C7Engine; |
| 2 | +using C7GameData; |
| 3 | +using Godot; |
| 4 | +using System; |
| 5 | + |
| 6 | +public partial class MilitaryAdvisor : TextureRect { |
| 7 | + Label totalUnitsLabel = new(); |
| 8 | + Label allowedUnitsLabel = new(); |
| 9 | + Label unitSupportCostLabel = new(); |
| 10 | + |
| 11 | + public override void _Ready() { |
| 12 | + this.CreateUI(); |
| 13 | + } |
| 14 | + |
| 15 | + private void CreateUI() { |
| 16 | + this.Texture = Util.LoadTextureFromPCX("Art/Advisors/military.pcx"); |
| 17 | + |
| 18 | + //TODO: Age-based background. Only use Ancient for now. |
| 19 | + ImageTexture AdvisorHappy = Util.LoadTextureFromPCX("Art/SmallHeads/popupMILITARY.pcx", 1, 40, 149, 110); |
| 20 | + ImageTexture AdvisorAngry = Util.LoadTextureFromPCX("Art/SmallHeads/popupMILITARY.pcx", 151, 40, 149, 110); |
| 21 | + ImageTexture AdvisorSad = Util.LoadTextureFromPCX("Art/SmallHeads/popupMILITARY.pcx", 301, 40, 149, 110); |
| 22 | + ImageTexture AdvisorSurprised = Util.LoadTextureFromPCX("Art/SmallHeads/popupMILITARY.pcx", 451, 40, 149, 110); |
| 23 | + |
| 24 | + TextureRect AdvisorHead = new TextureRect(); |
| 25 | + //TODO: Randomize or set logically |
| 26 | + AdvisorHead.Texture = AdvisorSurprised; |
| 27 | + AdvisorHead.SetPosition(new Vector2(851, 0)); |
| 28 | + AddChild(AdvisorHead); |
| 29 | + |
| 30 | + ImageTexture DialogBoxTexture = Util.LoadTextureFromPCX("Art/Advisors/dialogbox.pcx"); |
| 31 | + TextureButton DialogBox = new TextureButton(); |
| 32 | + DialogBox.TextureNormal = DialogBoxTexture; |
| 33 | + DialogBox.SetPosition(new Vector2(806, 110)); |
| 34 | + AddChild(DialogBox); |
| 35 | + |
| 36 | + //TODO: Multi-line capabilities |
| 37 | + Label DialogBoxAdvise = new Label(); |
| 38 | + DialogBoxAdvise.Text = "You are running C7!"; |
| 39 | + DialogBoxAdvise.SetPosition(new Vector2(815, 119)); |
| 40 | + AddChild(DialogBoxAdvise); |
| 41 | + |
| 42 | + ImageTexture GoBackTexture = Util.LoadTextureFromPCX("Art/exitBox-backgroundStates.pcx", 0, 0, 72, 48); |
| 43 | + TextureButton GoBackButton = new TextureButton(); |
| 44 | + GoBackButton.TextureNormal = GoBackTexture; |
| 45 | + GoBackButton.SetPosition(new Vector2(952, 720)); |
| 46 | + AddChild(GoBackButton); |
| 47 | + GoBackButton.Pressed += ReturnToMenu; |
| 48 | + |
| 49 | + using (UIGameDataAccess gameDataAccess = new()) { |
| 50 | + Player player = gameDataAccess.gameData.GetHumanPlayers()[0]; |
| 51 | + var (totalUnits, allowedUnits, unitSupportCost) = player.TotalUnitsAllowedUnitsAndSupportCost(); |
| 52 | + |
| 53 | + AddChild(totalUnitsLabel); |
| 54 | + totalUnitsLabel.SetPosition(new Vector2(0, 90)); |
| 55 | + totalUnitsLabel.SetTextAndCenterLabel($"Total Units\n{totalUnits}"); |
| 56 | + totalUnitsLabel.Position += new Vector2(-50, 0); |
| 57 | + |
| 58 | + AddChild(allowedUnitsLabel); |
| 59 | + allowedUnitsLabel.SetPosition(new Vector2(0, 139)); |
| 60 | + allowedUnitsLabel.SetTextAndCenterLabel($"Allowed Units\n{allowedUnits}"); |
| 61 | + allowedUnitsLabel.Position += new Vector2(-50, 0); |
| 62 | + |
| 63 | + AddChild(unitSupportCostLabel); |
| 64 | + unitSupportCostLabel.SetPosition(new Vector2(0, 188)); |
| 65 | + unitSupportCostLabel.SetTextAndCenterLabel($"Unit Support Cost\n{unitSupportCost} gold/turn"); |
| 66 | + unitSupportCostLabel.Position += new Vector2(-50, 0); |
| 67 | + } |
| 68 | + |
| 69 | + } |
| 70 | + |
| 71 | + private void ReturnToMenu() { |
| 72 | + GetParent<Advisors>().Hide(); |
| 73 | + } |
| 74 | +} |
0 commit comments