Implement Jackpot Win Animation (> 200)
Change Currency Name To "Q's" (i could probably come up with a better name here)
This commit is contained in:
parent
240bf9e9d7
commit
88806e93a4
BIN
qtc-net-client-2/Anims/left-horn-animated.gif
Normal file
BIN
qtc-net-client-2/Anims/left-horn-animated.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
BIN
qtc-net-client-2/Anims/right-horn-animated.gif
Normal file
BIN
qtc-net-client-2/Anims/right-horn-animated.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 15 KiB |
@ -30,23 +30,27 @@
|
|||||||
{
|
{
|
||||||
lblTokensWon = new Label();
|
lblTokensWon = new Label();
|
||||||
btnClaim = new Button();
|
btnClaim = new Button();
|
||||||
|
pbHornLeft = new PictureBox();
|
||||||
|
pbHornRight = new PictureBox();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pbHornLeft).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pbHornRight).BeginInit();
|
||||||
SuspendLayout();
|
SuspendLayout();
|
||||||
//
|
//
|
||||||
// lblTokensWon
|
// lblTokensWon
|
||||||
//
|
//
|
||||||
lblTokensWon.AutoSize = true;
|
lblTokensWon.AutoEllipsis = true;
|
||||||
lblTokensWon.Font = new Font("Segoe UI Black", 13F);
|
lblTokensWon.Font = new Font("Segoe UI Black", 13F);
|
||||||
lblTokensWon.Location = new Point(137, 30);
|
lblTokensWon.Location = new Point(145, 33);
|
||||||
lblTokensWon.Name = "lblTokensWon";
|
lblTokensWon.Name = "lblTokensWon";
|
||||||
lblTokensWon.Size = new Size(137, 25);
|
lblTokensWon.Size = new Size(129, 25);
|
||||||
lblTokensWon.TabIndex = 0;
|
lblTokensWon.TabIndex = 0;
|
||||||
lblTokensWon.Text = "0 Tokens Won";
|
lblTokensWon.Text = "300 Q's Won";
|
||||||
lblTokensWon.TextAlign = ContentAlignment.MiddleCenter;
|
lblTokensWon.TextAlign = ContentAlignment.MiddleCenter;
|
||||||
//
|
//
|
||||||
// btnClaim
|
// btnClaim
|
||||||
//
|
//
|
||||||
btnClaim.Enabled = false;
|
btnClaim.Enabled = false;
|
||||||
btnClaim.Location = new Point(167, 76);
|
btnClaim.Location = new Point(173, 72);
|
||||||
btnClaim.Name = "btnClaim";
|
btnClaim.Name = "btnClaim";
|
||||||
btnClaim.Size = new Size(75, 23);
|
btnClaim.Size = new Size(75, 23);
|
||||||
btnClaim.TabIndex = 1;
|
btnClaim.TabIndex = 1;
|
||||||
@ -54,12 +58,36 @@
|
|||||||
btnClaim.UseVisualStyleBackColor = true;
|
btnClaim.UseVisualStyleBackColor = true;
|
||||||
btnClaim.Click += btnClaim_Click;
|
btnClaim.Click += btnClaim_Click;
|
||||||
//
|
//
|
||||||
|
// pbHornLeft
|
||||||
|
//
|
||||||
|
pbHornLeft.Image = Properties.Resources.right_horn_animated;
|
||||||
|
pbHornLeft.Location = new Point(12, 8);
|
||||||
|
pbHornLeft.Name = "pbHornLeft";
|
||||||
|
pbHornLeft.Size = new Size(80, 100);
|
||||||
|
pbHornLeft.SizeMode = PictureBoxSizeMode.Zoom;
|
||||||
|
pbHornLeft.TabIndex = 2;
|
||||||
|
pbHornLeft.TabStop = false;
|
||||||
|
pbHornLeft.Visible = false;
|
||||||
|
//
|
||||||
|
// pbHornRight
|
||||||
|
//
|
||||||
|
pbHornRight.Image = Properties.Resources.left_horn_animated;
|
||||||
|
pbHornRight.Location = new Point(337, 8);
|
||||||
|
pbHornRight.Name = "pbHornRight";
|
||||||
|
pbHornRight.Size = new Size(78, 101);
|
||||||
|
pbHornRight.SizeMode = PictureBoxSizeMode.Zoom;
|
||||||
|
pbHornRight.TabIndex = 3;
|
||||||
|
pbHornRight.TabStop = false;
|
||||||
|
pbHornRight.Visible = false;
|
||||||
|
//
|
||||||
// TokenJackpotSpinner
|
// TokenJackpotSpinner
|
||||||
//
|
//
|
||||||
AutoScaleDimensions = new SizeF(7F, 15F);
|
AutoScaleDimensions = new SizeF(7F, 15F);
|
||||||
AutoScaleMode = AutoScaleMode.Font;
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
BackColor = Color.DodgerBlue;
|
BackColor = Color.DodgerBlue;
|
||||||
ClientSize = new Size(427, 125);
|
ClientSize = new Size(427, 117);
|
||||||
|
Controls.Add(pbHornRight);
|
||||||
|
Controls.Add(pbHornLeft);
|
||||||
Controls.Add(btnClaim);
|
Controls.Add(btnClaim);
|
||||||
Controls.Add(lblTokensWon);
|
Controls.Add(lblTokensWon);
|
||||||
DoubleBuffered = true;
|
DoubleBuffered = true;
|
||||||
@ -73,13 +101,16 @@
|
|||||||
FormClosing += TokenJackpotSpinner_FormClosing;
|
FormClosing += TokenJackpotSpinner_FormClosing;
|
||||||
FormClosed += TokenJackpotSpinner_FormClosed;
|
FormClosed += TokenJackpotSpinner_FormClosed;
|
||||||
Load += TokenJackpotSpinner_Load;
|
Load += TokenJackpotSpinner_Load;
|
||||||
|
((System.ComponentModel.ISupportInitialize)pbHornLeft).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)pbHornRight).EndInit();
|
||||||
ResumeLayout(false);
|
ResumeLayout(false);
|
||||||
PerformLayout();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
private Label lblTokensWon;
|
private Label lblTokensWon;
|
||||||
private Button btnClaim;
|
private Button btnClaim;
|
||||||
|
private PictureBox pbHornLeft;
|
||||||
|
private PictureBox pbHornRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,12 +26,15 @@ namespace qtc_net_client_2.Forms
|
|||||||
{
|
{
|
||||||
btnClaim.Enabled = false;
|
btnClaim.Enabled = false;
|
||||||
AllowClose = false;
|
AllowClose = false;
|
||||||
|
|
||||||
|
_audioService.OnSoundEnded += _audioService_OnSoundEnded;
|
||||||
await StartSpinAnimation(lblTokensWon);
|
await StartSpinAnimation(lblTokensWon);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void TokenJackpotSpinner_FormClosed(object sender, FormClosedEventArgs e)
|
private void TokenJackpotSpinner_FormClosed(object sender, FormClosedEventArgs e)
|
||||||
{
|
{
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
|
_audioService.Dispose();
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,6 +49,16 @@ namespace qtc_net_client_2.Forms
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void _audioService_OnSoundEnded(object? sender, SoundEndedEventArgs e)
|
||||||
|
{
|
||||||
|
switch(e.EventString)
|
||||||
|
{
|
||||||
|
case "sndTokenWin":
|
||||||
|
DetermineWinAnim();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public async Task StartSpinAnimation(Label label)
|
public async Task StartSpinAnimation(Label label)
|
||||||
{
|
{
|
||||||
if (label.IsHandleCreated)
|
if (label.IsHandleCreated)
|
||||||
@ -55,7 +68,7 @@ namespace qtc_net_client_2.Forms
|
|||||||
|
|
||||||
while (_audioService.OutputDevice?.PlaybackState == NAudio.Wave.PlaybackState.Playing)
|
while (_audioService.OutputDevice?.PlaybackState == NAudio.Wave.PlaybackState.Playing)
|
||||||
{
|
{
|
||||||
label.BeginInvoke(delegate () { label.Text = $"{rnd.Next(0, 300)} Tokens Won"; });
|
label.BeginInvoke(delegate () { label.Text = $"{rnd.Next(0, 300)} Q's Won"; });
|
||||||
await Task.Delay(10);
|
await Task.Delay(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,15 +76,26 @@ namespace qtc_net_client_2.Forms
|
|||||||
|
|
||||||
label.BeginInvoke(delegate ()
|
label.BeginInvoke(delegate ()
|
||||||
{
|
{
|
||||||
label.Text = $"{win} Tokens Won";
|
label.Text = $"{win} Q's Won";
|
||||||
btnClaim.Enabled = true;
|
btnClaim.Enabled = true;
|
||||||
_audioService.PlaySoundEffect("sndTokenWin");
|
_audioService.PlaySoundEffectWithEventString("sndTokenWin", "sndTokenWin");
|
||||||
});
|
});
|
||||||
|
|
||||||
_audioService.Dispose();
|
|
||||||
AllowClose = true;
|
AllowClose = true;
|
||||||
TokensWon = win;
|
TokensWon = win;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void DetermineWinAnim()
|
||||||
|
{
|
||||||
|
switch(TokensWon)
|
||||||
|
{
|
||||||
|
case > 200:
|
||||||
|
pbHornLeft.BeginInvoke(delegate () { pbHornLeft.Visible = true; });
|
||||||
|
pbHornRight.BeginInvoke(delegate () { pbHornRight.Visible = true; });
|
||||||
|
_audioService.PlaySoundEffect("sndTokenJackpot");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
20
qtc-net-client-2/Properties/Resources.Designer.cs
generated
20
qtc-net-client-2/Properties/Resources.Designer.cs
generated
@ -140,6 +140,16 @@ namespace qtc_net_client_2.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap left_horn_animated {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("left-horn-animated", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -200,6 +210,16 @@ namespace qtc_net_client_2.Properties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap right_horn_animated {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("right-horn-animated", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
/// Looks up a localized resource of type System.Drawing.Bitmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -118,6 +118,9 @@
|
|||||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
</resheader>
|
</resheader>
|
||||||
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="right-horn-animated" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Anims\right-horn-animated.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="SendIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="SendIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Icons\SendIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Icons\SendIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
@ -139,6 +142,9 @@
|
|||||||
<data name="AwayIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="AwayIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Icons\AwayIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Icons\AwayIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="CurrencyIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Icons\CurrencyIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
<data name="AddContactIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="AddContactIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Icons\AddContactIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Icons\AddContactIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
@ -160,7 +166,7 @@
|
|||||||
<data name="AcceptContactIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="AcceptContactIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Icons\AcceptContactIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Icons\AcceptContactIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
<data name="CurrencyIcon" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
<data name="left-horn-animated" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
<value>..\Icons\CurrencyIcon.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
<value>..\Anims\left-horn-animated.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
</data>
|
</data>
|
||||||
</root>
|
</root>
|
@ -12,6 +12,8 @@ namespace qtc_net_client_2.Services
|
|||||||
{
|
{
|
||||||
public WaveOutEvent? OutputDevice { get; set; }
|
public WaveOutEvent? OutputDevice { get; set; }
|
||||||
public AudioFileReader? AudioFileReader { get; set; }
|
public AudioFileReader? AudioFileReader { get; set; }
|
||||||
|
|
||||||
|
public event EventHandler<SoundEndedEventArgs>? OnSoundEnded;
|
||||||
public void PlaySoundEffect(string soundName)
|
public void PlaySoundEffect(string soundName)
|
||||||
{
|
{
|
||||||
if (!File.Exists($"./Sounds/{soundName}.wav")) return;
|
if (!File.Exists($"./Sounds/{soundName}.wav")) return;
|
||||||
@ -24,6 +26,18 @@ namespace qtc_net_client_2.Services
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PlaySoundEffectWithEventString(string soundName, string eventString)
|
||||||
|
{
|
||||||
|
if (!File.Exists($"./Sounds/{soundName}.wav")) return;
|
||||||
|
|
||||||
|
OutputDevice = new WaveOutEvent();
|
||||||
|
AudioFileReader = new AudioFileReader($"./Sounds/{soundName}.wav");
|
||||||
|
OutputDevice.Init(AudioFileReader);
|
||||||
|
OutputDevice.Play();
|
||||||
|
|
||||||
|
OutputDevice.PlaybackStopped += (sender, args) => OnSoundEnded?.Invoke(null, new SoundEndedEventArgs { EventString = eventString });
|
||||||
|
}
|
||||||
|
|
||||||
public void PlaySoundLooped(string soundName, int loopCount)
|
public void PlaySoundLooped(string soundName, int loopCount)
|
||||||
{
|
{
|
||||||
if (!File.Exists($"./Sounds/{soundName}.wav")) return;
|
if (!File.Exists($"./Sounds/{soundName}.wav")) return;
|
||||||
@ -50,4 +64,9 @@ namespace qtc_net_client_2.Services
|
|||||||
if (AudioFileReader != null) { AudioFileReader.Dispose(); AudioFileReader = null; }
|
if (AudioFileReader != null) { AudioFileReader.Dispose(); AudioFileReader = null; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public class SoundEndedEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
public string EventString { get; set; } = "UNKNOWN";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user