Changeset 2284
- Timestamp:
- 2011-06-29 13:32:00 (12 years ago)
- Location:
- 2011/26/JuhoK/SFN
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/26/JuhoK/SFN/SFN/SFN/Peli.cs
r2262 r2284 12 12 { 13 13 List<Auto> autot = new List<Auto>(); 14 int ID = 0; 14 int ID = 0, max_taso = 20; 15 double raha = 5000; 15 16 16 17 Image MenuBackround = LoadImage("MenuBackround"); 17 Label number, malli, moottori, renkaat, moottorin_hinta, renkaiden_hinta ;18 Label number, malli, moottori, renkaat, moottorin_hinta, renkaiden_hinta, sell_price, rahat; 18 19 19 20 public override void Begin() … … 70 71 { 71 72 ClearAll(); 73 Keyboard.Listen(Key.Escape, ButtonState.Released, Exit, null); 74 Camera.ZoomToLevel(); 75 Level.BackgroundColor = Color.LightGray; 72 76 73 77 Label ylapalkki = new Label(Screen.Width, Screen.Height / 15); … … 87 91 Add(oikeareuna); 88 92 89 Keyboard.Listen(Key.Escape, ButtonState.Released, Exit, null);90 Camera.ZoomToLevel();91 Level.BackgroundColor = Color.LightGray;92 93 /*GameObject alapalkki = new GameObject(Level.Width, Level.Height / 4);94 alapalkki.X = 0;95 alapalkki.Y = Level.Bottom + alapalkki.Height / 2;96 Add(alapalkki);*/97 /*98 GameObject ylapalkki = new GameObject(Level.Width, Level.Height / 10);99 ylapalkki.X = 0;100 ylapalkki.Y = Level.Top - ylapalkki.Height / 2;101 Add(ylapalkki);102 */103 /*GameObject oikeareuna = new GameObject(Level.Width / 6, Level.Height);104 oikeareuna.Position = new Vector(Level.Right - oikeareuna.Width / 2, 0);105 Add(oikeareuna);*/106 93 107 94 //Next … … 118 105 119 106 PushButton update_engine = new PushButton("Update engine"); 120 update_engine.Position = new Vector( Level.Right + 65, Level.Top - 20);107 update_engine.Position = new Vector(oikeareuna.X, Screen.Top * 0.75); 121 108 update_engine.Clicked += new Action(update_engine_Clicked); 122 109 Add(update_engine); 123 110 124 111 PushButton update_tiers = new PushButton("Update tiers"); 125 update_tiers.Position = new Vector( Level.Right + 65, Level.Top - 140);112 update_tiers.Position = new Vector(oikeareuna.X, Screen.Top * 0.52); 126 113 update_tiers.Clicked += new Action(update_tiers_Clicked); 127 114 Add(update_tiers); 115 116 PushButton drive = new PushButton("Leave safehouse"); 117 drive.Position = new Vector(oikeareuna.X, Screen.Bottom * 0.4); 118 Add(drive); 119 120 PushButton sell = new PushButton("Sell car"); 121 sell.Position = new Vector(oikeareuna.X, Screen.Bottom * 0.2); 122 sell.Clicked += new Action(sell_Clicked); 123 Add(sell); 128 124 129 125 //Number … … 133 129 134 130 malli = new Label(autot[ID].korinnimi.ToString()); 135 malli.Position = new Vector( Level.Left, ylapalkki.Y); //Level.Left, Level.Top + 60131 malli.Position = new Vector(Screen.Left * 0.9, ylapalkki.Y); //Level.Left, Level.Top + 60 136 132 Add(malli); 137 133 138 moottori = new Label(" Moottori: " + autot[ID].moottori.ToString());139 moottori.Position = new Vector( Level.Left + 250, ylapalkki.Y); //Level.Left + 250, Level.Top * 1.2134 moottori = new Label("Engine: " + autot[ID].moottori.ToString()); 135 moottori.Position = new Vector(Screen.Left * 0.5, ylapalkki.Y); //Level.Left + 250, Level.Top * 1.2 140 136 Add(moottori); 141 137 142 143 renkaat = new Label("Renkaat: "+autot[ID].renkaat.ToString()); 144 renkaat.Position = new Vector(0, ylapalkki.Y); 138 rahat = new Label("Money: "+raha.ToString()); 139 rahat.Position = new Vector(oikeareuna.X, 0); 140 Add(rahat); 141 142 double hinta =(10000 + (autot[ID].kori * 100) * 0.75) + ((autot[ID].moottori * 100) / 2) + ((autot[ID].renkaat * 100) / 2); 143 sell_price = new Label("Sell price: " + hinta); 144 sell_price.Position = new Vector(oikeareuna.X, Screen.Bottom * 0.28); 145 Add(sell_price); 146 147 148 renkaat = new Label("Tiers: "+autot[ID].renkaat.ToString()); 149 renkaat.Position = new Vector(Screen.Left * 0.05, ylapalkki.Y); 145 150 //renkaat.Y = ylapalkki.Y; 146 151 //ylapalkki.Y = 200 - ylapalkki.Height/2; … … 148 153 Add(renkaat); 149 154 150 moottorin_hinta = new Label(" Hinta: " + (autot[ID].moottori * 100).ToString());151 moottorin_hinta.Position = new Vector( Level.Right + 65, Level.Top - 60);155 moottorin_hinta = new Label("Price: " + (autot[ID].moottori * 100).ToString()); 156 moottorin_hinta.Position = new Vector(oikeareuna.X, Screen.Top * 0.65); 152 157 Add(moottorin_hinta); 153 158 154 renkaiden_hinta = new Label(" Hinta: " + (autot[ID].renkaat * 100).ToString());155 renkaiden_hinta.Position = new Vector( Level.Right + 65, Level.Top - 180);159 renkaiden_hinta = new Label("Price: " + (autot[ID].renkaat * 100).ToString()); 160 renkaiden_hinta.Position = new Vector(oikeareuna.X, Screen.Top * 0.4); 156 161 Add(renkaiden_hinta); 157 162 158 163 } 159 164 165 void sell_Clicked() 166 { 167 if (autot.Count > 1) 168 { 169 double hinta = (10000 + (autot[ID].kori * 100) * 0.75) + ((autot[ID].moottori * 100) / 2) + ((autot[ID].renkaat * 100) / 2); 170 autot.RemoveAt(ID); 171 raha = raha + hinta; 172 ID = ++ID % autot.Count; 173 UpdateHUD(); 174 } 175 else 176 { 177 MessageDisplay.Add("Can't sell last car."); 178 } 179 } 180 160 181 void update_tiers_Clicked() 161 182 { 162 MessageDisplay.Add("Tiers updated."); 163 autot[ID].renkaat += 1; 183 int hinta = autot[ID].renkaat * 100; 184 if (raha >= hinta) 185 { 186 if (autot[ID].renkaat < max_taso) 187 { 188 raha = raha - hinta; 189 autot[ID].renkaat += 1; 190 } 191 else 192 { 193 MessageDisplay.Add("Can't update engine."); 194 } 195 } 196 else 197 { 198 MessageDisplay.Add("No enought money."); 199 } 164 200 UpdateHUD(); 165 201 } … … 167 203 void update_engine_Clicked() 168 204 { 169 MessageDisplay.Add("Engine updated."); 170 autot[ID].moottori += 1; 205 int hinta = autot[ID].moottori * 100; 206 if (raha >= hinta) 207 { 208 if (autot[ID].moottori < max_taso) 209 { 210 raha = raha - hinta; 211 autot[ID].moottori += 1; 212 } 213 else 214 { 215 MessageDisplay.Add("Can't update engine."); 216 } 217 } 218 else 219 { 220 MessageDisplay.Add("No enought money."); 221 } 171 222 UpdateHUD(); 172 223 } … … 186 237 void UpdateHUD() 187 238 { 239 double hinta = (10000 + (autot[ID].kori * 100) * 0.75) + ((autot[ID].moottori * 100) / 2) + ((autot[ID].renkaat * 100) / 2); 240 sell_price.Text = "Sell price: " + hinta.ToString(); 188 241 malli.Text = autot[ID].korinnimi.ToString(); 189 moottori.Text = " Moottori: " + autot[ID].moottori.ToString();190 renkaat.Text = " Renkaat: " + autot[ID].renkaat.ToString();242 moottori.Text = "Engine: " + autot[ID].moottori.ToString(); 243 renkaat.Text = "Tiers: " + autot[ID].renkaat.ToString(); 191 244 number.Text = (ID + 1).ToString() + "/" + autot.Count.ToString(); 192 moottorin_hinta.Text = " Hinta: " + (autot[ID].moottori * 100).ToString();193 renkaiden_hinta.Text = " Hinta: " + (autot[ID].renkaat * 100).ToString();245 moottorin_hinta.Text = "Price: " + (autot[ID].moottori * 100).ToString(); 246 renkaiden_hinta.Text = "Price: " + (autot[ID].renkaat * 100).ToString(); 194 247 } 195 248 }
Note: See TracChangeset
for help on using the changeset viewer.