Skip to content

Commit

Permalink
Bound CPS image to main image, hid PS multiplier during endgame and N…
Browse files Browse the repository at this point in the history
…OTHING else
  • Loading branch information
TollyH committed Jan 24, 2022
1 parent 87129fc commit 3dee39e
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 42 deletions.
34 changes: 28 additions & 6 deletions CandyClicker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,23 @@
</PropertyGroup>

<ItemGroup>
<None Remove="candy-reincarnate.png" />
<None Remove="candy-special.png" />
<None Remove="candy.png" />
<None Remove="candy_special_dzI_icon.ico" />
<None Remove="candy_xnp_icon.ico" />
<None Remove="mikachanALL.ttc" />
<None Remove="Images\candy-reincarnate.png" />
<None Remove="Images\candy-special.png" />
<None Remove="Images\candy.png" />
<None Remove="Icons\candy_special_dzI_icon.ico" />
<None Remove="Icons\candy_xnp_icon.ico" />
<None Remove="Images\easter-fin-1.png" />
<None Remove="Images\easter-fin-2.png" />
<None Remove="Images\easter-fin-3.png" />
<None Remove="Images\easter-fin-4.png" />
<None Remove="Images\easter-fin-5.png" />
<None Remove="Images\easter-riley-1.png" />
<None Remove="Images\easter-riley-2.png" />
<None Remove="Images\easter-tolly-1.png" />
<None Remove="Images\easter-tolly-2.png" />
<None Remove="Images\easter-tom-1.png" />
<None Remove="Images\easter-tom-2.png" />
<None Remove="Fonts\mikachanALL.ttc" />
</ItemGroup>

<ItemGroup>
Expand All @@ -42,6 +53,17 @@
<Resource Include="Icons\candy_special_dzI_icon.ico" />
<Resource Include="Icons\candy_xnp_icon.ico" />
<Resource Include="Fonts\mikachanALL.ttc" />
<Resource Include="Images\easter-fin-1.png" />
<Resource Include="Images\easter-fin-2.png" />
<Resource Include="Images\easter-fin-3.png" />
<Resource Include="Images\easter-fin-4.png" />
<Resource Include="Images\easter-fin-5.png" />
<Resource Include="Images\easter-riley-1.png" />
<Resource Include="Images\easter-riley-2.png" />
<Resource Include="Images\easter-tolly-1.png" />
<Resource Include="Images\easter-tolly-2.png" />
<Resource Include="Images\easter-tom-1.png" />
<Resource Include="Images\easter-tom-2.png" />
</ItemGroup>

</Project>
Binary file added Images/easter-fin-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-fin-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-fin-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-fin-4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-fin-5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-riley-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-riley-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-tolly-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-tolly-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-tom-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Images/easter-tom-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<FlowDocument x:Name="flowDocumentCandiesPerSecond">
<Paragraph x:Name="paragraphCandiesPerSecond" TextAlignment="Center">
<Run x:Name="runCandiesPerSecond" Text="0"/>
<Image Source="/Images/candy.png" Height="15" RenderOptions.BitmapScalingMode="HighQuality"/><!--
<Image Source="{Binding Source, ElementName=imageCandy}" Height="15" RenderOptions.BitmapScalingMode="HighQuality"/><!--
--><Run Text="PS"/>
</Paragraph>
<Paragraph x:Name="paragraphEndGamePerSecond" TextAlignment="Center">
Expand Down
227 changes: 192 additions & 35 deletions MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Media.Imaging;

namespace CandyClicker
{
Expand Down Expand Up @@ -46,7 +47,7 @@ public ulong CandyPSReincarnationMultiplier
set
{
SetValue(CandyPSReincarnationMultiplierProperty, value);
textBlockReincarnated.Visibility = value <= 1 ? Visibility.Hidden : Visibility.Visible;
textBlockReincarnated.Visibility = value is <= 1 or ulong.MaxValue ? Visibility.Hidden : Visibility.Visible;
}
}

Expand All @@ -68,6 +69,120 @@ public ulong CandyPSReincarnationMultiplier
// IAMALAZYCHEATER ;)
private readonly Key[] cheatMenuKeys = new Key[15] { Key.I, Key.A, Key.M, Key.A, Key.L, Key.A, Key.Z, Key.Y, Key.C, Key.H, Key.E, Key.A, Key.T, Key.E, Key.R };

private enum EasterEggState
{
Normal,
Tolly,
Fin,
Riley,
Tom
}
private readonly Dictionary<EasterEggState, Key[]> easterEggKeys = new()
{
{
EasterEggState.Normal,
new Key[20]
{
// SAVEMEFROMTHISHORROR
Key.S, Key.A, Key.V, Key.E, Key.M, Key.E, Key.F, Key.R, Key.O, Key.M, Key.T, Key.H, Key.I, Key.S, Key.H, Key.O, Key.R, Key.R, Key.O, Key.R
}
},
{
EasterEggState.Tolly,
new Key[16]
{
// IAMTHEPROGRAMMER
Key.I, Key.A, Key.M, Key.T, Key.H, Key.E, Key.P, Key.R, Key.O, Key.G, Key.R, Key.A, Key.M, Key.M, Key.E, Key.R
}
},
{
EasterEggState.Fin,
new Key[12]
{
// INSANITYISME
Key.I, Key.N, Key.S, Key.A, Key.N, Key.I, Key.T, Key.Y, Key.I, Key.S, Key.M, Key.E
}
},
{
EasterEggState.Riley,
new Key[16]
{
// PLEASELETMESLEEP
Key.P, Key.L, Key.E, Key.A, Key.S, Key.E, Key.L, Key.E, Key.T, Key.M, Key.E, Key.S, Key.L, Key.E, Key.E, Key.P
}
},
{
EasterEggState.Tom,
new Key[15]
{
// TOOHIGHTOATTEND
Key.T, Key.O, Key.O, Key.H, Key.I, Key.G, Key.H, Key.T, Key.O, Key.A, Key.T, Key.T, Key.E, Key.N, Key.D
}
}
};
private readonly Dictionary<EasterEggState, BitmapImage[]> easterEggImages = new()
{
{
EasterEggState.Normal,
new BitmapImage[1]
{
new BitmapImage(new Uri("pack://application:,,,/Images/candy.png"))
}
},
{
EasterEggState.Tolly,
new BitmapImage[2]
{
new BitmapImage(new Uri("pack://application:,,,/Images/easter-tolly-1.png")),
new BitmapImage(new Uri("pack://application:,,,/Images/easter-tolly-2.png"))
}
},
{
EasterEggState.Fin,
new BitmapImage[5]
{
new BitmapImage(new Uri("pack://application:,,,/Images/easter-fin-1.png")),
new BitmapImage(new Uri("pack://application:,,,/Images/easter-fin-2.png")),
new BitmapImage(new Uri("pack://application:,,,/Images/easter-fin-3.png")),
new BitmapImage(new Uri("pack://application:,,,/Images/easter-fin-4.png")),
new BitmapImage(new Uri("pack://application:,,,/Images/easter-fin-5.png"))
}
},
{
EasterEggState.Riley,
new BitmapImage[2]
{
new BitmapImage(new Uri("pack://application:,,,/Images/easter-riley-1.png")),
new BitmapImage(new Uri("pack://application:,,,/Images/easter-riley-2.png"))
}
},
{
EasterEggState.Tom,
new BitmapImage[2]
{
new BitmapImage(new Uri("pack://application:,,,/Images/easter-tom-1.png")),
new BitmapImage(new Uri("pack://application:,,,/Images/easter-tom-2.png"))
}
}
};
private readonly Dictionary<EasterEggState, Color> easterEggBackgroundColors = new()
{
{ EasterEggState.Normal, new Color() { R = 0x86, G = 0xFF, B = 0xFA, A = 0xFF } },
{ EasterEggState.Tolly, new Color() { R = 0x46, G = 0x46, B = 0x46, A = 0xFF } },
{ EasterEggState.Fin, new Color() { R = 0x94, G = 0x00, B = 0x00, A = 0xFF } },
{ EasterEggState.Riley, new Color() { R = 0x00, G = 0x5C, B = 0x1D, A = 0xFF } },
{ EasterEggState.Tom, new Color() { R = 0xFF, G = 0x82, B = 0x9E, A = 0xFF } }
};
private readonly Dictionary<EasterEggState, byte> easterEggKeyProgression = new()
{
{ EasterEggState.Normal, 0 },
{ EasterEggState.Tolly, 0 },
{ EasterEggState.Fin, 0 },
{ EasterEggState.Riley, 0 },
{ EasterEggState.Tom, 0 }
};
private EasterEggState currentEasterEggState = EasterEggState.Normal;

// Used to calculate CPS and prevent autoclicker usage
private DateTime lastClickTime = DateTime.MinValue;
private int clicksThisSecond = 0;
Expand Down Expand Up @@ -258,8 +373,11 @@ private void UpdateSpecialProgress(bool doAnimation)
private async void InitiateSpecial()
{
isSpecialActive = true;
ImageSource regularSource = imageCandy.Source;
imageCandy.Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/Images/candy-special.png"));
ImageSource regularSource = new BitmapImage(new Uri("pack://application:,,,/Images/candy.png"));
if (currentEasterEggState == EasterEggState.Normal)
{
imageCandy.Source = new BitmapImage(new Uri("pack://application:,,,/Images/candy-special.png"));
}
textBlockSpecial.Visibility = Visibility.Visible;
rectangleBonusProgress.Fill = textBlockSpecial.Foreground;

Expand All @@ -278,11 +396,14 @@ private async void InitiateSpecial()
sb.Children.Add(changeWidth);
sb.Begin();

await System.Threading.Tasks.Task.Delay(5000);
await Task.Delay(5000);

rectangleBonusProgress.Fill = textBlockScore.Foreground;
textBlockSpecial.Visibility = Visibility.Hidden;
imageCandy.Source = regularSource;
if (currentEasterEggState == EasterEggState.Normal)
{
imageCandy.Source = regularSource;
}
clicksTowardSpecial = 0;
isSpecialActive = false;
}
Expand All @@ -292,7 +413,7 @@ private void EndGameVisualUpdate()
isEndGameVisualActive = true;
_ = flowDocumentCandiesPerSecond.Blocks.Remove(paragraphCandiesPerSecond);
flowDocumentCandiesPerSecond.Blocks.Add(paragraphEndGamePerSecond);
Icon = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/Icons/candy_special_dzI_icon.ico"));
Icon = new BitmapImage(new Uri("pack://application:,,,/Icons/candy_special_dzI_icon.ico"));
Storyboard sb = new()
{
Duration = new Duration(TimeSpan.FromSeconds(0.25))
Expand All @@ -301,17 +422,11 @@ private void EndGameVisualUpdate()
ColorAnimation fadeToGold = new()
{
From = ((SolidColorBrush)Background).Color,
To = new Color()
{
R = 0xE5,
G = 0xF1,
B = 0x9E,
A = 0xFF
},
To = new Color() { R = 0xE5, G = 0xF1, B = 0x9E, A = 0xFF },
Duration = sb.Duration
};
Storyboard.SetTarget(fadeToGold, windowCandyClicker);
Storyboard.SetTargetProperty(fadeToGold, new PropertyPath("(Button.Background).(SolidColorBrush.Color)"));
Storyboard.SetTargetProperty(fadeToGold, new PropertyPath("(Window.Background).(SolidColorBrush.Color)"));
sb.Children.Add(fadeToGold);

sb.Begin();
Expand All @@ -322,7 +437,7 @@ private void UndoEndGameVisualUpdate()
isEndGameVisualActive = false;
_ = flowDocumentCandiesPerSecond.Blocks.Remove(paragraphEndGamePerSecond);
flowDocumentCandiesPerSecond.Blocks.Add(paragraphCandiesPerSecond);
Icon = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/Icons/candy_xnp_icon.ico"));
Icon = new BitmapImage(new Uri("pack://application:,,,/Icons/candy_xnp_icon.ico"));
Storyboard sb = new()
{
Duration = new Duration(TimeSpan.FromSeconds(0.25))
Expand All @@ -331,17 +446,11 @@ private void UndoEndGameVisualUpdate()
ColorAnimation fadeToGold = new()
{
From = ((SolidColorBrush)Background).Color,
To = new Color()
{
R = 0x86,
G = 0xF1,
B = 0xE6,
A = 0xFF
},
To = new Color() { R = 0x86, G = 0xF1, B = 0xE6, A = 0xFF },
Duration = sb.Duration
};
Storyboard.SetTarget(fadeToGold, windowCandyClicker);
Storyboard.SetTargetProperty(fadeToGold, new PropertyPath("(Button.Background).(SolidColorBrush.Color)"));
Storyboard.SetTargetProperty(fadeToGold, new PropertyPath("(Window.Background).(SolidColorBrush.Color)"));
sb.Children.Add(fadeToGold);

sb.Begin();
Expand Down Expand Up @@ -396,6 +505,19 @@ private void CloseHelpPopUp()
private void OpenCheatPopUp()
{
timerPerSecond.Stop();

textBoxCheatCandies.Text = CandyScore.ToString();
textBoxCheatPerClick.Text = CandyPerClick.ToString();
textBoxCheatPerSecond.Text = CandyPerSecond.ToString();
textBoxCheatPSMultiplier.Text = CandyPSReincarnationMultiplier.ToString();
textBoxCheatReincarnationCount.Text = ReincarnateCounter.ToString();
textBoxCheatOverflowCount.Text = OverflowCounter.ToString();
textBoxCheatSpecialProgress.Text = clicksTowardSpecial.ToString();
checkBoxCheatTaskbarHide.IsChecked = !ShowInTaskbar;
checkBoxCheatDisableSaveChecks.IsChecked = !doSaveIntegrityChecks;
checkBoxCheatDisableAutoclickerCheck.IsChecked = !doAutoClickPrevention;
checkBoxCheatStopCandyRain.IsChecked = !doCandyRain;

gridCheat.Visibility = Visibility.Visible;

Storyboard sb = new()
Expand Down Expand Up @@ -608,6 +730,11 @@ private void ImageCandy_MouseDown(object sender, MouseButtonEventArgs e)
lastClickTime = DateTime.Now;
clicksThisSecond++;

if (!isSpecialActive || currentEasterEggState != EasterEggState.Normal)
{
imageCandy.Source = easterEggImages[currentEasterEggState][rng.Next(easterEggImages[currentEasterEggState].Length)];
}

if (rng.Next(10) == 0)
{
Storyboard sb = new()
Expand Down Expand Up @@ -715,7 +842,7 @@ await Dispatcher.Invoke(async () =>
{
Image rareCandy = new()
{
Source = new System.Windows.Media.Imaging.BitmapImage(new Uri("pack://application:,,,/Images/candy-special.png")),
Source = new BitmapImage(new Uri("pack://application:,,,/Images/candy-special.png")),
Height = 45,
Width = 45,
Stretch = Stretch.Uniform,
Expand Down Expand Up @@ -931,24 +1058,54 @@ private void GridCandyClicker_KeyDown(object sender, KeyEventArgs e)
if (cheatMenuKeyProgression == cheatMenuKeys.Length)
{
cheatMenuKeyProgression = 0;
textBoxCheatCandies.Text = CandyScore.ToString();
textBoxCheatPerClick.Text = CandyPerClick.ToString();
textBoxCheatPerSecond.Text = CandyPerSecond.ToString();
textBoxCheatPSMultiplier.Text = CandyPSReincarnationMultiplier.ToString();
textBoxCheatReincarnationCount.Text = ReincarnateCounter.ToString();
textBoxCheatOverflowCount.Text = OverflowCounter.ToString();
textBoxCheatSpecialProgress.Text = clicksTowardSpecial.ToString();
checkBoxCheatTaskbarHide.IsChecked = !ShowInTaskbar;
checkBoxCheatDisableSaveChecks.IsChecked = !doSaveIntegrityChecks;
checkBoxCheatDisableAutoclickerCheck.IsChecked = !doAutoClickPrevention;
checkBoxCheatStopCandyRain.IsChecked = !doCandyRain;
OpenCheatPopUp();
}
}
else
{
cheatMenuKeyProgression = 0;
}

foreach (EasterEggState state in Enum.GetValues(typeof(EasterEggState)))
{
if (e.Key == easterEggKeys[state][easterEggKeyProgression[state]])
{
easterEggKeyProgression[state]++;
if (easterEggKeyProgression[state] == easterEggKeys[state].Length)
{
easterEggKeyProgression[state] = 0;
currentEasterEggState = state;

Color targetColor = state == EasterEggState.Normal && isEndGameVisualActive
? (new() { R = 0xE5, G = 0xF1, B = 0x9E, A = 0xFF })
: easterEggBackgroundColors[state];

imageCandy.Source = state == EasterEggState.Normal && isSpecialActive
? new BitmapImage(new Uri("pack://application:,,,/Images/candy-special.png"))
: easterEggImages[state][rng.Next(easterEggImages[currentEasterEggState].Length)];
Storyboard sb = new()
{
Duration = new Duration(TimeSpan.FromSeconds(0.25))
};

ColorAnimation backgroundFade = new()
{
From = ((SolidColorBrush)Background).Color,
To = targetColor,
Duration = sb.Duration
};
Storyboard.SetTarget(backgroundFade, windowCandyClicker);
Storyboard.SetTargetProperty(backgroundFade, new PropertyPath("(Window.Background).(SolidColorBrush.Color)"));
sb.Children.Add(backgroundFade);

sb.Begin();
}
}
else
{
easterEggKeyProgression[state] = 0;
}
}
}

private void ButtonCommitCheat_Click(object sender, RoutedEventArgs e)
Expand Down

0 comments on commit 3dee39e

Please sign in to comment.