- Timestamp:
- 2013-07-04 15:02:42 (10 years ago)
- Location:
- 2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME
- Files:
-
- 6 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAME.cs
r4414 r4438 14 14 15 15 PlatformCharacter pelaaja1; 16 bool voikoPelaajaAmpua = true; 17 Image DragonJonnenKuva = LoadImage("DragonJonne"); 16 18 Image VihunKuva = LoadImage("Vihu"); 17 19 Image[] seisomisanimaatio = LoadImages("Trollface"); … … 25 27 DoubleMeter elamat; 26 28 IntMeter esLaskuri; 29 Vector? maaliAlue; 27 30 28 31 SoundEffect laaserAani = LoadSoundEffect("maali"); 29 int nykyinenKentta = 2;32 int nykyinenKentta = 1; 30 33 31 34 32 35 public override void Begin() 36 37 33 38 { 34 39 AloitaKentta(nykyinenKentta); 35 40 } 36 37 38 void AloitaKentta( int kentanNro ) 39 { 41 42 43 void AloitaKentta(int kentanNro) 44 { 45 ClearAll(); 40 46 Gravity = new Vector(0, -1000); 41 47 … … 47 53 LisaaElamaPalkki(); 48 54 49 lataaEnergiaaAjastin.Interval = 0.9; 55 lataaEnergiaaAjastin = new Timer(); 56 lataaEnergiaaAjastin.Interval = 0.2; 50 57 lataaEnergiaaAjastin.Timeout += delegate { energia.Value += 1; }; 51 58 lataaEnergiaaAjastin.Start(); … … 60 67 void SeuraavaKentta() 61 68 { 62 AloitaKentta(nykyinenKentta + 1); 69 if (nykyinenKentta < 4) 70 { 71 AloitaKentta(nykyinenKentta + 1); 72 } 73 else 74 { 75 VoititPelin(); 76 } 77 } 78 79 void VoititPelin() 80 { 81 ClearAll(); 82 Label teksti = new Label("Voitit pelin"); 83 Add(teksti); 84 85 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, null); 63 86 } 64 87 … … 66 89 { 67 90 energia = new DoubleMeter(100, 0, 100); 68 91 energia.LowerLimit += delegate { voikoPelaajaAmpua = false; }; 92 energia.AddTrigger(20, TriggerDirection.Up, delegate(double d) { voikoPelaajaAmpua = true; }); 69 93 ProgressBar energiaPalkki = new ProgressBar(200, 35); 70 94 energiaPalkki.Position = new Vector(Screen.Right - 150, Screen.Top - 50); … … 92 116 TileMap kentta = TileMap.FromLevelAsset(kentanNimi); 93 117 kentta.SetTileMethod('#', LisaaTaso); 118 119 kentta.SetTileMethod('M', LisaaMaali); 120 kentta.SetTileMethod('O', LisaaDragonJonne); 94 121 kentta.SetTileMethod('*', LisaaTahti); 95 122 kentta.SetTileMethod('N', LisaaPelaaja); 96 123 kentta.SetTileMethod('V', LisaaVihu); 124 125 maaliAlue = null; 126 97 127 kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 98 128 Level.CreateBorders(); … … 100 130 Level.Background.FitToLevel(); 101 131 } 102 103 void LisaaVihu(Vector paikka, double leveys, double korkeus) 104 { 132 133 134 void LisaaMaali(Vector paikka, double leveys, double korkeys) 135 { 136 maaliAlue = paikka; 137 138 } 139 140 141 void LisaaDragonJonne(Vector paikka, double leveys, double korkeys) 142 { 143 144 DragonJonne DragonJonne = new DragonJonne(leveys * 6.9, korkeys * 6.5, 80); 145 //DragonJonne.IgnoresCollisionResponse = true; 146 DragonJonne.Restitution = 10.0; 147 DragonJonne.IgnoresGravity = true; 148 DragonJonne.Position = paikka; 149 //vihu.Color = Color.Red; 150 DragonJonne.Image = DragonJonnenKuva; 151 DragonJonne.Tag = "DragonJonne"; 152 DragonJonne.Shape = Shape.Circle; 153 Add(DragonJonne); 154 155 156 if (maaliAlue != null) 157 { 158 DragonJonne.MoveTo((Vector)maaliAlue, nopeus - 50, JonneVoittaa); 159 } 160 else 161 { 162 Timer ajastin = new Timer(); 163 ajastin.Interval = 2.0; 164 ajastin.Timeout += delegate { DragonJonne.Hit(RandomGen.NextVector(200.0, 300.0)); }; 165 ajastin.Start(); 166 167 DragonJonne.Elamat.LowerLimit += VoititPelin; 168 } 169 170 GameObject palkinPaikka = new GameObject(50, 50); 171 palkinPaikka.Position = new Vector(0, 150); 172 palkinPaikka.IsVisible = false; 173 //Add(palkinPaikka); 174 DragonJonne.Add(palkinPaikka); 175 176 ProgressBar DragonJonnenElamat = new ProgressBar(70, 30); 177 DragonJonnenElamat.IsVisible = true; 178 DragonJonnenElamat.BindTo(DragonJonne.Elamat); 179 palkinPaikka.Add(DragonJonnenElamat); 180 181 182 183 } 184 185 186 void JonneVoittaa() 187 { 188 189 MessageDisplay.Add("JONNE WON!"); pelaaja1.Destroy(); 190 } 191 192 193 194 195 void LisaaVihu(Vector paikka, double leveys, double korkeus) 196 { 105 197 106 198 Vihu vihu = new Vihu(leveys * 1.5, korkeus * 1.5, 5); … … 126 218 vihunElamat.BindTo(vihu.Elamat); 127 219 palkinPaikka.Add(vihunElamat); 128 129 130 } 131 132 133 134 135 136 137 138 139 140 141 142 143 144 220 221 222 } 223 void LisaaLaskuri() 224 { 225 esLaskuri = new IntMeter(0, 0, 6); 226 esLaskuri.UpperLimit += SeuraavaKentta; 227 228 Label pisteNaytto = new Label(); 229 pisteNaytto.Left = Screen.Left + 50; 230 pisteNaytto.Top = Screen.Top - 50; 231 pisteNaytto.TextColor = Color.White; 232 pisteNaytto.Color = Color.Black; 233 234 pisteNaytto.BindTo(esLaskuri); 235 Add(pisteNaytto); 236 } 145 237 146 238 void LisaaTaso(Vector paikka, double leveys, double korkeus) … … 171 263 AddCollisionHandler(pelaaja1, "es", TormaaTahteen); 172 264 AddCollisionHandler(pelaaja1, "Vihu", TormaaVihuun); 265 AddCollisionHandler(pelaaja1, "DragonJonne", TormaaVihuun); 173 266 174 267 //pelaaja1 on PlatformCharacter-tyyppinen … … 199 292 ((Vihu)kohde).Elamat.Value -= 0.2; 200 293 } 294 295 if (kohde is DragonJonne) 296 { 297 ((DragonJonne)kohde).Elamat.Value -= 0.2; 298 } 201 299 } 202 300 … … 204 302 void AmmuAseella(PlatformCharacter pelaaja) 205 303 { 206 if ( energia.Value < 1) return;304 if (!voikoPelaajaAmpua) return; 207 305 PhysicsObject ammus = pelaaja.Weapon.Shoot(); 208 306 pelaaja1.PlayAnimation(new Animation(hyokkausanimaatio)); … … 213 311 ammus.Width *= 2; 214 312 ammus.Image = ammusKuva; 215 //ammus.MaximumLifetime = TimeSpan.FromSeconds(5.0) 216 } 217 313 ammus.MaximumLifetime = TimeSpan.FromSeconds(1.0); 314 } 218 315 } 219 316 … … 245 342 void Liikuta(PlatformCharacter hahmo, double nopeus) 246 343 { 344 if (maaliAlue != null) 345 { 346 if (hahmo.Position.X >= maaliAlue.Value.X) 347 { 348 SeuraavaKentta(); 349 } 350 } 247 351 hahmo.Walk(nopeus); 248 352 } … … 260 364 } 261 365 262 366 263 367 } 264 368 … … 266 370 { 267 371 DoubleMeter elamat; 268 public DoubleMeter Elamat { get { return elamat; }}372 public DoubleMeter Elamat { get { return elamat; } } 269 373 public Vihu(double leveys, double korkeus, int elamia) 270 374 : base(leveys, korkeus) … … 278 382 279 383 } 384 385 public class DragonJonne : PhysicsObject 386 { 387 DoubleMeter elamat; 388 public DoubleMeter Elamat { get { return elamat; } } 389 public DragonJonne(double leveys, double korkeus, int elamia) 390 : base(leveys, korkeus) 391 392 { 393 elamat = new DoubleMeter(elamia, 0, elamia); 394 elamat.LowerLimit += delegate { this.Destroy(); }; 395 } 396 397 398 399 400 } -
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAMEContent/kentta2.txt
r4414 r4438 4 4 ################ # * # ################ 5 5 # # # # # # 6 # # # ## #* #6 # ### # ### ## #### * # 7 7 # * # # # # # # 8 8 # # # # # # … … 13 13 # ############################################################################################################ 14 14 ### # 15 ##### 16 ####### # V # V # V # V# #17 # ############################################################################################################ #18 # 19 # * ##### * V #20 # V # V # V # V # V ####### # ###########################################21 # ############################################################################################################# ##### # #22 ### 23 ##### 24 ####### # V # V# V # ################# V # V #15 ##### ######## ########### V # 16 ####### ############# # ## ###### ######################### # # 17 # V ##### # # 18 # ############### # V ### # 19 ######### # * ############# ############ V # * V # 20 # V ##### ### # ############ ## # # ########################################### 21 # ######### ####### ############# # # ##### # # 22 ### ### # # ###### #### ######### *# # 23 ##### # # ############# # 24 ####### # V # # V # V # V # ################# V # V # 25 25 ############################################################################################################ # #################################################### # 26 26 # ### ############# ### -
2013/27/ViljamiV/kill_everypody_GAME/kill_everypody_GAME/kill_everypody_GAMEContent/kill_everypody_GAMEContent.contentproj
r4414 r4438 46 46 </ItemGroup> 47 47 <ItemGroup> 48 <Compile Include="kentta3.txt"> 49 <Name>kentta3</Name> 50 <Importer>TextFileImporter</Importer> 51 <Processor>TextFileContentProcessor</Processor> 52 </Compile> 48 53 <Compile Include="maali.wav"> 49 54 <Name>maali</Name> … … 123 128 </Compile> 124 129 </ItemGroup> 130 <ItemGroup> 131 <Compile Include="DragonJonne.png"> 132 <Name>DragonJonne</Name> 133 <Importer>TextureImporter</Importer> 134 <Processor>TextureProcessor</Processor> 135 </Compile> 136 </ItemGroup> 137 <ItemGroup> 138 <Compile Include="kentta4.txt"> 139 <Name>kentta4</Name> 140 <Importer>TextFileImporter</Importer> 141 <Processor>TextFileContentProcessor</Processor> 142 </Compile> 143 </ItemGroup> 125 144 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 126 145 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.