-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMainWindow.xaml.cs
531 lines (269 loc) · 17.3 KB
/
MainWindow.xaml.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
using MahApps.Metro.Controls;
using System;
using System.Collections.Generic;
using System.Media;
using System.Windows;
using System.Windows.Media.Imaging;
using System.Windows.Threading;
namespace Rock_paper_scissors
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
///
public partial class MainWindow : MetroWindow
{
public MainWindow()
{
InitializeComponent();
}
public void DispatcherTimerSample()
{
InitializeComponent();
DispatcherTimer timer = new DispatcherTimer();
timer.Interval = TimeSpan.FromSeconds(1);
timer.Tick += timer_Tick;
timer.Start();
}
void timer_Tick(object sender, EventArgs e)
{
//lblTime.Content = DateTime.Now.ToLongTimeString();
}
int numberofwins = 0; // the number of wins
int numberoflosses = 0; // the number of losses
int numberofties = 0; // the number of ties
int numberofwinsCPU = 0; // the number of wins for the CPU.
int numberoflossesCPU = 0; // the number of losses for the CPU.
int numberoftiesCPU = 0; // The Number of ties for the cpu.
private void RadioButton_Checked(object sender, RoutedEventArgs e) ///Rock Option
{
//Player1_Option_Chosen.Source = new BitmapImage(new Uri("Mickey Rockoldbad.jpg", UriKind.Relative)); //sets the image to rock.
Player1_Option_Chosen.Source = new BitmapImage(new Uri("pack://application:,,,/ImagesBeingUsed/MickeyRockBetterfortheplayer.png")); // loads the paper image
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.Falling_Rock_Sound; // plays the rock sound file.
player.Load(); // loads the file
player.Play(); // plays the file
}
private void Paper_Option_Checked(object sender, RoutedEventArgs e) // paper option
{
Player1_Option_Chosen.Source = new BitmapImage(new Uri("pack://application:,,,/ImagesBeingUsed/PAPER Proper left.png")); // loads the paper image
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.Paper_Soundfinal; // plays the paper sound file.
player.Load(); // loads the file
player.Play(); // plays the file
}
private void Scissior_Option_Checked(object sender, RoutedEventArgs e) // scissior option checked
{
Player1_Option_Chosen.Source = new BitmapImage(new Uri("pack://application:,,,/ImagesBeingUsed/Scissors2trans.png")); //loads the scissors image.
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.Scissors_Final_Sound; // plays the paper sound file.
player.Load(); // loads the file
player.Play(); // plays the file
}
public static int NumMembers { get; protected set; }
//player2 option chosen is for the cpu.
public void Button_Click(object sender, RoutedEventArgs e) //run game button. The Main Part of the Code.
{
//array of choices to pick for the cpu.
var choices = new List<string> { "rock", "paper", "scissor" }; // A list of choices the cpu will pick.
//0 = rock, 1 = paper. 3 = scissor.
//create a new random to be used. Will be used in the cpu picking a choice.
Random random = new Random();
int index = random.Next(choices.Count); // randomly pick a choice. The CPU picks a random choice.
String choicepicked = choices[index]; // choice is stored in the string.
Console.WriteLine($"choice picked by the cpu is " + choicepicked); //writes to the console to show what the choice is for the cpu.
if (choicepicked.Equals("rock")) //if choice picked equals rock then load rock image for cpu.
{
Player2_Option_Chosen.Source = new BitmapImage(new Uri(" pack://application:,,,/ImagesBeingUsed/MickeyRockBetter.png")); //loads the rock image.
}
if (choicepicked.Equals("paper")) //if choice picked equals rock then load paper image for cpu.
{
Player2_Option_Chosen.Source = new BitmapImage(new Uri("pack://application:,,,/ImagesBeingUsed/paperright.png")); //loads the Paper image.
}
if (choicepicked.Equals("paper") && Scissior_Option.IsChecked == true) //if choice picked equals paper and the player chose scissors then the player wins
{
//player wins. Increase the number of wins.
numberofwins += 1; // increase number of wins by one
Console.WriteLine("number of wins is " + numberofwins); //writes the number of wins in the console. For Testing and debugging.
numberoflossesCPU += 1; // increase the number of looses for the cpu
Console.WriteLine("number of losses for the cpu is " + numberoflossesCPU);
/// Color color2 = (Color)ColorConverter.ConvertFromString("#FF00FF23"); screw it
Game_Status_Textblock.Text = "VICTORY"; //change game status to victory since player won.
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Gold; // change text to gold.
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_Narration_Victory; // plays the defeat sound file
player.Load(); // loads the file
player.Play(); // plays the file
}
if (choicepicked.Equals("paper") && Rock_Option.IsChecked == true) //if choice picked equals paper and the player chose rock then the player looses
{
//player loses. Increse the number of loses
numberoflosses += 1; // increase number of wins by one
Console.WriteLine("the number of losses is" + numberoflosses); //prints the number of losses to console.
numberofwinsCPU += 1; //increase the number of wins for the cpu
Console.WriteLine("number of wins for the cpu is " + numberofwinsCPU); //prints the number of cpu wins to the console.
Game_Status_Textblock.Text = "DEFEATED"; //change game status to DEFEATED
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Red; // CHange text Color to red
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_narration_Defeated; // plays the defeat sound file
player.Load(); // loads the file
player.Play(); // plays the file
}
if (choicepicked.Equals("paper") && Paper_Option.IsChecked == true) //if choice picked equals paper and the player chose paper then a tie is declared.
{
//Tie is declared. Increase the number of ties.
numberofties += 1; // increase the number of ties.
Console.WriteLine("the number of ties is" + numberofties); //prints the number of ties to console.
numberoftiesCPU += 1; //increase the number of ties for the cpu
Console.WriteLine("number of ties for the cpu is " + numberoftiesCPU); //prints the number of ties for the cpu to the console.
Game_Status_Textblock.Text = "TIE"; //change game status to TIE
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Orange; // CHange text Color to Orange.
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_narration_Gameset; // plays the gameset soud file
player.Load(); // loads the file
player.Play(); // plays the file
}
if (choicepicked.Equals("rock") && Paper_Option.IsChecked == true) // if paper option is made by and rock is chosen by the cpu then..
{
//player wins. Increase the number of wins.
numberofwins += 1; // increase number of wins by one
Console.WriteLine("number of wins is " + numberofwins); //writes the number of wins in the console. For Testing and debugging.
numberoflossesCPU += 1; //increase the number of losses
Console.WriteLine("number of losses for the cpu is " + numberoflossesCPU); //prints the number of cpu losses to the console.
Game_Status_Textblock.Text = "VICTORY"; //change game status to victory since player won.
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Gold; // change text to gold.
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_Narration_Victory; // plays the Victory sound file
player.Load(); // loads the file
player.Play(); // plays the file
}
if (choicepicked.Equals("rock") && Scissior_Option.IsChecked == true) // if rock is chosen by the cpu, player chooses scissior then the player looses
{
//player looses, increase the number of looses
numberoflosses += 1; // increase number of looses by one
numberofwinsCPU += 1; //increase the number of wins for the cpu
Console.WriteLine("number of wins for the cpu is " + numberofwinsCPU); //prints the number of cpu wins to the console.
Console.WriteLine("number of looses is " + numberoflosses); //writes the number of looses in the console. For Testing and debugging.
Game_Status_Textblock.Text = "DEFEATED"; //change game status to Defeated
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Red; // CHange text Color to Red.
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_narration_Defeated; // plays the defeated sound file
player.Load(); // loads the file
player.Play(); // plays the file
}
if (choicepicked.Equals("rock") && Rock_Option.IsChecked == true) // if rock is chosen by the cpu, player chooses rock then a tie is declared
{
// a Tie is declared. Incrase the number of ties
numberofties += 1; // increase number of ties
numberoftiesCPU += 1; //increase the number of ties for the cpu
Console.WriteLine("number of ties for the cpu is " + numberoftiesCPU); //prints the number of ties for the cpu to the console.
Console.WriteLine("number of ties is " + numberofties); //writes the number of ties in the console. For Testing and debugging.
Game_Status_Textblock.Text = "TIE"; //change game status to tie.
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Orange; // change text color to orange
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_narration_Gameset; // plays the gameset soud file
player.Load(); // loads the file
player.Play(); // plays the file
}
if (choicepicked.Equals("scissor")) // if scissior is chosen by the cpu, load the scissior image
{
Player2_Option_Chosen.Source = new BitmapImage(new Uri("pack://application:,,,/ImagesBeingUsed/Scissors for the right sideTransparent.png")); //loads the Scissior image
}
if (choicepicked.Equals("scissor") && Paper_Option.IsChecked == true) // if scissior is chosen by the cpu, player chooses paper then a loss is declared
{
//Player looses. Increase the number of losses
numberoflosses += 1; // increase number of losses
Console.WriteLine("number of looses is " + numberoflosses); //writes the number of looses to the console.
numberofwinsCPU += 1; //increase the number of wins for the cpu
Console.WriteLine("number of wins for the cpu is " + numberofwinsCPU); //prints the number of cpu wins to the console.
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_narration_Defeated; // plays the defeated sound file
player.Load(); // loads the file
player.Play(); // plays the file
Game_Status_Textblock.Text = "DEFEATED"; //change game status to Defeated
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Red; // change text color to red.
}
if (choicepicked.Equals("scissor") && Scissior_Option.IsChecked == true) // if scissior is chosen by the cpu, player chooses Scissior then a tie is declared
{
//A tie is declared. Incrase the number of ties
numberofties += 1; // increase number of ties
numberoftiesCPU += 1; //increase the number of ties for the cpu
Console.WriteLine("number of ties for the cpu is " + numberoftiesCPU); //prints the number of ties for the cpu to the console.
Console.WriteLine("number of ties is " + numberofties); //writes the number of ties to the console.
Game_Status_Textblock.Text = "TIE"; //change game status to Tie
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Orange; // change text to orange
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_narration_Gameset; // plays the gameset soud file
player.Load(); // loads the file
player.Play(); // plays the file
}
if (choicepicked.Equals("scissor") && Rock_Option.IsChecked == true) // if scissior is chosen by the cpu, player chooses rock then a win is declared
{
//Player wins. Increase the number of wins
numberofwins += 1; // increase number of wins
Console.WriteLine("number of wins is " + numberofwins); //writes the number of wins to the console.
numberoflossesCPU += 1; //increase the number of losses
Console.WriteLine("number of losses for the cpu is " + numberoflossesCPU); //prints the number of cpu losses to the console.
Game_Status_Textblock.Text = "SUCCESS"; //change game status to victory since player won.
Game_Status_Textblock.Foreground = System.Windows.Media.Brushes.Gold; // change text to gold.
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_narration_Success; // plays the sucess soud file
player.Load(); // loads the file
player.Play(); // plays the file
}
Number_of_wins_textblock.Text = "Wins " + numberofwins; // puts the number of wins in the textblock.
Number_of_Losses_textblock.Text = "Loses " + numberoflosses; // puts the number of losses in the textblock.
Number_of_Ties_textblock.Text = "Ties " + numberofties; // the number of ties is put into the textblock.
Number_of_Losses_CPU_textblock.Text = "Loses " + numberoflossesCPU; // the number of losses for the cpu is put into the textblock.
Number_of_Ties_CPU_textblock.Text = "Ties " + numberoftiesCPU; //the number of ties for the cpu is put into the textblock.
Number_of_wins_CPU_textblock.Text = "Wins " + numberofwinsCPU; //the number of wins for the cpu is put into the textblock.
}
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
// private void playsound(object sender, RoutedEventArgs e)
// {
// SoundPlayer player = new SoundPlayer(); // creates a new sound player
// player.Stream = Properties.Resources.snd_se_narration_Player_01; // plays the paper sound file.
// player.Load(); // loads the file
// player.Play(); // plays the file
// System.Threading.Thread.Sleep(3000);
// SoundPlayer player2 = new SoundPlayer(); // creates a new sound player
// player2.Stream = Properties.Resources.snd_se_narration_Player_01; // plays the paper sound file.
// player2.Load(); // loads the file
// player2.Play(); // plays the file
// }
private void playsound(object sender, RoutedEventArgs e) //plays when the textblock loads
{
SoundPlayer player = new SoundPlayer(); // creates a new sound player
player.Stream = Properties.Resources.snd_se_narration_Player_01; // plays the player1 sound.
player.Load(); // loads the file
player.Play(); // plays the file
System.Threading.Thread.Sleep(3000);
SoundPlayer player2 = new SoundPlayer(); // creates a new sound player
player2.Stream = Properties.Resources.snd_se_narration_Go; // plays the go sound
player2.Load(); // loads the file
player2.Play(); // plays the file
}
private void MenuItem_Click(object sender, RoutedEventArgs e) //click event for the About menu item.
{
Window1 window1 = new Window1();
window1.Show();
}
//TODO: Load the sound effects when the player wins, looses. DONE.
//TODO: If you can, find a sound effect for a game tie. (Myabe a audience shock effect might be a good idea). DONE
//TODO: Add The game Status Text when the player looses, Wins, or gets a tie. DONE
//TODO: Add Wins, Ties and losses counter for the CPU. DONE.
//TODO: Make the Wins, Ties, and losses Counter Functionsl for the cpu. DONE
//TODO: Add the sound Effect game for when a tie is declared. DONE
//TODO:get rid of the old images we do not use. Try to orgnaize them into a folder if you can. DONE
//TODO: Get rid of Sound files we are not using. DONE
//TODO: Add a About menu or a label with your name on it. DONE
//TODO: Organize the soud files into one folder. DONE
//TODO: These will be the final changes most likely.
// Make text in game status disappear after a few seconds. Maybe 3-5 seconds.
//TODO: CHange colors. Find a color theme online and use that.
}
}