- Timestamp:
- 2011-08-04 14:58:15 (12 years ago)
- Location:
- 2011/31/PeetuL/Palikoiden sota
- Files:
-
- 2 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2011/31/PeetuL/Palikoiden sota/Palikoiden sota/Palikoiden sota/Peli.cs
r2532 r2552 9 9 public class Peli : PhysicsGame 10 10 { 11 11 12 RandomMoverBrain SatunnaisAivot = new RandomMoverBrain(); 12 PlatformCharacter Behqulo; 13 Behqulo Behqulo; 14 int pahisten_lkm = 0; 15 13 16 14 17 public override void Begin() 15 18 { 19 MediaPlayer.Play("vs sephiroth"); 16 20 LuoAleksikuutio(); 17 21 LuoBehqulo(); … … 23 27 24 28 Camera.Follow(Behqulo); 25 Gravity = new Vector(0.0, -1100.0); 29 Gravity = new Vector(0.0, 0.0); 30 Level.BackgroundColor = Color.Black; 31 Level.CreateBorders(); 26 32 27 33 28 34 29 35 int i = 0; 30 while (i < 10)36 while (i < 30) 31 37 { 32 38 LuoPahis(); … … 37 43 38 44 int u = 0; 39 while (u < 10) 45 46 while (u < 15) 40 47 { 41 48 LuoLaserpahis(); 42 49 u = u + 1; 43 50 } 51 int o = 0; 52 53 /* 54 while (o < 15) 55 { 56 LuoLaserpahis2(); 57 o = o + 1; 58 } 59 */ 44 60 45 61 Level.CreateGround(55, 45, 7, 5); 46 62 } 63 64 void pahis_ampuu(PlatformCharacter pahis) 65 { 66 if (!pahis.IsDestroyed) 67 { 68 PhysicsObject Ammus = pahis.Weapon.Shoot(); 69 Timer.SingleShot(1.0, Ammus.Destroy); 70 } 71 } 72 47 73 void LuoPahis() 48 74 { 49 P latformCharacter pahis = new PlatformCharacter(10.0, 10.0);75 Pahis pahis = new Pahis(10.0, 10.0); 50 76 pahis.X = RandomGen.NextDouble(Level.Left, Level.Right); 51 77 pahis.Shape = Shape.Circle; … … 53 79 // if (pahis.IsDestroyed); 54 80 pahis.Weapon = new AssaultRifle(20, 5); 81 pahis.Weapon.ProjectileCollision =AmmusOsuu2; 55 82 Vector suunta = (Behqulo.Position - pahis.Position).Normalize(); 56 83 pahis.Angle = suunta.Angle; 84 pahisten_lkm++; 85 /* 57 86 Timer ajastin = new Timer(); 58 87 ajastin.Interval = 1.0; 59 88 ajastin.Timeout += delegate { PahisAmpuu(pahis); }; 60 ajastin.Start(); 89 ajastin.Start();*/ 61 90 pahis.Brain = new RandomMoverBrain(1000.0); 62 91 Add(pahis); 63 } 64 92 93 Timer vihu_ammunta_ajastin = new Timer(); 94 vihu_ammunta_ajastin.Interval = (1.0 + (RandomGen.NextDouble(-0.3, 0.3))); 95 vihu_ammunta_ajastin.Timeout += delegate { pahis_ampuu(pahis); }; 96 vihu_ammunta_ajastin.Start(); 97 98 } 99 100 void AmmusOsuu(PhysicsObject Ammus, PhysicsObject kohde) 101 { 102 if (kohde is Pahis) 103 { 104 Pahis k = (Pahis)kohde; 105 k.Hp--; 106 if (k.Hp < 1) kohde.Destroy(); 107 } 108 else if (kohde is Aleksikuutio) 109 { 110 Aleksikuutio k = (Aleksikuutio)kohde; 111 k.Hp--; 112 if (k.Hp < 1) kohde.Destroy(); 113 } 114 else if (kohde is Laserpahis) 115 { 116 Laserpahis k = (Laserpahis)kohde; 117 k.Hp--; 118 if (k.Hp < 1) kohde.Destroy(); 119 } 120 121 122 } 123 void AmmusOsuu2(PhysicsObject Ammus2, PhysicsObject kohde2) 124 { 125 126 if (kohde2 is Behqulo) 127 { 128 Behqulo k = (Behqulo)kohde2; 129 k.Hp--; 130 if (k.Hp < 1) kohde2.Destroy(); 131 } 132 } 133 65 134 66 135 … … 81 150 void LuoBehqulo() 82 151 { 83 Behqulo = new PlatformCharacter(10.0, 15.0);152 Behqulo = new Behqulo(10.0, 15.0); 84 153 Add(Behqulo); 85 154 Behqulo.Shape = Shape.Rectangle; 86 Behqulo.Color = Color.Yellow; 87 Behqulo.Weapon = new AssaultRifle(20, 5); 88 89 Keyboard.Listen(Key.D, ButtonState.Down, 90 LiikutaBehquloa, null, new Vector(1000, 0)); 91 Keyboard.Listen(Key.A, ButtonState.Down, 92 LiikutaBehquloa, null, new Vector(-1000, 0)); 93 Keyboard.Listen(Key.W, ButtonState.Down, 155 Behqulo.Color = Color.Red; 156 Behqulo.Weapon = new LaserGun(20, 5); 157 Behqulo.Weapon.ProjectileCollision = AmmusOsuu; 158 Behqulo.Weapon.InfiniteAmmo = true; 159 Keyboard.Listen(Key.Right, ButtonState.Down, 160 LiikutaBehquloa, null, new Vector(10000, 0)); 161 Keyboard.Listen(Key.Left, ButtonState.Down, 162 LiikutaBehquloa, null, new Vector(-10000, 0)); 163 Keyboard.Listen(Key.Up, ButtonState.Down, 94 164 LiikutaBehquloa, null, new Vector(0, 1000)); 95 Mouse.Listen(MouseButton.Left, ButtonState.Pressed, 165 Keyboard.Listen(Key.Down, ButtonState.Down, 166 LiikutaBehquloa, null, new Vector(0, -1000)); 167 Keyboard.Listen(Key.Space, ButtonState.Pressed, 96 168 Ammu, null); 97 Mouse.IsCursorVisible = true; 169 98 170 99 171 } 100 172 void LuoLaserpahis() 101 173 { 102 P latformCharacter Laserpahis = new PlatformCharacter(11.0, 10.3);174 Pahis Laserpahis = new Pahis(11.0, 10.3); 103 175 Laserpahis.X = RandomGen.NextDouble(Level.Left, Level.Right); 104 176 Laserpahis.Shape = Shape.Star; 105 177 Laserpahis.Color = Color.Green; 106 178 Laserpahis.Weapon = new LaserGun(5, 5); 179 Laserpahis.Weapon.ProjectileCollision = AmmusOsuu2; 180 Laserpahis.Brain = new RandomMoverBrain(1000.0); 107 181 Vector suunta = (Behqulo.Position - Laserpahis.Position).Normalize(); 108 182 109 183 110 184 Add(Laserpahis); 111 Timer ajastin = new Timer(); 112 ajastin.Interval = 1.0; 113 ajastin.Timeout += delegate { LaserPahisAmpuu(Laserpahis); }; 114 ajastin.Start(); 115 116 117 } 118 119 void PahisAmpuu(PlatformCharacter pahis) 120 { 121 pahis.Weapon.Shoot(); 122 } 123 124 void LaserPahisAmpuu(PlatformCharacter LaserPahis) 125 { 126 LaserPahis.Weapon.Shoot(); 185 pahisten_lkm++; 186 187 Timer vihu_ammunta_ajastin = new Timer(); 188 vihu_ammunta_ajastin.Interval = 1.0 + (RandomGen.NextDouble(-0.3, 0.3)); 189 vihu_ammunta_ajastin.Timeout += delegate { pahis_ampuu(Laserpahis); }; 190 vihu_ammunta_ajastin.Start(); 191 127 192 128 193 } … … 130 195 void LuoAleksikuutio() 131 196 { 132 PlatformCharacter Aleksikuutio = new PlatformCharacter(100.0, 100.0);197 Aleksikuutio Aleksikuutio = new Aleksikuutio(100.0, 100.0); 133 198 Aleksikuutio.X = RandomGen.NextDouble(Level.Left, Level.Right); 134 199 Aleksikuutio.Color = Color.Violet; 135 Aleksikuutio.Weapon = new Cannon(60.0, 60.0);136 200 Aleksikuutio.Weapon = new AssaultRifle(60.0, 60.0); 201 Aleksikuutio.Weapon.ProjectileCollision = AmmusOsuu2; 137 202 Add(Aleksikuutio); 138 203 Timer ajastin = new Timer(); … … 142 207 ajastin.Start(); 143 208 } 209 void LuoLaserpahis2() 210 { 211 Pahis Laserpahis2 = new Pahis(11.0, 10.3); 212 Laserpahis2.X = RandomGen.NextDouble(Level.Left, Level.Right); 213 Laserpahis2.Shape = Shape.Star; 214 Laserpahis2.Color = Color.Green; 215 Laserpahis2.Weapon = new LaserGun(5, 5); 216 Vector suunta = (Behqulo.Position - Laserpahis2.Position).Normalize(); 217 218 219 Add(Laserpahis2); 220 pahisten_lkm++; 221 222 Timer vihu_ammunta_ajastin = new Timer(); 223 vihu_ammunta_ajastin.Interval = 1.0; 224 vihu_ammunta_ajastin.Timeout += delegate { pahis_ampuu(Laserpahis2); }; 225 vihu_ammunta_ajastin.Start(); 226 227 228 } 144 229 145 230 void AleksikuutioAmpuu(PlatformCharacter Aleksikuutio) 146 231 { 147 PhysicsObject ammus = Aleksikuutio.Weapon.Shoot(); 148 if (ammus != null) 149 { 150 ammus.Size *= 5; 151 } 152 } 153 154 155 } 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 232 PhysicsObject ammus2 = Aleksikuutio.Weapon.Shoot(); 233 if (ammus2 != null) 234 { 235 ammus2.Size *= 5; 236 } 237 } 238 239 240 } 241 242 243 244 245 public class Pahis : PlatformCharacter 246 { 247 public int Hp = 7; 248 249 public Pahis(double width, double height) 250 : base(width, height) 251 { 252 253 } 254 255 } 256 257 public class Aleksikuutio : PlatformCharacter 258 { 259 public int Hp = 100000; 260 261 public Aleksikuutio(double width, double height) 262 : base(width, height) 263 { 264 265 } 266 267 } 268 269 public class Laserpahis : PlatformCharacter 270 { 271 public int Hp = 10; 272 273 public Laserpahis(double width, double height) 274 : base(width, height) 275 { 276 277 } 278 279 } 280 public class Behqulo : PlatformCharacter 281 { 282 public int Hp = 10; 283 284 public Behqulo(double width, double height) 285 : base(width, height) 286 { 287 288 } 289 290 } 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 -
2011/31/PeetuL/Palikoiden sota/Palikoiden sota/Palikoiden sotaContent/Palikoiden sotaContent.contentproj
r2496 r2552 44 44 <Reference Include="TextFileContentExtension" /> 45 45 </ItemGroup> 46 <ItemGroup> 47 <Compile Include="vs sephiroth.mp3"> 48 <Name>vs sephiroth</Name> 49 <Importer>Mp3Importer</Importer> 50 <Processor>SongProcessor</Processor> 51 </Compile> 52 </ItemGroup> 46 53 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 47 54 <!-- 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.