1 | using System; |
---|
2 | using System.Collections.Generic; |
---|
3 | using System.Linq; |
---|
4 | using System.Text; |
---|
5 | using Jypeli; |
---|
6 | using Jypeli.Widgets; |
---|
7 | using Entity; |
---|
8 | |
---|
9 | namespace Gui |
---|
10 | { |
---|
11 | public class InGameGui : Widget |
---|
12 | { |
---|
13 | private TheDungeonGame game; |
---|
14 | private Widget inventoryItem; |
---|
15 | public IntMeter bossHealth; |
---|
16 | private BarGauge bossMeterBar; |
---|
17 | |
---|
18 | |
---|
19 | public InGameGui(TheDungeonGame game) |
---|
20 | : base(TheDungeonGame.Screen.Width, TheDungeonGame.Screen.Height - (TheDungeonGame.ROOMHEIGHT + TheDungeonGame.ROOMTHICKNESS), Shape.Rectangle) |
---|
21 | { |
---|
22 | this.game = game; |
---|
23 | Left = TheDungeonGame.Screen.Left; |
---|
24 | Top = TheDungeonGame.Screen.Top; |
---|
25 | Color = Color.Black; |
---|
26 | setupTexts(); |
---|
27 | setupHealthMeter(); |
---|
28 | // setupInventory(); |
---|
29 | } |
---|
30 | |
---|
31 | public void setupInfoMeters() |
---|
32 | { |
---|
33 | Label weaponSpeedText = new Label(); |
---|
34 | weaponSpeedText.BindTo(game.Player.weaponSpeedMeter); |
---|
35 | weaponSpeedText.Right += 200; |
---|
36 | weaponSpeedText.Top += 30; |
---|
37 | weaponSpeedText.TextColor = Color.White; |
---|
38 | weaponSpeedText.Color = Color.Transparent; |
---|
39 | Add(weaponSpeedText); |
---|
40 | |
---|
41 | Label weaponSpeedInfo = new Label("Shooting delay"); |
---|
42 | weaponSpeedInfo.Top += 30; |
---|
43 | weaponSpeedInfo.Right += 90; |
---|
44 | weaponSpeedInfo.TextColor = Color.White; |
---|
45 | weaponSpeedInfo.Color = Color.Transparent; |
---|
46 | Add(weaponSpeedInfo); |
---|
47 | |
---|
48 | Label weaponDamageText = new Label(); |
---|
49 | weaponDamageText.BindTo(game.Player.weaponDamageMeter); |
---|
50 | weaponDamageText.Right += 200; |
---|
51 | weaponDamageText.Top += 10; |
---|
52 | weaponDamageText.TextColor = Color.White; |
---|
53 | weaponDamageText.Color = Color.Transparent; |
---|
54 | Add(weaponDamageText); |
---|
55 | |
---|
56 | Label weaponDamageInfo = new Label("Weapon's damage"); |
---|
57 | weaponDamageInfo.Top += 10; |
---|
58 | weaponDamageInfo.Right += 80; |
---|
59 | weaponDamageInfo.TextColor = Color.White; |
---|
60 | weaponDamageInfo.Color = Color.Transparent; |
---|
61 | Add(weaponDamageInfo); |
---|
62 | |
---|
63 | |
---|
64 | Label bulletLifeText = new Label(); |
---|
65 | bulletLifeText.BindTo(game.Player.bulletLifeMeter); |
---|
66 | bulletLifeText.Top -= 10; |
---|
67 | bulletLifeText.Right += 200; |
---|
68 | bulletLifeText.TextColor = Color.White; |
---|
69 | bulletLifeText.Color = Color.Transparent; |
---|
70 | Add(bulletLifeText); |
---|
71 | |
---|
72 | Label bulletLifeInfo = new Label("Bullet's lifetime"); |
---|
73 | bulletLifeInfo.Top -= 10; |
---|
74 | bulletLifeInfo.Right += 95; |
---|
75 | bulletLifeInfo.TextColor = Color.White; |
---|
76 | bulletLifeInfo.Color = Color.Transparent; |
---|
77 | Add(bulletLifeInfo); |
---|
78 | |
---|
79 | |
---|
80 | } |
---|
81 | |
---|
82 | private void setupTexts() |
---|
83 | { |
---|
84 | Label levelText = new Label("Level " + game.LevelGen.level); |
---|
85 | levelText.TextColor = Color.White; |
---|
86 | levelText.Color = Color.Transparent; |
---|
87 | levelText.Left = Left; |
---|
88 | levelText.Top += 30; |
---|
89 | Add(levelText); |
---|
90 | } |
---|
91 | |
---|
92 | private void setupHealthMeter() |
---|
93 | { |
---|
94 | Label healthAmount = new Label(); |
---|
95 | healthAmount.BindTo(game.Player.playerHealth); |
---|
96 | healthAmount.Color = Color.Transparent; |
---|
97 | healthAmount.TextColor = Color.Red; |
---|
98 | healthAmount.TextScale = new Vector(1.5, 1.5); |
---|
99 | healthAmount.Right = Right - 100; |
---|
100 | |
---|
101 | Add(healthAmount); |
---|
102 | |
---|
103 | Image heartTexture = TheDungeonGame.LoadImage("gui/heart"); |
---|
104 | Widget heartImage = new Widget(heartTexture.Width / 4, heartTexture.Height / 4); |
---|
105 | heartImage.Image = heartTexture; |
---|
106 | heartImage.Right = healthAmount.Right - 50; |
---|
107 | |
---|
108 | Add(heartImage); |
---|
109 | } |
---|
110 | |
---|
111 | private void setupInventory() |
---|
112 | { |
---|
113 | Label itemText = new Label("Item"); |
---|
114 | itemText.Color = Color.Transparent; |
---|
115 | itemText.TextColor = Color.White; |
---|
116 | itemText.Right = Right - 200; |
---|
117 | itemText.Top += 30; |
---|
118 | Add(itemText); |
---|
119 | |
---|
120 | inventoryItem = new Widget(64, 64); |
---|
121 | setInventoryImage(game.Player.ItemInInventory); |
---|
122 | inventoryItem.Right = itemText.Right + itemText.Width / 4; |
---|
123 | inventoryItem.Top = itemText.Top - 20; |
---|
124 | inventoryItem.Color = Color.Transparent; |
---|
125 | inventoryItem.BorderColor = Color.DarkGray; |
---|
126 | Add(inventoryItem); |
---|
127 | } |
---|
128 | |
---|
129 | public void setInventoryImage(Items.Item item) |
---|
130 | { |
---|
131 | Image texture; |
---|
132 | if (item == null) texture = null; |
---|
133 | else texture = item.itemTexture; |
---|
134 | |
---|
135 | inventoryItem.Image = texture; |
---|
136 | } |
---|
137 | |
---|
138 | public void setupBossGauge(EntityBase entity) |
---|
139 | { |
---|
140 | bossHealth = new IntMeter(entity.health, 0, entity.health); |
---|
141 | |
---|
142 | bossMeterBar = new BarGauge(20, TheDungeonGame.Screen.Width / 4); |
---|
143 | bossMeterBar.Angle = Angle.FromDegrees(270); |
---|
144 | bossMeterBar.Color = Color.Red; |
---|
145 | bossMeterBar.BarColor = Color.Green; |
---|
146 | bossMeterBar.BorderColor = Color.White; |
---|
147 | bossMeterBar.Right -= 40; |
---|
148 | bossMeterBar.BindTo(bossHealth); |
---|
149 | Add(bossMeterBar); |
---|
150 | } |
---|
151 | |
---|
152 | public void destroyBossGauge() |
---|
153 | { |
---|
154 | if (bossMeterBar != null) |
---|
155 | bossMeterBar.Destroy(); |
---|
156 | } |
---|
157 | } |
---|
158 | } |
---|