Changeset 8467 for 2017/23/JaakkoS/Makkarajono
- Timestamp:
- 2017-06-09 11:08:53 (4 years ago)
- Location:
- 2017/23/JaakkoS/Makkarajono/Makkarajono/Makkarajono
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
2017/23/JaakkoS/Makkarajono/Makkarajono/Makkarajono/Makkarajono.cs
r8466 r8467 17 17 } 18 18 19 MessageWindow winScreen; 19 20 Label timeScreenP; 20 21 Timer timeTimer; 22 Timer colorTimer; 21 23 IntMeter p1Points; 22 24 IntMeter p2Points; … … 69 71 { 70 72 ClearAll(); 71 73 IsFullScreen = false; 72 74 StartMenu = new MultiSelectWindow("Welcome!", "Start", "Exit"); 73 75 StartMenu.AddItemHandler(0, AskNames, false); … … 461 463 void AddPlayerNames(string _name, double x, double y, bool isIcon2) 462 464 { 463 Label nameField = new Label(_name.Length * 1 3, 30, _name);465 Label nameField = new Label(_name.Length * 14, 30, _name); 464 466 nameField.X = x; 465 467 nameField.Y = y; … … 547 549 _player.PlayAnimation(p1Punch, () => 548 550 { 549 _player.Stop ();550 Timer.SingleShot(0. 5, delegate { isAttacking = false; });551 _player.StopHorizontal(); 552 Timer.SingleShot(0.3, delegate { isAttacking = false; }); 551 553 }); 552 554 } … … 564 566 void AddTimeCounter() 565 567 { 566 timeCounterSeconds = new IntMeter( 60);568 timeCounterSeconds = new IntMeter(30); 567 569 timeCounterMinutes = new IntMeter(1); 568 570 … … 578 580 timeScreenP.X = Screen.Center.X; 579 581 timeScreenP.Y = Screen.Top - 20; 582 timeScreenP.Font = Font.DefaultLargeBold; 580 583 Add(timeScreenP, 3); 581 584 } … … 584 587 { 585 588 timeCounterSeconds.Value -= 1; 586 if(timeCounterSeconds >= 10) 587 timeScreenP.Text = timeCounterMinutes + ":" + timeCounterSeconds; 588 589 else 589 if (timeCounterSeconds.Value >= 10) 590 timeScreenP.Text = timeCounterMinutes + ":" + timeCounterSeconds; 591 592 else 593 { 590 594 timeScreenP.Text = timeCounterMinutes + ":0" + timeCounterSeconds; 591 592 if (timeCounterSeconds.Value <= 0 && timeCounterMinutes > 0) 595 } 596 597 if (timeCounterSeconds.Value <= 0 && timeCounterMinutes.Value > 0) 593 598 { 594 599 timeCounterMinutes.Value -= 1; 595 600 timeCounterSeconds.Value += 60; 596 601 } 597 if (timeCounterSeconds.Value <= 0 && timeCounterMinutes == 0) 598 { 602 colorTimer = new Timer(); 603 colorTimer.Interval = 0.05; 604 colorTimer.Timeout += delegate 605 { 606 if (timeCounterSeconds <= 10 && timeCounterMinutes == 0) { 607 Color _randomColor = RandomColor(); 608 timeScreenP.TextColor = _randomColor; 609 } 610 else 611 { 612 timeScreenP.TextColor = Color.White; 613 } 614 }; 615 colorTimer.Start(); 616 617 if (timeCounterSeconds.Value <= 0 && timeCounterMinutes.Value == 0) 618 { 619 colorTimer.Stop(); 620 timeScreenP.TextColor = Color.White; 599 621 WinScreen(); 600 622 } … … 606 628 if(p1Points > p2Points) 607 629 { 608 MessageWindow winScreen = new MessageWindow(p1name + " won!"); 609 winScreen.Closed += delegate { Begin(); }; 630 Pause(); 631 if(p1name == "") 632 winScreen = new MessageWindow("Blue player won!"); 633 else 634 winScreen = new MessageWindow(p1name + " won!"); 635 winScreen.Closed += delegate { Begin(); Pause(); }; 610 636 Add(winScreen); 611 637 } 612 else 613 { 614 MessageWindow winScreen = new MessageWindow(p2name + " won!"); 615 winScreen.Closed += delegate { Begin(); }; 638 else if (p2Points > p1Points) 639 { 640 Pause(); 641 if(p2name == "") 642 winScreen = new MessageWindow("Green player won!"); 643 else 644 winScreen = new MessageWindow(p2name + " won!"); 645 winScreen.Closed += delegate { Begin(); Pause(); }; 616 646 Add(winScreen); 617 647 } 648 else 649 { 650 Pause(); 651 winScreen = new MessageWindow( "Draw!"); 652 winScreen.Closed += delegate { Begin(); Pause(); }; 653 Add(winScreen); 654 655 } 656 } 657 658 Color RandomColor() 659 { 660 byte[] buffer = new byte[3]; 661 new Random(DateTime.Now.Millisecond * 100000 + DateTime.Now.Second * 10000 + DateTime.Now.Minute * 100000).NextBytes(buffer); 662 return new Color(buffer[0], buffer[1], buffer[2]); 618 663 } 619 664
Note: See TracChangeset
for help on using the changeset viewer.