Skip to content
Snippets Groups Projects
Commit 032fef18 authored by bionic85's avatar bionic85
Browse files

added secret konami code for cheating money, also added theme buy logic.

Need to rewrite how the bought themes are stored. Because currently it is in an embedded resource. But you can unfortunatly not edit them so I need to find an other way
parent 8d30c1e4
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,9 @@
<setting name="Money" serializeAs="String">
<value>100</value>
</setting>
<setting name="UnlockedThemes" serializeAs="String">
<value>TrueTrueTrueFalseFalseFalseFalseFalseFalseFalseFalseFalseFalse</value>
</setting>
</PuzzlePlayer_Namespace.Properties.Settings>
</userSettings>
</configuration>
\ No newline at end of file
......@@ -58,5 +58,17 @@ namespace PuzzlePlayer_Namespace.Properties {
this["Money"] = value;
}
}
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("TrueTrueTrueFalseFalseFalseFalseFalseFalseFalseFalseFalseFalse")]
public string UnlockedThemes {
get {
return ((string)(this["UnlockedThemes"]));
}
set {
this["UnlockedThemes"] = value;
}
}
}
}
......@@ -11,5 +11,8 @@
<Setting Name="Money" Type="System.Int32" Scope="User">
<Value Profile="(Default)">100</Value>
</Setting>
<Setting Name="UnlockedThemes" Type="System.String" Scope="User">
<Value Profile="(Default)">TrueTrueTrueFalseFalseFalseFalseFalseFalseFalseFalseFalseFalse</Value>
</Setting>
</Settings>
</SettingsFile>
\ No newline at end of file
......@@ -5,9 +5,9 @@ THEME|Forest|34|139|34|46|87|35|85|107|47|False
THEME|Ocean|28|107|160|41|128|185|59|172|230|False
THEME|Sunset|255|94|77|255|154|94|255|203|164|False
THEME|Lavender|153|102|204|191|150|233|229|204|255|False
THEME|Amber|255|191|0|255|204|51|255|230|102|False
THEME|Ice|173|216|230|200|229|255|240|248|255|False
THEME|Midnight|25|25|112|0|0|139|72|61|139|False
THEME|Earth|102|51|0|139|69|19|160|82|45|False
THEME|Rosewood|101|67|33|139|76|57|165|105|79|False
THEME|Aurora|58|12|163|32|178|170|127|255|212|False
THEME|RICHBOI|255|191|0|255|204|51|255|230|102|False
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.Eventing.Reader;
using System.Drawing;
using System.Linq;
using System.Text;
......@@ -13,6 +14,8 @@ namespace PuzzlePlayer_Namespace.Resources
{
Label moneyLabel;
const int BUTTONSIZE = 300;
string KonamiCode = "UpUpDownDownLeftRightLeftRightBA";
string KonamiBuffer = "";
public ShopMenu()
{
ClientSize = new Size(BUTTONSIZE*4 + 41, 800); // magic numbers dw
......@@ -22,6 +25,10 @@ namespace PuzzlePlayer_Namespace.Resources
Theme currentTheme = UserDataManager.Theme;
BackColor = currentTheme.primaryColor;
SetupUI();
KeyPreview = true;
//KeyPress += SuperSecretKonamiCodeDetector; // shhhh this is super secret ↑↑↓↓←→←→BA
//KeyDown += SuperSecretKonamiCodeDetector;
}
void SetupUI()
......@@ -33,7 +40,6 @@ namespace PuzzlePlayer_Namespace.Resources
menuStrip.Items.Add("Buy Fonts");
menuStrip.Items.Add("Change Themes/Fonts");
//menuStrip.Text = "Text";
menuStrip.Font = BigFont;
menuStrip.BackColor = UserDataManager.Theme.secondaryColor;
menuStrip.ForeColor = UserDataManager.Theme.tertiaryColor;
......@@ -54,6 +60,9 @@ namespace PuzzlePlayer_Namespace.Resources
buyableThemes.Location = new Point(0, 100);
buyableThemes.Size = new Size(ClientSize.Width, ClientSize.Height - buyableThemes.Location.Y);
buyableThemes.AutoScroll = true;
buyableThemes.GotFocus += (object o, EventArgs ea) => this.Focus();
int themeCost = 100;
foreach (Theme theme in UserDataManager.GetThemes())
{
......@@ -67,7 +76,12 @@ namespace PuzzlePlayer_Namespace.Resources
graphics.FillRectangle(new SolidBrush(theme.tertiaryColor),0, bm.Height / 3*2, bm.Width,bm.Height/3);
Button button = new Button();
button.Text = theme.name;
if(theme.name == "RICHBOI")
button.Text = theme.name + $"\n$69690420";
else
button.Text = theme.name + $"\n${themeCost}";
button.Name = theme.name;
button.Font = BigFont;
button.ForeColor = theme.tertiaryColor;
button.Size = bm.Size;
......@@ -78,6 +92,7 @@ namespace PuzzlePlayer_Namespace.Resources
button.Click += ButtonClick;
buyableThemes.Controls.Add(button);
themeCost += 100;
}
}
......@@ -92,7 +107,7 @@ namespace PuzzlePlayer_Namespace.Resources
foreach(Theme theme in UserDataManager.GetThemes())
{
if(theme.name == button.Text)
if(theme.name == button.Name)
{
BackColor = theme.primaryColor;
MainMenuStrip.BackColor = theme.secondaryColor;
......@@ -111,9 +126,50 @@ namespace PuzzlePlayer_Namespace.Resources
void ButtonClick(object sender, EventArgs e)
{
Button button = (Button)sender;
string[] buttonTextSplit = button.Text.Split("$", StringSplitOptions.TrimEntries);
int themeCost = int.Parse(buttonTextSplit[1]);
string themeName = buttonTextSplit[0];
MessageBox.Show(themeName);
if(UserDataManager.Money < themeCost)
MessageBox.Show($"You dont have enough money!!!\nPlay puzzles or gamble to get more money","You are poor!", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
else
{
DialogResult result = MessageBox.Show($"Do you want to buy the theme: {themeName}?\nIt costs: ${themeCost}", "Buy theme?", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
if (result == DialogResult.Yes)
{
if (UserDataManager.UnlockTheme(themeName))
MessageBox.Show("Theme unlocked!", "Unlocked", MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show("babab");
}
}
moneyLabel.Text = $"Money: ${UserDataManager.Money}";
}
// the Konami code is a cheat code / easter egg used in many old games to activate a cheat or other effects
// We thought it would be funny if the user could use this to gain a lot of money for free
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
{
if (KonamiBuffer.Count() > KonamiCode.Length) // if the user pressed more then 10 keys then the code is invalid
return base.ProcessCmdKey(ref msg, keyData);
KonamiBuffer += keyData; // add the current key to the buffer
if (KonamiBuffer == KonamiCode) // check if the buffer is the same as the code
{
UserDataManager.Money += 9999999; // add money
KonamiBuffer = ""; //reset the buffer
moneyLabel.Text = $"Money: ${UserDataManager.Money}"; // draw new money
}
return base.ProcessCmdKey(ref msg, keyData);
}
}
}
......@@ -55,7 +55,7 @@ namespace PuzzlePlayer_Namespace
static public Font MainFont { get { return GetMainFont(); } }
static public Theme Theme { get { return GetCurrentTheme(); } }
static private List<Theme> allThemes = GetThemes();
static public List<Theme> AllThemes { get { return GetThemes(); } }
private const string themeFilePath = "PuzzlePlayer_Namespace.Resources.Themes.txt";
......@@ -107,7 +107,7 @@ namespace PuzzlePlayer_Namespace
static private Theme GetCurrentTheme()
{
string currentThemeName = Settings.Default.ThemeName;
foreach (Theme t in allThemes)
foreach (Theme t in AllThemes)
{
if (t.unlocked && currentThemeName == t.name)
return t;
......@@ -117,7 +117,7 @@ namespace PuzzlePlayer_Namespace
static public void SetCurrentTheme(string newThemeName)
{
foreach (Theme t in allThemes)
foreach (Theme t in AllThemes)
{
if(t.unlocked && newThemeName == t.name)
{
......@@ -128,23 +128,29 @@ namespace PuzzlePlayer_Namespace
}
}
static public void UnlockTheme(string ThemeToUnlock)
static public bool UnlockTheme(string ThemeToUnlock)
{
bool result = false;
/*
List<Theme> allThemes = AllThemes;
// update the unlockedThemes list
for (int i = 0; i < allThemes.Count; i++)
{
if (allThemes[i].name == ThemeToUnlock)
{
allThemes[i].Unlock();
return;
result = true;
}
}
*/
// write the data back to the file
using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(themeFilePath))
using (StreamWriter writer = new StreamWriter(stream))
foreach(Theme t in allThemes)
writer.WriteLine(t.ToString());
//foreach(Theme t in allThemes)
//writer.WriteLine(t.ToString());
return result;
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment