- Timestamp:
- 2013-06-27 15:07:28 (8 years ago)
- Location:
- 2012/30/OtsoR/Projekti
- Files:
-
- 153 added
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/30/OtsoR/Projekti/Projekti/Projekti/Projekti.cs
r4201 r4281 7 7 using Jypeli.Widgets; 8 8 9 public class Player : PhysicsObject 10 { 11 private IntMeter health = new IntMeter(100, 0, 100); 12 public IntMeter Health { get { return health; } } 13 public Color Color1; 14 public Color Color2; 15 16 public Image cannonImage; 17 18 public Player(double width, double height, Shape shape) 19 : base(width, height, shape) 20 { 21 ProgressBar playerhealth = new ProgressBar(8, 3); 22 playerhealth.BindTo(health); 23 playerhealth.BarColor = Color.SpringGreen; 24 playerhealth.BorderColor = Color.Red; 25 playerhealth.X = -8; 26 playerhealth.Angle = Angle.RightAngle; 27 Add(playerhealth); 28 health.LowerLimit += delegate 29 { 30 this.Destroy(); 31 }; 32 } 33 } 34 class Enemy : PhysicsObject 35 { 36 private IntMeter health = new IntMeter(5, 0, 5); 37 public IntMeter Health { get { return health; } } 38 39 public Enemy(double leveys, double korkeus, Shape muoto) 40 : base(leveys, korkeus, muoto) 41 { 42 ProgressBar enemyhealth = new ProgressBar(6, 2.5); 43 enemyhealth.BindTo(health); 44 enemyhealth.X = -8; 45 enemyhealth.Angle = Angle.RightAngle; 46 Add(enemyhealth); 47 health.LowerLimit += delegate 48 { 49 this.Destroy(); 50 }; 51 } 52 } 53 class BigEnemy : PhysicsObject 54 { 55 private IntMeter health = new IntMeter(100, 0, 100); 56 public IntMeter Health { get { return health; } } 57 58 public BigEnemy(double leveys, double korkeus, Shape muoto) 59 : base(leveys, korkeus, muoto) 60 { 61 ProgressBar enemyhealth = new ProgressBar(6, 2.5); 62 enemyhealth.BindTo(health); 63 enemyhealth.X = -20; 64 enemyhealth.Angle = Angle.RightAngle; 65 Add(enemyhealth); 66 health.LowerLimit += delegate 67 { 68 this.Destroy(); 69 }; 70 } 71 } 9 72 public class Projekti : PhysicsGame 10 73 { 11 74 Image[] shipimages = new Image[100]; 12 Color[] shipcolors = { Color.DarkGray, Color.Silver, Color.DarkOrange, Color.Ultramarine }; 13 Color[] shipcolors2 = { Color.Ruby, Color.Azure, Color.Emerald, Color.Emerald }; 75 Color[] shipcolors = { Color.DarkGray, Color.Silver, Color.DarkOrange, Color.Blue }; 76 Color[] shipcolors2 = { Color.Ruby, Color.Azure, Color.Emerald, Color.Orange }; 77 Image bigenemy = LoadImage("bigenemy"); 14 78 Image shell = LoadImage("bullet"); 15 16 String[] weaponnames = { "projectile","laser","plasma" }; 79 Image pointer = LoadImage("pointer"); 80 Image rdamage = LoadImage("rdamage"); 81 Image rrepair = LoadImage("rrepair"); 82 Image homing = LoadImage("missile"); 83 84 String[] weaponnames = { "projectile", "laser", "plasma", "missile" }; 17 85 18 86 PhysicsObject topedge; … … 20 88 PhysicsObject leftedge; 21 89 PhysicsObject rightedge; 22 23 P hysicsObject ship;90 91 Player ship1; 24 92 Weapon weapon; 25 P hysicsObjectship2;93 Player ship2; 26 94 Weapon weapon2; 27 PhysicsObject hostile;95 //PhysicsObject hostile; 28 96 Weapon hostilew; 97 GameObject line; 98 PhysicsObject ammus; 29 99 30 100 Label number; 31 101 Label number2; 102 Label colour; 32 103 Label weaponlabel; 33 104 Label weaponlabel2; 34 Widget Aluskuva;35 Widget Aluskuva2;105 Widget aluskuva; 106 Widget aluskuva2; 36 107 IntMeter shipimg; 37 IntMeter shipcolor ;108 IntMeter shipcolor1; 38 109 IntMeter shipwpn; 39 110 IntMeter shipimg2; 40 111 IntMeter shipcolor2; 41 IntMeter ship wpn2;112 IntMeter shipWeapon2; 42 113 int shipcounter; 114 int bigshipcounter; 115 int bosscounter; 116 int runecounter; 43 117 public override void Begin() 44 118 { 45 119 for (int i = 1; i <= 100; i++) 46 120 { 47 shipimages[i -1] = LoadImage("s"+i);121 shipimages[i - 1] = LoadImage("s" + i); 48 122 } 49 123 IsMouseVisible = true; … … 69 143 } 70 144 } 145 71 146 void singleplayer() 72 147 { 73 Aluskuva = new Widget(50, 50);74 Aluskuva.X = 0;75 Aluskuva.Y = 250;76 Aluskuva.Image = shipimages[0];77 Add( Aluskuva);148 aluskuva = new Widget(50, 50); 149 aluskuva.X = 0; 150 aluskuva.Y = 250; 151 aluskuva.Image = shipimages[0]; 152 Add(aluskuva); 78 153 79 154 shipimg = new IntMeter(1, 1, 100); 80 shipimg.Changed += Changeship ;81 shipwpn = new IntMeter(1, 1, 3);155 shipimg.Changed += Changeship1; 156 shipwpn = new IntMeter(1, 1, 4); 82 157 shipwpn.Changed += delegate { weaponlabel.Text = weaponnames[shipwpn.Value - 1]; }; 83 shipcolor = new IntMeter(1, 1, 4);84 shipcolor .Changed += Changeship;158 shipcolor1 = new IntMeter(0, 0, 3); 159 shipcolor1.Changed += Changeship1; 85 160 86 161 number = new Label(); … … 89 164 number.Y = 300; 90 165 Add(number); 166 167 colour = new Label("style"); 168 colour.X = -125; 169 colour.Y = 125; 170 Add(colour); 91 171 92 172 weaponlabel = new Label(weaponnames[0]); … … 102 182 shipcolour.X = -125; 103 183 shipcolour.Y = 150; 104 shipcolour.BindTo(shipcolor );184 shipcolour.BindTo(shipcolor1); 105 185 Slider shipweapon = new Slider(125, 15); 106 186 shipweapon.X = 125; … … 124 204 Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, singleplayerbase, null); 125 205 } 126 void Changeship(int vanha, int uusi) 127 { 128 Aluskuva.Image = shipimages[shipimg.Value-1].Clone(); 129 Aluskuva.Image.ReplaceColor(Color.White, shipcolors[shipcolor.Value - 1]); 130 Aluskuva.Image.ReplaceColor(Color.Black, shipcolors2[shipcolor.Value - 1]); 206 207 void Changeship1(int vanha, int uusi) 208 { 209 aluskuva.Image = shipimages[shipimg.Value - 1].Clone(); 210 aluskuva.Image.ReplaceColor(Color.White, shipcolors[shipcolor1.Value]); 211 aluskuva.Image.ReplaceColor(Color.Black, shipcolors2[shipcolor1.Value]); 131 212 } 132 213 void Changeship2(int vanha, int uusi) 133 214 { 134 Aluskuva2.Image = shipimages[shipimg2.Value - 1].Clone(); 135 Aluskuva2.Image.ReplaceColor(Color.White, shipcolors[shipcolor2.Value - 1]); 136 Aluskuva2.Image.ReplaceColor(Color.Black, shipcolors2[shipcolor2.Value - 1]); 137 } 138 void Createship() 139 { 140 ship = new PhysicsObject(16, 16, Shape.FromImage(Aluskuva.Image)); 141 ship.Image = Aluskuva.Image; 142 ship.Restitution = 1.0; 143 ship.KineticFriction = 0.0; 144 ship.MomentOfInertia = Double.PositiveInfinity; 145 ship.LinearDamping = 0.95; 146 ship.AngularDamping = 0.95; 147 Add(ship); 215 aluskuva2.Image = shipimages[shipimg2.Value - 1].Clone(); 216 aluskuva2.Image.ReplaceColor(Color.White, shipcolors[shipcolor2.Value]); 217 aluskuva2.Image.ReplaceColor(Color.Black, shipcolors2[shipcolor2.Value]); 218 } 219 220 void Createship(double x, double y) 221 { 222 ship1 = new Player(14, 14, Shape.FromImage(aluskuva.Image)); 223 ship1.Image = aluskuva.Image; 224 225 ship1.Restitution = 1.0; 226 ship1.Color1 = shipcolors[shipcolor1.Value]; 227 ship1.Color2 = shipcolors2[shipcolor1.Value]; 228 ship1.cannonImage = LoadImage("missile"); 229 ship1.cannonImage.ReplaceColor(Color.White, ship1.Color1); 230 ship1.cannonImage.ReplaceColor(Color.Black, ship1.Color2); 231 232 ship1.X = x; 233 ship1.Y = y; 234 ship1.KineticFriction = 0.0; 235 ship1.MomentOfInertia = Double.PositiveInfinity; 236 ship1.LinearDamping = 0.95; 237 ship1.AngularDamping = 0.95; 238 Add(ship1); 148 239 choice(shipwpn.Value); 149 ship.Add(weapon); 150 ship.CollisionIgnoreGroup = 1; 151 ship.Tag = "player"; 152 } 153 void Createship2() 154 { 155 ship2 = new PhysicsObject(16, 16, Shape.FromImage(Aluskuva2.Image)); 156 ship2.Image = Aluskuva2.Image; 240 ship1.Add(weapon); 241 ship1.CollisionIgnoreGroup = 1; 242 ship1.Tag = "player"; 243 ship1.Destroyed += playerdeath; 244 if (weapon is LaserGun) 245 { 246 line = new GameObject(5000, 1.25); 247 line.Image = pointer; 248 line.X = 2500; 249 ship1.Add(line); 250 } 251 } 252 void Createship2(double x, double y) 253 { 254 ship2 = new Player(14, 14, Shape.FromImage(aluskuva2.Image)); 255 ship2.Image = aluskuva2.Image; 256 ship2.X = x; 257 ship2.Y = y; 258 ship2.Color1 = shipcolors[shipcolor2.Value]; 259 ship2.Color2 = shipcolors2[shipcolor2.Value]; 260 ship2.cannonImage = LoadImage("missile"); 261 ship2.cannonImage.ReplaceColor(Color.White, ship2.Color1); 262 ship2.cannonImage.ReplaceColor(Color.Black, ship2.Color2); 263 157 264 ship2.Restitution = 1.0; 158 265 ship2.KineticFriction = 0.0; … … 161 268 ship2.AngularDamping = 0.95; 162 269 Add(ship2); 163 choice2(ship wpn2.Value);270 choice2(shipWeapon2.Value); 164 271 ship2.Add(weapon2); 165 272 ship2.CollisionIgnoreGroup = 1; 166 273 ship2.Tag = "player"; 274 ship2.Destroyed += playerdeath; 275 if (weapon is LaserGun) 276 { 277 line = new GameObject(5000, 1.25); 278 line.Image = pointer; 279 line.X = 2500; 280 ship1.Add(line); 281 } 167 282 } 168 283 void Spawnhostiles() 169 284 { 170 int shipcounter = 0; 171 172 while (shipcounter < 5) 285 while (shipcounter < 39) 173 286 { 174 287 int hostileship = RandomGen.NextInt(0, 100); … … 184 297 hostiley = RandomGen.NextDouble(Level.Bottom, Level.Top); 185 298 hostilex = Level.Left + 2 * Level.Right * RandomGen.NextInt(0, 2); 186 187 299 } 188 300 Createhostile(hostileship, hostiley, hostilex); 189 301 shipcounter++; 190 302 } 303 while (bigshipcounter < 4) 304 { 305 double bighostiley = 0.0; 306 double bighostilex = 0.0; 307 if (RandomGen.NextBool()) 308 { 309 bighostiley = Level.Bottom + 2 * Level.Top * RandomGen.NextInt(0, 2); 310 bighostilex = RandomGen.NextDouble(Level.Left, Level.Right); 311 } 312 else 313 { 314 bighostiley = RandomGen.NextDouble(Level.Bottom, Level.Top); 315 bighostilex = Level.Left + 2 * Level.Right * RandomGen.NextInt(0, 2); 316 } 317 Createbighostile(bighostiley, bighostilex); 318 bigshipcounter++; 319 } 191 320 } 192 321 void Createhostile(int randomship, double randomy, double randomx) 193 322 { 194 hostile = new PhysicsObject(16, 16, Shape.FromImage(shipimages[randomship]));323 Enemy hostile = new Enemy(14, 14, Shape.FromImage(shipimages[randomship])); 195 324 hostile.Image = shipimages[randomship]; 196 325 hostile.Y = randomy; … … 202 331 hostile.AngularDamping = 1; 203 332 hostile.Tag = "hostile"; 204 Add(hostile); 333 hostile.Health.MaxValue = 5; 334 hostile.Health.Value = 5; 205 335 hostile.CollisionIgnoreGroup = 2; 206 336 hostile.Image.ReplaceColor(Color.White, Color.Ultramarine); 207 hostile.Image.ReplaceColor(Color.Black, Color.Emerald); 208 209 PlasmaCannon hostilew = new PlasmaCannon(0, 0); 210 hostilew.ProjectileCollision = weaponhit; 337 hostile.Image.ReplaceColor(Color.Black, Color.Green); 338 Add(hostile); 339 340 hostile.Destroyed += enemydeath; 341 342 AssaultRifle hostilew = new AssaultRifle(0, 0); 343 hostilew.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 10, 0); }; 211 344 hostilew.FireRate = 0.5; 212 hostilew.Power.DefaultValue = 700;213 hostilew.Power.Value = 700;345 hostilew.Power.DefaultValue = 15; 346 hostilew.Power.Value = 15; 214 347 hostile.Add(hostilew); 215 348 … … 217 350 brain.Speed = 20; 218 351 brain.DistanceFar = 10000; 219 brain.DistanceClose = 200;352 brain.DistanceClose = 125; 220 353 brain.StopWhenTargetClose = false; 221 brain.TargetClose += delegate { fire(hostilew ); };354 brain.TargetClose += delegate { fire(hostilew, null); }; 222 355 brain.TurnWhileMoving = true; 223 356 hostile.Brain = brain; 357 } 358 void Createbighostile(double y, double x) 359 { 360 Enemy Big1 = new Enemy(50, 28, Shape.FromImage(bigenemy)); 361 Big1.Image = bigenemy; 362 Big1.X = x; 363 Big1.Y = y; 364 Big1.Restitution = 1.0; 365 Big1.KineticFriction = 0.0; 366 Big1.MomentOfInertia = Double.PositiveInfinity; 367 Big1.LinearDamping = 0.95; 368 Big1.AngularDamping = 1; 369 Big1.Tag = "hostile"; 370 Big1.Health.MaxValue = 40; 371 Big1.Health.Value = 40; 372 Big1.CollisionIgnoreGroup = 2; 373 Big1.Image.ReplaceColor(Color.White, Color.Ultramarine); 374 Big1.Image.ReplaceColor(Color.Black, Color.Green); 375 Add(Big1); 376 Big1.Destroyed += bigenemydeath; 377 378 Cannon Big1w = new Cannon(0, 0); 379 Big1w.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 3, 0); }; 380 Big1w.FireRate = 0.3; 381 Big1w.CanHitOwner = false; 382 Big1w.Power.DefaultValue = 1500; 383 Big1w.Power.Value = 1500; 384 Big1.Add(Big1w); 385 386 FollowerBrain bigbrain = new FollowerBrain("player"); 387 bigbrain.Speed = 15; 388 bigbrain.DistanceFar = 10000; 389 bigbrain.DistanceClose = 325; 390 bigbrain.TurnSpeed = UnlimitedAngle.FromDegrees(25); 391 bigbrain.StopWhenTargetClose = false; 392 bigbrain.TargetClose += delegate { firehoming(Big1w); }; 393 bigbrain.TurnWhileMoving = true; 394 Big1.Brain = bigbrain; 395 } 396 void playerdeath() 397 { 398 MessageDisplay.Add("Ship lost"); 399 //MediaPlayer.Play("playerdeath"); 400 } 401 void enemydeath() 402 { 403 shipcounter--; 404 } 405 void bigenemydeath() 406 { 407 bigshipcounter--; 408 } 409 void boss1death() 410 { 411 } 412 void boss2death() 413 { 224 414 } 225 415 void createedges() … … 248 438 void coop() 249 439 { 250 Aluskuva = new Widget(50, 50);251 Aluskuva.X = -300;252 Aluskuva.Y = 250;253 Aluskuva.Image = shipimages[0];254 Add( Aluskuva);255 256 Aluskuva2 = new Widget(50, 50);257 Aluskuva2.X = 300;258 Aluskuva2.Y = 250;259 Aluskuva2.Image = shipimages[0];260 Add( Aluskuva2);440 aluskuva = new Widget(50, 50); 441 aluskuva.X = -300; 442 aluskuva.Y = 250; 443 aluskuva.Image = shipimages[0]; 444 Add(aluskuva); 445 446 aluskuva2 = new Widget(50, 50); 447 aluskuva2.X = 300; 448 aluskuva2.Y = 250; 449 aluskuva2.Image = shipimages[0]; 450 Add(aluskuva2); 261 451 262 452 shipimg = new IntMeter(1, 1, 100); 263 shipimg.Changed += Changeship ;264 shipwpn = new IntMeter(1, 1, 3);453 shipimg.Changed += Changeship1; 454 shipwpn = new IntMeter(1, 1, 4); 265 455 shipwpn.Changed += delegate { weaponlabel.Text = weaponnames[shipwpn.Value - 1]; }; 266 shipcolor = new IntMeter(1, 1, 4); 267 shipcolor.Changed += Changeship; 456 457 Slider shipColorP1 = new Slider(125, 15); 458 shipColorP1.X = -425; 459 shipColorP1.Y = 150; 460 shipcolor1 = new IntMeter(0, 0, 3); 461 shipcolor1.Changed += Changeship1; 462 shipColorP1.BindTo(shipcolor1); 463 464 Slider shipcolour2 = new Slider(125, 15); 465 shipcolour2.X = 225; 466 shipcolour2.Y = 150; 467 shipcolor2 = new IntMeter(0, 0, 3); 468 shipcolor2.Changed += Changeship2; 469 shipcolour2.BindTo(shipcolor2); 470 268 471 shipimg2 = new IntMeter(1, 1, 100); 269 472 shipimg2.Changed += Changeship2; 270 ship wpn2 = new IntMeter(1, 1, 3);271 ship wpn2.Changed += delegate { weaponlabel2.Text = weaponnames[shipwpn2.Value - 1]; };272 shipcolor2 = new IntMeter(1, 1, 4);273 shipcolor2.Changed += Changeship2;274 473 shipWeapon2 = new IntMeter(1, 1, 4); 474 shipWeapon2.Changed += delegate 475 { 476 weaponlabel2.Text = weaponnames[shipWeapon2.Value - 1]; 477 }; 275 478 number = new Label(); 276 479 number.BindTo(shipimg); … … 298 501 shiptype.Y = 200; 299 502 shiptype.BindTo(shipimg); 300 Slider shipcolour = new Slider(125, 15); 301 shipcolour.X = -425; 302 shipcolour.Y = 150; 303 shipcolour.BindTo(shipcolor); 503 304 504 Slider shipweapon = new Slider(125, 15); 305 505 shipweapon.X = -225; … … 311 511 shiptype2.Y = 200; 312 512 shiptype2.BindTo(shipimg2); 313 Slider shipcolour2 = new Slider(125, 15); 314 shipcolour2.X = 225; 315 shipcolour2.Y = 150; 316 shipcolour2.BindTo(shipcolor2); 513 317 514 Slider shipweapon2 = new Slider(125, 15); 318 515 shipweapon2.X = 425; 319 516 shipweapon2.Y = 150; 320 shipweapon2.BindTo(shipwpn2); 321 517 shipweapon2.BindTo(shipWeapon2); 322 518 Add(shiptype); 323 Add(ship colour);519 Add(shipColorP1); 324 520 Add(shipweapon); 325 521 Add(shiptype2); 326 522 Add(shipcolour2); 327 523 Add(shipweapon2); 328 329 524 List<Label> valikonKohdat2; 330 525 valikonKohdat2 = new List<Label>(); // Alustetaan lista, johon valikon kohdat tulevat … … 345 540 case 1: 346 541 weapon = new AssaultRifle(0, 0); 347 weapon.ProjectileCollision = weaponhit;542 weapon.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 1); }; 348 543 weapon.FireRate = 4.5; 544 weapon.Power.Value = 25; 545 weapon.Power.DefaultValue = 25; 349 546 break; 350 547 case 2: 351 548 weapon = new LaserGun(0, 0); 352 weapon.ProjectileCollision = weaponhit;353 weapon.FireRate = 1;354 weapon.Power.DefaultValue = 3000;355 weapon.Power.Value = 3000;549 weapon.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 5); }; 550 weapon.FireRate = 0.8; 551 weapon.Power.DefaultValue = 100; 552 weapon.Power.Value = 100; 356 553 break; 357 554 case 3: 358 555 weapon = new PlasmaCannon(0, 0); 359 weapon.ProjectileCollision = weaponhit; 360 weapon.FireRate = 1; 361 weapon.Power.Value = 750; 362 weapon.Power.DefaultValue = 750; 556 weapon.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 3); }; 557 weapon.FireRate = 1.5; 558 weapon.Power.Value = 400; 559 weapon.Power.DefaultValue = 400; 560 break; 561 case 4: 562 weapon = new Cannon(0, 0); 563 weapon.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 5); }; 564 weapon.FireRate = 0.8; 565 weapon.Power.DefaultValue = 1500; 566 weapon.Power.Value = 1500; 363 567 break; 364 568 } … … 370 574 case 1: 371 575 weapon2 = new AssaultRifle(0, 0); 372 weapon2.ProjectileCollision = weaponhit; 373 weapon2.FireRate = 4; 576 weapon2.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 1); }; 577 weapon2.FireRate = 4.5; 578 weapon2.Power.Value = 25; 579 weapon2.Power.DefaultValue = 25; 374 580 break; 375 581 case 2: 376 582 weapon2 = new LaserGun(0, 0); 377 weapon2.ProjectileCollision = weaponhit; 378 weapon2.FireRate = 0.5; 583 weapon2.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 5); }; 584 weapon2.FireRate = 1; 585 weapon2.Power.DefaultValue = 1000; 586 weapon2.Power.Value = 1000; 379 587 break; 380 588 case 3: 381 589 weapon2 = new PlasmaCannon(0, 0); 382 weapon2.ProjectileCollision = weaponhit; 383 weapon2.FireRate = 2; 384 break; 385 } 386 } 387 void fire(Weapon ase) 590 weapon2.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 3); }; 591 weapon2.FireRate = 1.5; 592 weapon2.Power.Value = 400; 593 weapon2.Power.DefaultValue = 400; 594 break; 595 case 4: 596 weapon2 = new Cannon(0, 0); 597 weapon2.ProjectileCollision = delegate(PhysicsObject ammus, PhysicsObject kohde) { weaponhit(ammus, kohde, 0, 5); }; 598 weapon2.FireRate = 0.8; 599 weapon2.Power.DefaultValue = 1500; 600 weapon2.Power.Value = 1500; 601 break; 602 } 603 } 604 void fire(Weapon ase, Player ship) 388 605 { 389 606 PhysicsObject ammus = ase.Shoot(); 390 391 607 if (ammus != null) 392 608 { … … 395 611 //ammus.Image = ...; 396 612 //ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 397 ammus.MaximumLifetime = TimeSpan.From Days(1.0);613 ammus.MaximumLifetime = TimeSpan.FromSeconds(10.0); 398 614 if (ase is AssaultRifle) 399 615 { 400 616 ammus.IgnoresCollisionResponse = true; 401 617 ammus.Image = shell; 402 ammus.Size *=0.4; 618 ammus.Size *= 0.4; 619 ammus.CollisionIgnoreGroup = 4; 620 AddCollisionHandler(ammus, CollisionHandler.DestroyObject); 403 621 } 404 622 if (ase is LaserGun) 405 623 { 624 ammus.Size *= 2; 406 625 ammus.IgnoresCollisionResponse = true; 626 ammus.Tag = "laser"; 407 627 } 408 628 if (ase is PlasmaCannon) 409 629 { 410 ammus.Size *= 1.5; 630 ammus.Size *= 0.9; 631 AddCollisionHandler(ammus, CollisionHandler.DestroyObject); 632 ammus.IgnoresCollisionResponse = true; 633 ammus.CollisionIgnoreGroup = 3; 411 634 } 412 } 413 414 } 415 416 void weaponhit(PhysicsObject ammus, PhysicsObject kohde) 417 { 418 if (kohde.Tag == "hostile") kohde.Destroy(); 419 ammus.Destroy(); 420 } 421 635 if (ase is Cannon) 636 { 637 ammus.Size *= 0.8; 638 // ammus.Image = homing; 639 ammus.Image = ship.cannonImage; 640 AddCollisionHandler(ammus, missilehit); 641 ammus.AngularDamping = 1.0; 642 ammus.IgnoresCollisionResponse = true; 643 644 FollowerBrain ammusbrain = new FollowerBrain("hostile", "laser"); 645 //ammusbrain.DistanceFar = 125; 646 ammusbrain.DistanceFar = 50; 647 ammusbrain.Speed = 80; 648 ammusbrain.TurnSpeed = UnlimitedAngle.FromDegrees(360); 649 ammusbrain.StopWhenTargetClose = false; 650 ammusbrain.TurnWhileMoving = true; 651 ammus.Brain = ammusbrain; 652 } 653 } 654 } 655 void missilehit(PhysicsObject tormaaja, PhysicsObject kohde) 656 { 657 tormaaja.Destroy(); 658 Explosion missilecrash = new Explosion(8); 659 missilecrash.Position = tormaaja.Position; 660 missilecrash.UseShockWave = false; 661 Add(missilecrash); 662 } 663 void firehoming(Weapon ase) 664 { 665 PhysicsObject ammus = ase.Shoot(); 666 if (ammus != null) 667 { 668 //Add(ammus, 2); 669 //ammus.Size *= ; 670 //ammus.Image = ...; 671 //ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 672 ammus.MaximumLifetime = TimeSpan.FromSeconds(5.0); 673 ammus.Image = homing; 674 AddCollisionHandler(ammus, missilehit); 675 ammus.IgnoresCollisionResponse = true; 676 ammus.Size *= 0.8; 677 ammus.AngularDamping = 1.0; 678 ammus.Image.ReplaceColor(Color.White, Color.Ultramarine); 679 ammus.Image.ReplaceColor(Color.Black, Color.Green); 680 AddCollisionHandler(ammus, "player1", CollisionHandler.DestroyObject); 681 FollowerBrain ammusbrain = new FollowerBrain("player", "laser"); 682 //ammusbrain.DistanceFar = 125; 683 ammusbrain.DistanceFar = 50; 684 ammusbrain.Speed = 80; 685 ammusbrain.TurnSpeed = UnlimitedAngle.FromDegrees(360); 686 ammusbrain.StopWhenTargetClose = false; 687 ammusbrain.TurnWhileMoving = true; 688 ammus.Brain = ammusbrain; 689 } 690 } 691 void weaponhit(PhysicsObject ammus, PhysicsObject kohde, int playerDamage, int enemyDamage) 692 { 693 if (kohde.Tag == "player") 694 { 695 Player ship = kohde as Player; 696 //ship.Health.Value -= 3; 697 ship.Health.Value -= playerDamage; 698 } 699 if (kohde.Tag == "hostile") 700 { 701 Enemy ship = kohde as Enemy; 702 //ship.Health.Value -= 1; 703 ship.Health.Value -= enemyDamage; 704 } 705 } 706 void Controlsship() 707 { 708 Keyboard.Listen(Key.W, ButtonState.Down, movement, null, 0, 100, ship1); 709 Keyboard.Listen(Key.S, ButtonState.Down, movement, null, 0, -100, ship1); 710 Keyboard.Listen(Key.A, ButtonState.Down, movement, null, -100, 0, ship1); 711 Keyboard.Listen(Key.D, ButtonState.Down, movement, null, 100, 0, ship1); 712 Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon, ship1); 713 Mouse.ListenMovement(0, Aim, null, ship1); 714 Mouse.Listen(MouseButton.Left, ButtonState.Down, fire, null, weapon, ship1); 715 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, null); 716 } 717 void Aim(AnalogState hiirenLiike, Player ship) 718 { 719 Vector suunta = (Mouse.PositionOnWorld - ship.AbsolutePosition).Normalize(); 720 ship.Angle = suunta.Angle; 721 } 722 void movement(int x, int y, PhysicsObject ship) 723 { 724 ship.Push(new Vector(x, y)); 725 } 422 726 void Controlsship1() 423 727 { 424 Keyboard.Listen(Key.W, ButtonState.Down, thrust, "", 1.0, ship );425 Keyboard.Listen(Key.S, ButtonState.Down, thrust, "", -1.0, ship );426 Keyboard.Listen(Key.A, ButtonState.Down, tilt, "", 1.0, ship );427 Keyboard.Listen(Key.D, ButtonState.Down, tilt, "", -1.0, ship );428 Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon );728 Keyboard.Listen(Key.W, ButtonState.Down, thrust, "", 1.0, ship1); 729 Keyboard.Listen(Key.S, ButtonState.Down, thrust, "", -1.0, ship1); 730 Keyboard.Listen(Key.A, ButtonState.Down, tilt, "", 1.0, ship1); 731 Keyboard.Listen(Key.D, ButtonState.Down, tilt, "", -1.0, ship1); 732 Keyboard.Listen(Key.Space, ButtonState.Down, fire, "", weapon, ship1); 429 733 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 430 734 } … … 435 739 Keyboard.Listen(Key.NumPad4, ButtonState.Down, tilt, "", 1.0, ship2); 436 740 Keyboard.Listen(Key.NumPad6, ButtonState.Down, tilt, "", -1.0, ship2); 437 Keyboard.Listen(Key.Add, ButtonState.Down, fire, "", weapon2 );438 } 439 void thrust(double direction, P hysicsObjectship)440 { 441 Vector shipdirection = Vector.FromLengthAndAngle(100.0 *direction, ship.Angle);741 Keyboard.Listen(Key.Add, ButtonState.Down, fire, "", weapon2, ship2); 742 } 743 void thrust(double direction, Player ship) 744 { 745 Vector shipdirection = Vector.FromLengthAndAngle(100.0 * direction, ship.Angle); 442 746 ship.Push(shipdirection); 443 747 } 444 void tilt(double direction, P hysicsObjectship)445 { 446 ship.AngularAcceleration = 10.0 *direction;748 void tilt(double direction, Player ship) 749 { 750 ship.AngularAcceleration = 10.0 * direction; 447 751 } 448 752 void singleplayerbase() … … 452 756 Level.CreateBorders(); 453 757 Camera.ZoomToLevel(); 454 Createship( );758 Createship(0, 0); 455 759 Spawnhostiles(); 456 Controlsship1(); 760 Controlsship(); 761 457 762 Timer a = new Timer(); 458 a.Interval = 5;763 a.Interval = 8; 459 764 a.Timeout += Spawnhostiles; 460 765 a.Start(); 461 766 } 767 462 768 void coopbase() 463 769 { … … 466 772 Level.CreateBorders(); 467 773 Camera.ZoomToLevel(); 468 Createship( );469 Createship2( );774 Createship(-100, 0); 775 Createship2(100, 0); 470 776 Spawnhostiles(); 471 777 Controlsship1(); … … 473 779 474 780 Timer a = new Timer(); 475 a.Interval = 5;781 a.Interval = 8; 476 782 a.Timeout += Spawnhostiles; 477 783 a.Start(); 478 784 } 785 786 void Spawnrunes() 787 { 788 while (runecounter < 5) 789 { 790 int runetype = RandomGen.NextInt(0, 2); 791 double runey = 0.0; 792 double runex = 0.0; 793 if (RandomGen.NextBool()) 794 { 795 runey = Level.Bottom + 2 * Level.Top * RandomGen.NextInt(0, 2); 796 runex = RandomGen.NextDouble(Level.Left, Level.Right); 797 } 798 else 799 { 800 runey = RandomGen.NextDouble(Level.Bottom, Level.Top); 801 runex = Level.Left + 2 * Level.Right * RandomGen.NextInt(0, 2); 802 } 803 Createhostile(runetype, runey, runex); 804 runecounter++; 805 } 806 } 807 void Createrune(int runetype, double y, double x) 808 { 809 PhysicsObject Rune = new PhysicsObject(5, 5); 810 Rune.X = x; 811 Rune.Y = y; 812 Rune.CollisionIgnoreGroup = 2 & 3 & 4; 813 814 switch (runetype) 815 { 816 case 1: 817 //Addcollision 818 Rune.Image = rdamage; 819 break; 820 case 2: 821 //Addcollision 822 Rune.Image = rrepair; 823 break; 824 case 3: 825 //Addcollision 826 //Rune.Image = ...; 827 break; 828 } 829 } 479 830 } -
2012/30/OtsoR/Projekti/Projekti/Projekti/Projekti.csproj.Debug.cachefile
r4201 r4281 100 100 Content\s99.xnb 101 101 Content\bullet.xnb 102 Content\pointer.xnb 103 Content\rdamage.xnb 104 Content\rrepair.xnb 105 Content\bigenemy.xnb 106 Content\missile.xnb 107 Content\esphere.xnb -
2012/30/OtsoR/Projekti/Projekti/Projekti/obj/x86/Debug/Projekti.csproj.FileListAbsolute.txt
r3819 r4281 1 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Projekti.exe2 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Projekti.pdb3 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Jypeli.dll4 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Jypeli.xml5 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\obj\x86\Debug\ResolveAssemblyReference.cache6 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt7 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\obj\x86\Debug\Projekti.exe8 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\obj\x86\Debug\Projekti.pdb9 1 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\s1.xnb 10 2 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\s10.xnb … … 108 100 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\s99.xnb 109 101 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\bullet.xnb 102 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Projekti.exe 103 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Projekti.pdb 104 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Jypeli.dll 105 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Jypeli.xml 106 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\obj\x86\Debug\ResolveAssemblyReference.cache 107 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\obj\x86\Debug\Microsoft.Xna.Framework.RuntimeProfile.txt 108 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\obj\x86\Debug\Projekti.exe 109 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\obj\x86\Debug\Projekti.pdb 110 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\pointer.xnb 111 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\rdamage.xnb 112 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\rrepair.xnb 113 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\bigenemy.xnb 114 C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\missile.xnb -
2012/30/OtsoR/Projekti/Projekti/Projekti/obj/x86/Debug/cachefile-{97999162-0C3B-480A-AB91-BD553A4EB51F}-targetpath.txt
r3819 r4281 100 100 Content\s99.xnb 101 101 Content\bullet.xnb 102 Content\pointer.xnb 103 Content\rdamage.xnb 104 Content\rrepair.xnb 105 Content\bigenemy.xnb 106 Content\missile.xnb -
2012/30/OtsoR/Projekti/Projekti/ProjektiContent/ProjektiContent.contentproj
r3819 r4281 553 553 </Compile> 554 554 </ItemGroup> 555 <ItemGroup> 556 <Compile Include="pointer.png"> 557 <Name>pointer</Name> 558 <Importer>TextureImporter</Importer> 559 <Processor>TextureProcessor</Processor> 560 </Compile> 561 </ItemGroup> 562 <ItemGroup> 563 <Compile Include="rdamage.png"> 564 <Name>rdamage</Name> 565 <Importer>TextureImporter</Importer> 566 <Processor>TextureProcessor</Processor> 567 </Compile> 568 <Compile Include="rrepair.png"> 569 <Name>rrepair</Name> 570 <Importer>TextureImporter</Importer> 571 <Processor>TextureProcessor</Processor> 572 </Compile> 573 </ItemGroup> 574 <ItemGroup> 575 <Compile Include="bigenemy.png"> 576 <Name>bigenemy</Name> 577 <Importer>TextureImporter</Importer> 578 <Processor>TextureProcessor</Processor> 579 </Compile> 580 </ItemGroup> 581 <ItemGroup> 582 <Compile Include="missile.png"> 583 <Name>missile</Name> 584 <Importer>TextureImporter</Importer> 585 <Processor>TextureProcessor</Processor> 586 </Compile> 587 </ItemGroup> 555 588 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 556 589 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2012/30/OtsoR/Projekti/Projekti/ProjektiContent/obj/x86/Debug/ContentPipeline.xml
r4201 r4281 910 910 <Output>C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\bullet.xnb</Output> 911 911 <Time>2013-06-24T14:37:17.0836813+03:00</Time> 912 </Item> 913 <Item> 914 <Source>pointer.png</Source> 915 <Name>pointer</Name> 916 <Importer>TextureImporter</Importer> 917 <Processor>TextureProcessor</Processor> 918 <Options>None</Options> 919 <Output>C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\pointer.xnb</Output> 920 <Time>2013-06-25T14:24:18.3001089+03:00</Time> 921 </Item> 922 <Item> 923 <Source>rdamage.png</Source> 924 <Name>rdamage</Name> 925 <Importer>TextureImporter</Importer> 926 <Processor>TextureProcessor</Processor> 927 <Options>None</Options> 928 <Output>C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\rdamage.xnb</Output> 929 <Time>2013-06-26T12:21:15.4338436+03:00</Time> 930 </Item> 931 <Item> 932 <Source>rrepair.png</Source> 933 <Name>rrepair</Name> 934 <Importer>TextureImporter</Importer> 935 <Processor>TextureProcessor</Processor> 936 <Options>None</Options> 937 <Output>C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\rrepair.xnb</Output> 938 <Time>2013-06-26T12:14:26.3399876+03:00</Time> 939 </Item> 940 <Item> 941 <Source>bigenemy.png</Source> 942 <Name>bigenemy</Name> 943 <Importer>TextureImporter</Importer> 944 <Processor>TextureProcessor</Processor> 945 <Options>None</Options> 946 <Output>C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\bigenemy.xnb</Output> 947 <Time>2013-06-27T10:14:12.4141641+03:00</Time> 948 </Item> 949 <Item> 950 <Source>missile.png</Source> 951 <Name>missile</Name> 952 <Importer>TextureImporter</Importer> 953 <Processor>TextureProcessor</Processor> 954 <Options>None</Options> 955 <Output>C:\MyTemp\OtsoR\Projekti\Projekti\Projekti\bin\x86\Debug\Content\missile.xnb</Output> 956 <Time>2013-06-27T12:28:34.7934641+03:00</Time> 912 957 </Item> 913 958 <BuildSuccessful>true</BuildSuccessful>
Note: See TracChangeset
for help on using the changeset viewer.