Changeset 2444 for 2011/24/LauriK/Call of garden Modern carrotfare 2/Call of garden Modern carrotfare 2/Peli.cs
- Timestamp:
- 2011-07-14 17:17:40 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/24/LauriK/Call of garden Modern carrotfare 2/Call of garden Modern carrotfare 2/Peli.cs
r2105 r2444 14 14 const int RUUDUN_KOKO = 40; 15 15 16 int kentanNro = 1;16 int kentanNro = 0; 17 17 18 18 ScoreList topLista = new ScoreList(10, false, 0); … … 24 24 PhysicsObject uusikranaatti; 25 25 PhysicsObject raha; 26 26 27 27 IntMeter panoslaskuri; 28 28 IntMeter pistelaskuri; … … 44 44 Image alustus1 = LoadImage("alustus1"); 45 45 Image alustus2 = LoadImage("alustus2"); 46 //Image alustus3 = LoadImage("alustus3"); 46 47 Image maalinKuva = LoadImage("Maali"); 47 48 Image alkuvalikko = LoadImage("alkuvalikko"); … … 55 56 { 56 57 topLista = DataStorage.Load<ScoreList>(topLista, "pisteet.xlm"); 57 } 58 58 } 59 59 60 rajahdyksenTomaattiUhrit = new List<GameObject>(); 60 61 rajahdyksenPorkkanaUhri = new List<GameObject>(); … … 62 63 pelaajanKuvaPeilattu = Image.Mirror(pelaajanKuva); 63 64 vihollisenKuvaPeilattu = Image.Mirror(vihollisenKuva); 64 65 Valikkoon(); 66 65 67 66 SeuraavaKentta(kentanNro); 67 68 //pelaajallaOnLaser = (false); 68 69 69 70 Gravity = new Vector(0, -1000); … … 75 76 } 76 77 77 void Valikko on()78 void Valikko() 78 79 { 79 80 Camera.Reset(); … … 85 86 Level.Background.Height = Screen.Height; 86 87 88 Label versio = new Label(); 89 versio.SizeMode = TextSizeMode.Wrapped; 90 versio.Width = Screen.Width - 100; 91 versio.Height = Screen.Height; 92 versio.X = 500; 93 versio.Y = -95; 94 versio.TextColor = Color.Green; 95 versio.Font = Font.DefaultLargeBold; 96 Add(versio); 97 versio.Text = "Beta 2.0"; 98 87 99 MediaPlayer.Play("alkuaani"); 88 100 89 //MediaPlayer.Play("");90 91 101 ClearControls(); 92 102 103 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 93 104 Keyboard.Listen(Key.Enter, ButtonState.Pressed, SeuraavaKentta, "Aloita peli", 1); 94 105 106 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 95 107 ControllerOne.Listen(Button.Start, ButtonState.Pressed, SeuraavaKentta, "Aloita peli", 1); 108 96 109 } 97 110 98 111 void SeuraavaKentta(int kentanNro) 99 112 { 100 113 if (kentanNro == 0) Valikko(); 101 114 if (kentanNro == 1) luoAlustus1(); 102 115 else if (kentanNro == 2) luoAlustus2(); 103 //else if (kent taLaskuri.Value== 3) luoAlustus3();116 //else if (kentanNro == 3) luoAlustus3(); 104 117 else if (kentanNro > 2) LopetaPeli(); 105 106 107 108 118 } 109 119 … … 125 135 126 136 ControllerOne.Listen(Button.Start, ButtonState.Pressed, TeeKentta1,"Aloita kenttä"); 137 138 MessageDisplay.TextColor = Color.White; 127 139 } 128 140 … … 134 146 135 147 Level.Background.Image = alustus2; 136 Level.Background.FitToLevel(); 148 Level.Background.Width = Screen.Width; 149 Level.Background.Height = Screen.Height; 137 150 138 151 MediaPlayer.Play("alustus2aani"); … … 143 156 144 157 ControllerOne.Listen(Button.Start, ButtonState.Pressed, TeeKentta2, "Aloita kenttä"); 145 } 146 147 //void luoKentta3() 158 159 MessageDisplay.TextColor = Color.White; 160 } 161 162 //void luoAlustus3() 148 163 //{ 149 // TileMap kentta = TileMap.FromFile(); 150 // kentta['#'] = lisaaTaso; 151 // kentta['K'] = lisaaTaso2; 152 // kentta['N'] = lisaaPelaaja; 153 // kentta['E'] = lisaaTomaatti; 154 // kentta['L'] = LuoLipas; 155 // kentta['A'] = LuoKranaatti; 156 // kentta['T'] = lisaaTomaatti2; 157 // kentta['M'] = LuoMaali; 158 // kentta['R'] = LuoRaha; 159 // kentta.Insert(RUUDUN_KOKO, RUUDUN_KOKO); 160 // Level.CreateBorders(); 161 //Level.Background.CreateGradient(Color.Green,Color.Black); 164 // Camera.Reset(); 165 166 // ClearAll(); 167 168 // Level.Background.Image = alustus3; 169 // Level.Background.Width = Screen.Width; 170 // Level.Background.Height = Screen.Height; 171 172 // MediaPlayer.Play("alustus3aani"); 173 174 // ClearControls(); 175 176 // Keyboard.Listen(Key.Enter, ButtonState.Pressed, TeeKentta3, "Aloita kenttä"); 177 178 // ControllerOne.Listen(Button.Start, ButtonState.Pressed, TeeKentta3, "Aloita kenttä"); 179 180 // MessageDisplay.TextColor = Color.White; 162 181 //} 163 182 … … 188 207 porkkana.Mass = 4.0; 189 208 190 porkkana.Weapon = new AssaultRifle(60, 30); 191 porkkana.Weapon.Ammo.Value = 10; 192 porkkana.Weapon.Y = -3; 193 porkkana.Weapon.X = 0; 194 porkkana.Weapon.ProjectileCollision = AmmusOsui; 195 209 //if (pelaajallaOnLaser == true) 210 //{ 211 // porkkana.Weapon = new AssaultRifle(60, 30); 212 // porkkana.Weapon.Ammo.Value = 10; 213 // porkkana.Weapon.Y = -3; 214 // porkkana.Weapon.X = 0; 215 // porkkana.Weapon.ProjectileCollision = AmmusOsui; 216 //} 217 218 //else 219 //{ 220 porkkana.Weapon = new AssaultRifle(60, 30); 221 porkkana.Weapon.Ammo.Value = 10; 222 porkkana.Weapon.Y = -3; 223 porkkana.Weapon.X = 0; 224 porkkana.Weapon.ProjectileCollision = AmmusOsui; 225 //} 196 226 AddCollisionHandler(porkkana, LipasKranaattiOsuma); 197 227 … … 212 242 213 243 tomaatti.Tag = "Vihollinen"; 244 245 tomaatti.IgnoresGravity = false; 214 246 215 247 FollowerBrain SeuraajanAivot = new FollowerBrain(); … … 268 300 { 269 301 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 270 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä");302 Keyboard.Listen(Key.Escape, ButtonState.Pressed, SeuraavaKentta, "Poistu valikkoon", 0); 271 303 272 304 Keyboard.Listen(Key.Left, ButtonState.Down, liikuta, "Pelaaja liikkuu vasemmalle", porkkana, -nopeus); … … 279 311 Keyboard.Listen(Key.Q, ButtonState.Pressed, HeitaKranaatti, "Heitä kranaatti"); 280 312 281 ControllerOne.Listen(Button.Start, ButtonState.Pressed, Exit, "Poistu pelistä");313 ControllerOne.Listen(Button.Start, ButtonState.Pressed, SeuraavaKentta, "Poistu valikkoon", 0); 282 314 ControllerOne.Listen(Button.Back, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 283 315 … … 311 343 PhysicsObject ammus = porkkana.Weapon.Shoot(); 312 344 313 314 345 if (ammus != null) 315 346 { 316 ammus.Size *= 5; 347 ammus.Size *= 1; 348 ammus.Restitution = 0.5; 317 349 ammus.MaximumLifetime = TimeSpan.FromSeconds(1.5); 318 350 } … … 363 395 364 396 } 365 397 } 398 399 void Ammus2Osui(PhysicsObject ammus2, PhysicsObject kohde) 400 { 401 366 402 if (kohde == porkkana) 367 403 { 404 ammus2.Destroy();; 405 406 //porkkana.IgnoresCollisionResponse = true; 407 368 408 porkkana.Stop(); 369 409 … … 375 415 376 416 LopetaPeli(); 377 378 } 379 380 if (kohde.Tag.ToString() == "Lipas") 381 { 382 383 } 384 } 385 417 418 } 419 } 420 386 421 void LopetaPeli() 387 422 { … … 593 628 PhysicsObject vihu = ampumaAjastin.Tag as PhysicsObject; 594 629 595 PhysicsObject ammus = tomaatti2.Weapon.Shoot();596 597 if (ammus != null)598 { 599 ammus .Size *= 5;600 ammus .MaximumLifetime = TimeSpan.FromSeconds(1.5);601 ammus .IgnoresGravity = true;630 PhysicsObject ammus2 = tomaatti2.Weapon.Shoot(); 631 632 if (ammus2 != null) 633 { 634 ammus2.Size *= 5; 635 ammus2.MaximumLifetime = TimeSpan.FromSeconds(1.5); 636 ammus2.IgnoresGravity = true; 602 637 } 603 638 } … … 649 684 maali.Image = maalinKuva; 650 685 maali.Mass = 4.0; 686 maali.Tag = "maali"; 651 687 AddCollisionHandler(maali, MaaliinOsuma); 652 688 return maali; … … 655 691 void MaaliinOsuma(PhysicsObject maali, PhysicsObject kohde) 656 692 { 657 if (kohde == porkkana) 658 { 659 pistelaskuri.Value += 200; 660 kentanNro += 1; 661 SeuraavaKentta(kentanNro); 662 } 693 if (kentanNro == 1 || kohde == porkkana || maali.Tag == maali) 694 { 695 pistelaskuri.Value += 500; 696 //kentanNro = 2; 697 SeuraavaKentta(kentanNro); 698 kentanNro = 2; 699 } 700 701 else if (kentanNro == 2 || kohde == porkkana || maali.Tag == maali) 702 { 703 pistelaskuri.Value += 500; 704 //kentanNro = 3; 705 maali.Destroy(); 706 SeuraavaKentta(kentanNro); 707 kentanNro = 3; 708 } 663 709 } 664 710 … … 676 722 lopetus.Font = Font.DefaultLargeBold; 677 723 Add(lopetus); 678 lopetus.Text = " 679 "Paina Escape/Start mennäksesi valikkoon .";724 lopetus.Text = " Peli päättyi.\n" + 725 "Paina Escape/Start mennäksesi valikkoon tai Enter/A aloittaaksesi alusta."; 680 726 681 727 ClearControls(); 682 728 683 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikkoon, "Poistu pelistä"); 684 685 ControllerOne.Listen(Button.Start, ButtonState.Down, Valikkoon, "Poistu valikkoon"); 729 Keyboard.Listen(Key.Enter, ButtonState.Pressed, SeuraavaKentta, "Aloita alusta", 1); 730 731 Keyboard.Listen(Key.Escape, ButtonState.Pressed, SeuraavaKentta, "Poistu valikkoon", 0); 732 733 ControllerOne.Listen(Button.Start, ButtonState.Down, SeuraavaKentta, "Poistu valikkoon", 0); 734 735 ControllerOne.Listen(Button.A, ButtonState.Pressed, SeuraavaKentta, "Aloita alusta", 1); 686 736 687 737 } … … 725 775 Level.Background.CreateGradient(Color.Blue, Color.Black); 726 776 727 Gravity = new Vector(0, - 1000);777 Gravity = new Vector(0, -500); 728 778 729 779 LuoPanosLaskuri(); … … 771 821 lisaaNappaimet(); 772 822 } 823 824 //void TeeKentta3() 825 //{ 826 // MediaPlayer.Stop(); 827 828 // TileMap kentta = TileMap.FromFile("kentta3.txt"); 829 // kentta['#'] = lisaaTaso; 830 // kentta['K'] = lisaaTaso2; 831 // kentta['G'] = lisaaTaso3; 832 // kentta['N'] = lisaaPelaaja; 833 // kentta['E'] = lisaaTomaatti; 834 // kentta['L'] = LuoLipas; 835 // kentta['A'] = LuoKranaatti; 836 // kentta['T'] = lisaaTomaatti2; 837 // kentta['M'] = LuoMaali; 838 // kentta['R'] = LuoRaha; 839 // kentta.Insert(RUUDUN_KOKO, RUUDUN_KOKO); 840 // Level.CreateBorders(); 841 // Level.Background.CreateGradient(Color.Black, Color.Blue); 842 843 // Gravity = new Vector(0, -1000); 844 845 // LuoPanosLaskuri(); 846 // LuoPisteLaskuri(); 847 // LuoKranaattiLaskuri(); 848 849 // Camera.Follow(porkkana); 850 851 // Camera.ZoomFactor = 1.0; 852 // Camera.StayInLevel = true; 853 854 // lisaaNappaimet(); 855 // 856 //} 773 857 }
Note: See TracChangeset
for help on using the changeset viewer.