- Timestamp:
- 2012-04-20 10:48:17 (11 years ago)
- Location:
- 2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/JAO/jouni/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1/Tasohyppelypeli1.cs
r2730 r2732 9 9 public class Tasohyppelypeli1 : PhysicsGame 10 10 { 11 int kenttaNro = 1; 11 12 int lkm; 12 13 const double nopeus = 200; … … 27 28 { 28 29 29 if (DataStorage.Exists("pisteet3.xml"))30 topLista = DataStorage.Load<ScoreList>(topLista, "pisteet3.xml");30 //if (DataStorage.Exists("pisteet3.xml")) 31 //topLista = DataStorage.Load<ScoreList>(topLista, "pisteet3.xml"); 31 32 Valikko(); 32 33 } 33 void AloitaPeli( string tied)34 void AloitaPeli(int kentta) 34 35 { 35 36 ClearAll(); 36 37 lkm = 0; 37 38 Gravity = new Vector(0, -1000); 38 luoKentta(tied); 39 if (kentta == 1) luoKentta("kentta1.txt"); 40 else if (kentta == 2) luoKentta("kentta2.txt"); 41 else 42 { 43 kentta = 1; 44 Valikko(); 45 } 46 47 //luoKentta(kentta); 39 48 Level.Background.Image = taustaKuva; 40 49 … … 72 81 { 73 82 case 0: 74 AloitaPeli( "kentta1.txt");83 AloitaPeli(kenttaNro); 75 84 break; 76 85 case 1: 77 AloitaPeli("kentta2.txt"); 86 kenttaNro = 2; 87 AloitaPeli(kenttaNro); 78 88 break; 79 89 case 2: … … 105 115 { 106 116 case 0: 107 AloitaPeli( "kentta1.txt");117 AloitaPeli(kenttaNro); 108 118 break; 109 119 case 1: … … 139 149 pisteNaytto.Y = Screen.Top - 100; 140 150 pisteNaytto.TextColor = Color.Red; 151 141 152 pisteLaskuri.MaxValue = lkm; 153 142 154 pisteLaskuri.UpperLimit += laskuriYlarajassa; 143 155 pisteNaytto.BindTo(pisteLaskuri); … … 156 168 void ParhaatPisteet() 157 169 { 170 MultiSelectWindow parhaatPisteetValikko = new MultiSelectWindow("valitse kenttä", 171 "kenttä 1", "kenttä 2", "takaisin"); 172 parhaatPisteetValikko.ItemSelected += PainettiinparhaatPisteetValikonNappia; 173 Add(parhaatPisteetValikko); 174 175 /*HighScoreWindow topIkkuna = new HighScoreWindow( 176 "Parhaat pisteet", 177 topLista); 178 topIkkuna.Closed += TallennaPisteet; 179 Add(topIkkuna);*/ 180 } 181 182 void PainettiinparhaatPisteetValikonNappia(int valinta) 183 { 184 switch (valinta) 185 { 186 case 0: 187 naytaParhaatPisteet(1); 188 break; 189 case 1: 190 naytaParhaatPisteet(2); 191 break; 192 case 2: 193 Valikko(); 194 break; 195 } 196 } 197 198 void naytaParhaatPisteet(int kentta) 199 { 200 if (DataStorage.Exists("pisteet" + kentta + ".xml")) 201 topLista = DataStorage.Load<ScoreList>(topLista, "pisteet" + kentta + ".xml"); 202 else 203 topLista = new ScoreList(10, true, 999); 158 204 HighScoreWindow topIkkuna = new HighScoreWindow( 159 205 "Parhaat pisteet", 160 206 topLista); 161 topIkkuna.Closed += TallennaPisteet;207 topIkkuna.Closed += delegate { kenttaNro = 1; Valikko(); }; 162 208 Add(topIkkuna); 163 209 } 210 164 211 void TallennaPisteet(Window sender) 165 212 { 166 DataStorage.Save<ScoreList>(topLista, "pisteet3.xml"); 167 Valikko(); 213 DataStorage.Save<ScoreList>(topLista, "pisteet" + kenttaNro + ".xml"); 214 kenttaNro = kenttaNro + 1; 215 AloitaPeli(kenttaNro); 168 216 } 169 217 void luoKentta(string tied) 170 218 { 219 if (DataStorage.Exists("pisteet" + kenttaNro + ".xml")) 220 topLista = DataStorage.Load<ScoreList>(topLista, "pisteet" + kenttaNro + ".xml"); 221 else 222 topLista = new ScoreList(10, true, 999); 223 171 224 TileMap kentta = TileMap.FromFile(tied); 172 225 kentta.SetTileMethod('#', lisaaTaso);
Note: See TracChangeset
for help on using the changeset viewer.