- Timestamp:
- 2012-07-27 12:51:21 (11 years ago)
- Location:
- 2012/30/OtsoR/Projekti
- Files:
-
- 1 added
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/30/OtsoR/Projekti/Projekti/Projekti/Projekti.cs
r3783 r3819 14 14 15 15 String[] weaponnames = { "projectile","laser","plasma" }; 16 17 PhysicsObject topedge; 18 PhysicsObject bottomedge; 19 PhysicsObject leftedge; 20 PhysicsObject rightedge; 16 21 17 22 PhysicsObject ship; … … 19 24 PhysicsObject ship2; 20 25 Weapon weapon2; 21 22 26 PhysicsObject hostile; 23 27 Weapon hostilew; … … 35 39 IntMeter shipcolor2; 36 40 IntMeter shipwpn2; 41 int shipcounter; 37 42 public override void Begin() 38 43 { … … 41 46 shipimages[i-1] = LoadImage("s"+i); 42 47 } 43 44 48 IsMouseVisible = true; 45 49 MultiSelectWindow numberofplayersmenu = new MultiSelectWindow("Select number of players", "1 Player", "2 Players", "Quit"); … … 54 58 ClearAll(); 55 59 singleplayer(); 56 57 60 break; 58 61 case 1: … … 144 147 choice(shipwpn.Value); 145 148 ship.Add(weapon); 149 ship.CollisionIgnoreGroup = 1; 146 150 } 147 151 void Createship2() … … 157 161 choice2(shipwpn2.Value); 158 162 ship2.Add(weapon2); 159 } 160 void Createhostile() 161 { 162 hostile = new PhysicsObject(16, 16, Shape.FromImage(Aluskuva.Image)); 163 hostile.Image = Aluskuva.Image; 164 hostile.Y = 100; 163 ship2.CollisionIgnoreGroup = 1; 164 } 165 void Spawnhostiles() 166 { 167 int shipcounter = 0; 168 169 while (shipcounter < 5) 170 { 171 int hostileship = RandomGen.NextInt(0, 100); 172 double hostiley = 0.0; 173 double hostilex = 0.0; 174 if (RandomGen.NextBool()) 175 { 176 hostiley = Level.Bottom + 2 * Level.Top * RandomGen.NextInt(0, 2); 177 hostilex = RandomGen.NextDouble(Level.Left, Level.Right); 178 } 179 else 180 { 181 hostiley = RandomGen.NextDouble(Level.Bottom, Level.Top); 182 hostilex = Level.Left + 2 * Level.Right * RandomGen.NextInt(0, 2); 183 184 } 185 Createhostile(hostileship, hostiley, hostilex); 186 shipcounter++; 187 } 188 } 189 void Createhostile(int randomship, double randomy, double randomx) 190 { 191 hostile = new PhysicsObject(16, 16, Shape.FromImage(shipimages[randomship])); 192 hostile.Image = shipimages[randomship]; 193 hostile.Y = randomy; 194 hostile.X = randomx; 165 195 hostile.Restitution = 1.0; 166 196 hostile.KineticFriction = 0.0; … … 168 198 hostile.LinearDamping = 0.95; 169 199 hostile.AngularDamping = 1; 200 hostile.Tag = "hostile"; 170 201 Add(hostile); 171 hostilew = new AssaultRifle(0, 0); 202 hostile.CollisionIgnoreGroup = 2; 203 hostile.Image.ReplaceColor(Color.White, Color.Ultramarine); 204 hostile.Image.ReplaceColor(Color.Black, Color.Emerald); 205 206 AssaultRifle hostilew = new AssaultRifle(0, 0); 172 207 hostilew.ProjectileCollision = weaponhit; 208 hostilew.FireRate = 0.5; 173 209 hostile.Add(hostilew); 174 210 175 RandomMoverBrain RandomAivot = new RandomMoverBrain(10); 176 RandomAivot.ChangeMovementSeconds = 3; 177 RandomAivot.TurnWhileMoving = true; 178 179 FollowerBrain SeuraavatAivot = new FollowerBrain(ship, ship2); 180 SeuraavatAivot.Speed = 10; 181 SeuraavatAivot.DistanceFar = 10000; 182 SeuraavatAivot.DistanceClose = 300; 183 SeuraavatAivot.StopWhenTargetClose = false; 184 SeuraavatAivot.FarBrain = RandomAivot; 185 SeuraavatAivot.TargetClose += delegate { firehostile(hostilew); }; 186 SeuraavatAivot.TurnWhileMoving = true; 187 hostile.Brain = SeuraavatAivot; 188 } 189 void firehostile(Weapon weapon) 190 { 191 fire(weapon); 211 FollowerBrain brain = new FollowerBrain(ship, ship2); 212 brain.Speed = 20; 213 brain.DistanceFar = 10000; 214 brain.DistanceClose = 200; 215 brain.StopWhenTargetClose = false; 216 brain.TargetClose += delegate { fire(hostilew); }; 217 brain.TurnWhileMoving = true; 218 hostile.Brain = brain; 219 } 220 void createedges() 221 { 222 PhysicsObject leftedge = Level.CreateLeftBorder(); 223 leftedge.Restitution = 1.0; 224 leftedge.KineticFriction = 0.0; 225 leftedge.IsVisible = false; 226 leftedge.CollisionIgnoreGroup = 2; 227 PhysicsObject rightedge = Level.CreateRightBorder(); 228 rightedge.Restitution = 1.0; 229 rightedge.KineticFriction = 0.0; 230 rightedge.IsVisible = false; 231 rightedge.CollisionIgnoreGroup = 2; 232 PhysicsObject topedge = Level.CreateTopBorder(); 233 topedge.Restitution = 1.0; 234 topedge.KineticFriction = 0.0; 235 topedge.IsVisible = false; 236 topedge.CollisionIgnoreGroup = 2; 237 PhysicsObject bottomedge = Level.CreateBottomBorder(); 238 bottomedge.Restitution = 1.0; 239 bottomedge.IsVisible = false; 240 bottomedge.KineticFriction = 0.0; 241 topedge.CollisionIgnoreGroup = 2; 192 242 } 193 243 void coop() … … 291 341 weapon = new AssaultRifle(0, 0); 292 342 weapon.ProjectileCollision = weaponhit; 343 weapon.FireRate = 4; 293 344 break; 294 345 case 2: 295 346 weapon = new LaserGun(0, 0); 296 347 weapon.ProjectileCollision = weaponhit; 297 weapon.Power.Value = 5000; 298 weapon.FireRate = 1.0; 348 weapon.FireRate = 0.5; 299 349 break; 300 350 case 3: 301 351 weapon = new PlasmaCannon(0, 0); 302 352 weapon.ProjectileCollision = weaponhit; 353 weapon.FireRate = 2; 303 354 break; 304 355 } … … 311 362 weapon2 = new AssaultRifle(0, 0); 312 363 weapon2.ProjectileCollision = weaponhit; 364 weapon2.FireRate = 4; 313 365 break; 314 366 case 2: 315 367 weapon2 = new LaserGun(0, 0); 316 368 weapon2.ProjectileCollision = weaponhit; 317 weapon2.Power.Value = 5000; 318 weapon2.FireRate = 1.0; 369 weapon2.FireRate = 0.5; 319 370 break; 320 371 case 3: 321 372 weapon2 = new PlasmaCannon(0, 0); 322 373 weapon2.ProjectileCollision = weaponhit; 374 weapon2.FireRate = 2; 323 375 break; 324 376 } … … 327 379 { 328 380 PhysicsObject ammus = ase.Shoot(); 329 381 382 330 383 if (ammus != null) 331 384 { 385 //Add(ammus, 2); 332 386 //ammus.Size *= 3; 333 387 //ammus.Image = … … 335 389 } 336 390 } 391 337 392 void weaponhit(PhysicsObject ammus, PhysicsObject kohde) 338 393 { 394 if (kohde.Tag == "hostile") kohde.Destroy(); 339 395 ammus.Destroy(); 340 396 } 341 void AsetaOhjaimet() 397 398 void Controlsship1() 342 399 { 343 400 Keyboard.Listen(Key.W, ButtonState.Down, thrust, "", 1.0, ship); … … 345 402 Keyboard.Listen(Key.A, ButtonState.Down, tilt, "", 1.0, ship); 346 403 Keyboard.Listen(Key.D, ButtonState.Down, tilt, "", -1.0, ship); 347 Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon); 348 404 Keyboard.Listen(Key.F, ButtonState.Down, fire, "", weapon); 349 405 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 350 406 } 407 void Controlsship2() 408 { 351 409 Keyboard.Listen(Key.NumPad8, ButtonState.Down, thrust, "", 1.0, ship2); 352 410 Keyboard.Listen(Key.NumPad5, ButtonState.Down, thrust, "", -1.0, ship2); 353 411 Keyboard.Listen(Key.NumPad4, ButtonState.Down, tilt, "", 1.0, ship2); 354 412 Keyboard.Listen(Key.NumPad6, ButtonState.Down, tilt, "", -1.0, ship2); 355 Keyboard.Listen(Key. Space, ButtonState.Down, fire, "", weapon2);413 Keyboard.Listen(Key.Add, ButtonState.Down, fire, "", weapon2); 356 414 } 357 415 void thrust(double direction, PhysicsObject ship) … … 371 429 Camera.ZoomToLevel(); 372 430 Createship(); 373 AsetaOhjaimet();431 Controlsship1(); 374 432 } 375 433 void coopbase() … … 381 439 Createship(); 382 440 Createship2(); 383 Createhostile(); 384 AsetaOhjaimet(); 441 Spawnhostiles(); 442 Controlsship1(); 443 Controlsship2(); 444 445 Timer a = new Timer(); 446 a.Interval = 5; 447 a.Timeout += Spawnhostiles; 448 a.Start(); 385 449 } 386 450 } -
2012/30/OtsoR/Projekti/Projekti/Projekti/Projekti.csproj.Debug.cachefile
r3779 r3819 99 99 Content\s98.xnb 100 100 Content\s99.xnb 101 Content\s101.xnb 102 Content\bullet.xnb -
2012/30/OtsoR/Projekti/Projekti/Projekti/obj/x86/Debug/Projekti.csproj.FileListAbsolute.txt
r3783 r3819 107 107 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\s98.xnb 108 108 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\s99.xnb 109 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\bullet.xnb -
2012/30/OtsoR/Projekti/Projekti/Projekti/obj/x86/Debug/cachefile-{97999162-0C3B-480A-AB91-BD553A4EB51F}-targetpath.txt
r3779 r3819 99 99 Content\s98.xnb 100 100 Content\s99.xnb 101 Content\bullet.xnb -
2012/30/OtsoR/Projekti/Projekti/ProjektiContent/ProjektiContent.contentproj
r3764 r3819 546 546 </Compile> 547 547 </ItemGroup> 548 <ItemGroup> 549 <Compile Include="bullet.png"> 550 <Name>bullet</Name> 551 <Importer>TextureImporter</Importer> 552 <Processor>TextureProcessor</Processor> 553 </Compile> 554 </ItemGroup> 548 555 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 549 556 <!-- 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.