Changeset 9125
- Timestamp:
- 2017-07-26 13:52:18 (6 years ago)
- Location:
- 2017/30/HugoE/HanniAndHoo/HanniAndHoo/HanniAndHoo
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/30/HugoE/HanniAndHoo/HanniAndHoo/HanniAndHoo/HanniAndHoo.cs
r9119 r9125 12 12 Image HoonKuva = LoadImage("Hoo"); 13 13 14 AssaultRifle HanninAse;15 14 15 PlasmaCannon HanninAse; 16 16 Cannon HoonAse; 17 17 18 19 18 20 19 PlatformCharacter Hanni; 21 P hysicsObjectHoo;20 PlatformCharacter Hoo; 22 21 23 22 public override void Begin() 24 23 { 25 24 LuoKentta(); 25 LuoPelaajat(); 26 26 LuoNappaimet(); 27 LuoPelaajat();28 29 AmmuAseella(HanninAse);30 AmmuAseella2(HoonAse);31 32 33 34 35 36 37 27 } 38 28 39 29 void LuoPelaajat() 40 30 { 41 42 31 Hanni = new PlatformCharacter(80.0, 80.0); 43 32 Hanni.X = Level.Left + 100.0; … … 46 35 Hanni.Color = Color.Blue; 47 36 Hanni.Image = HanninKuva; 48 Hanni.CanRotate = false; 37 Hanni.CanRotate = false; 49 38 Add(Hanni); 50 HanninAse = new AssaultRifle(60, 20);39 HanninAse = new PlasmaCannon(60, 20); 51 40 HanninAse.ProjectileCollision = AmmusOsui; 52 41 HanninAse.X += 50; 53 Hanni.Add(HanninAse); 54 55 42 Keyboard.Listen(Key.S, ButtonState.Pressed, AmmuAseella, "Ammu", HanninAse); 43 Hanni.Weapon = HanninAse; 56 44 Hoo = new PlatformCharacter (100.0, 100.0); 57 45 Hoo.X = Level.Right - 100.0; … … 61 49 Hoo.Image = HoonKuva; 62 50 Hoo.CanRotate = false; 63 Add(Hoo); 51 Add(Hoo); 64 52 HoonAse = new Cannon (90, 30); 65 53 HoonAse.ProjectileCollision = AmmusOsui; 66 54 HoonAse.X += 80; 67 Hoo.Add(HoonAse); 55 Hoo.Weapon = HoonAse; 56 Keyboard.Listen(Key.Down, ButtonState.Pressed, AmmuAseella2, "Ammu2", HoonAse); 68 57 HoonAse.Power.DefaultValue = 20000; 58 AddCollisionHandler(Hoo, Hanni, Tormaa); 59 } 60 void Tormaa(PhysicsObject tormaaja, PhysicsObject kohde) 61 { 62 kohde.Destroy(); 69 63 } 70 64 … … 72 66 { 73 67 Ammus.Destroy(); 74 75 68 } 76 69 void LuoNappaimet() 77 70 { 78 Keyboard.Listen(Key.W, ButtonState.Pressed, LiikutaHannia, null, new Vector(0, 700)); 79 Keyboard.Listen(Key.D, ButtonState.Down, LiikutaHannia, null, new Vector(500.0, 0.0)); 80 Keyboard.Listen(Key.D, ButtonState.Released, LiikutaHannia, null, new Vector(0, 0)); 81 Keyboard.Listen(Key.A, ButtonState.Down, LiikutaHannia, null, new Vector(-500, 0)); 82 Keyboard.Listen(Key.A, ButtonState.Released, LiikutaHannia, null, new Vector(0, 0)); 83 84 85 Keyboard.Listen(Key.Up, ButtonState.Pressed, LiikutaHoota, null, new Vector(0, 700)); 86 Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaHoota, null, new Vector(500.0, 0.0)); 87 Keyboard.Listen(Key.Right, ButtonState.Released, LiikutaHoota, null, new Vector(0, 0)); 88 Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaHoota, null, new Vector(-500, 0)); 89 Keyboard.Listen(Key.Left, ButtonState.Released, LiikutaHoota, null, new Vector(0, 0)); 90 91 92 71 Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppy, null, Hanni, 1000.0); 72 Keyboard.Listen(Key.D, ButtonState.Down, Kavely, null, Hanni, 500.0); 73 Keyboard.Listen(Key.A, ButtonState.Down, Kavely, null, Hanni, -500.0); 74 Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppy, null, Hoo, 1000.0); 75 Keyboard.Listen(Key.Right, ButtonState.Down, Kavely, null, Hoo, 500.0); 76 Keyboard.Listen(Key.Left, ButtonState.Down, Kavely, null, Hoo, -500.0); 93 77 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 94 78 … … 107 91 108 92 109 void LiikutaHannia(Vector vektori)93 void Kavely(PlatformCharacter tyyppi, double liikkumisenMaara) 110 94 { 111 Hanni.Velocity = (vektori);112 95 96 tyyppi.Walk(liikkumisenMaara); 113 97 114 98 } 115 void LiikutaHoota(Vector vektori)99 void Hyppy(PlatformCharacter tyyppi, double hypynMaara) 116 100 { 117 Hoo.Velocity = (vektori);101 tyyppi.Jump(hypynMaara); 118 102 } 119 103 120 void AmmuAseella( AssaultRifleHanninAse)104 void AmmuAseella(PlasmaCannon HanninAse) 121 105 { 122 PhysicsObject Ammus = HanninAse.Shoot(); 123 Keyboard.Listen(Key.S, ButtonState.Pressed, AmmuAseella, "Ammu", HanninAse); 124 HanninAse.FireRate = 0.25; 125 106 PhysicsObject Ammus = HanninAse.Shoot(); 107 HanninAse.FireRate = 2; 126 108 if (Ammus != null) 127 109 { 128 110 Ammus.Size *= 3; 129 111 Ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 130 131 112 } 132 113 … … 136 117 { 137 118 PhysicsObject Ammus = HoonAse.Shoot(); 138 Keyboard.Listen(Key.Down, ButtonState.Pressed, AmmuAseella2, "Ammu2", HoonAse); 139 HoonAse.FireRate = 0.25; 140 141 119 HoonAse.FireRate = 1; 142 120 if (Ammus != null) 143 121 { 144 122 Ammus.Size *= 4; 145 123 Ammus.MaximumLifetime = TimeSpan.FromSeconds(4.0); 146 147 124 } 148 125 126 } 127 128 class Hyvis : PhysicsObject 129 { 130 private IntMeter elamaLaskuri = new IntMeter(3, 0, 3); 131 public IntMeter ElamaLaskuri { get { return elamaLaskuri; } } 149 132 133 public Hyvis(double leveys, double korkeus) 134 : base(leveys, korkeus) 135 { 136 elamaLaskuri.LowerLimit += delegate { this.Destroy(); }; 137 } 150 138 151 139 } … … 154 142 155 143 } 144 145 146 147 148
Note: See TracChangeset
for help on using the changeset viewer.