Fixes, new Level, balancing, removed locking Windows Key in an Attempt to fix the following, bug: crashes randomly (access violation in native code), bug: all Levels are availale without having to be unlocked

This commit is contained in:
CreepyCrafter24 2019-08-01 22:42:35 +02:00
parent fa681f52ff
commit d192d7c808
33 changed files with 1195 additions and 142 deletions

21
1/1.cs
View File

@ -66,9 +66,12 @@ namespace LaptopSimulator2015.Levels
Vector2 invadersPlayer;
uint minigamePrevTime = 0;
bool invadersCanShoot = true;
double speedMod = 5;
public void gameTick(Graphics g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
public void gameTick(Graphics e, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
Graphics g = buffer.Graphics;
try
{
g.Clear(Color.Black);
@ -89,7 +92,7 @@ namespace LaptopSimulator2015.Levels
invadersAliens.Add(new Vector2(minigamePanel.Width, random.Next(minigamePanel.Height - 10)));
for (int i = 0; i < invadersAliens.Count; i++)
{
invadersAliens[i].X -= 1;
invadersAliens[i].X -= 1.2;
if (invadersPlayer.distanceFromSquared(invadersAliens[i]) < 100 | invadersAliens[i].X < 0)
{
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
@ -114,20 +117,25 @@ namespace LaptopSimulator2015.Levels
}
invadersAliens = invadersAliens.Except(aliensToRemove.Distinct()).Distinct().ToList();
invadersBullets = invadersBullets.Except(bulletsToRemove.Distinct()).Distinct().ToList();
speedMod += 0.1;
speedMod = Math.Max(Math.Min(speedMod, 5), 1);
if (Input.IsKeyDown(Keys.W))
invadersPlayer.Y -= 2;
invadersPlayer.Y -= speedMod;
if (Input.IsKeyDown(Keys.A))
invadersPlayer.X -= 2;
invadersPlayer.X -= speedMod;
if (Input.IsKeyDown(Keys.S))
invadersPlayer.Y += 2;
invadersPlayer.Y += speedMod;
if (Input.IsKeyDown(Keys.D))
invadersPlayer.X += 2;
invadersPlayer.X += speedMod;
if (Input.IsKeyDown(Keys.Space) & invadersCanShoot)
{
invadersBullets.Add(new Vector2(invadersPlayer));
invadersCanShoot = false;
speedMod--;
}
}
buffer.Render();
buffer.Dispose();
}
catch (Exception ex) { if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe") throw new Exception(ex.Message); else Console.WriteLine(ex.ToString()); }
}
@ -141,6 +149,7 @@ namespace LaptopSimulator2015.Levels
invadersBullets = new List<Vector2>();
minigamePrevTime = 0;
invadersCanShoot = true;
speedMod = 5;
}
}
}

8
2/2.cs
View File

@ -66,15 +66,17 @@ namespace LaptopSimulator2015.Levels
uint minigamePrevTime = 0;
uint lives = 3;
public void gameTick(Graphics g, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
public void gameTick(Graphics e, Panel minigamePanel, Timer minigameTimer, uint minigameTime)
{
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
Graphics g = buffer.Graphics;
try
{
Random random = new Random();
for (int i = 0; i < enemies.Count; i++)
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
g.DrawString(lives.ToString(), new Font("Tahoma", 7), Brushes.White, new Rectangle(player.toPoint(), new Size(10, 10)));
Random random = new Random();
if (minigameTime != minigamePrevTime)
{
minigamePrevTime = minigameTime;
@ -117,6 +119,8 @@ namespace LaptopSimulator2015.Levels
}
enemies = enemies.Except(enemiesToRemove.Distinct()).Distinct().ToList();
}
buffer.Render();
buffer.Dispose();
}
catch (Exception ex) { if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe") throw new Exception(ex.Message); else Console.WriteLine(ex.ToString()); }
}

175
3/3.cs Normal file

File diff suppressed because one or more lines are too long

60
3/3.csproj Normal file
View File

@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8109040E-9D8D-43E7-A461-83475B2939C9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>_3</RootNamespace>
<AssemblyName>3</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="3.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Base\Base.csproj">
<Project>{9a9561a7-dd5f-43a5-a3f5-a95f35da204d}</Project>
<Name>Base</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>if not exist "$(SolutionDir)tmp" mkdir "$(SolutionDir)tmp"
copy "$(TargetPath)" "$(SolutionDir)tmp"</PostBuildEvent>
</PropertyGroup>
</Project>

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("3")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("3")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("8109040e-9d8d-43e7-a461-83475b2939c9")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -5,6 +5,7 @@ using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Input;
namespace Base
{
@ -13,6 +14,7 @@ namespace Base
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern short GetKeyState(int keyCode);
//public static bool IsKeyDown(Key key) => Keyboard.IsKeyDown(key);
public static bool IsKeyDown(Keys key)
{
try
@ -30,6 +32,10 @@ namespace Base
Console.WriteLine("Invader: IsKeyDown failed:\r\n" + e1.ToString());
return false;
}
/*Enum.TryParse(key.ToString(), out Key k);
if (k == Key.None)
return false;
return IsKeyDown(k);*/
}
}
}

View File

@ -23,5 +23,7 @@ namespace Base
public static float i2f(int input) => input;
public static double i2d(int input) => input;
public static double f2d(float input) => input;
public static double rad2deg(double input) => (360 * input) / (2 * Math.PI);
public static double deg2rad(double input) => ((2 * Math.PI) * input) / 360;
}
}

View File

@ -13,6 +13,7 @@ namespace Base
public static readonly Vector2 Zero = new Vector2(Point.Empty);
double x_unchecked = 0;
double y_unchecked = 0;
public object Tag;
void check()
{
if (!bounds.IsEmpty)
@ -91,10 +92,10 @@ namespace Base
public PointF toPointF() => new PointF(Misc.d2f(X), Misc.d2f(Y));
public double distanceFromSquared(Vector2 other) => Math.Pow(X - other.X, 2) + Math.Pow(Y - other.Y, 2);
public double distanceFrom(Vector2 other) => Math.Sqrt(distanceFromSquared(other));
public void moveInDirection(double angle = 0, double distance = 1)
public void moveInDirection(double radians = 0, double distance = 1)
{
X += Math.Cos(angle) * distance;
Y += Math.Sin(angle) * distance;
X += Math.Cos(radians) * distance;
Y += Math.Sin(radians) * distance;
}
public double getDirection(Vector2 other) => Math.Atan((other.X - X) / (other.Y - Y));

View File

@ -6,6 +6,7 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaptopSimulator2015", "LaptopSimulator2015\LaptopSimulator2015.csproj", "{ADBFC08F-A516-4790-9F9E-FB3000619E2A}"
ProjectSection(ProjectDependencies) = postProject
{0965C803-49B2-4311-B62F-1E60DBD9185F} = {0965C803-49B2-4311-B62F-1E60DBD9185F}
{8109040E-9D8D-43E7-A461-83475B2939C9} = {8109040E-9D8D-43E7-A461-83475B2939C9}
{DFA2FB97-D676-4B0D-B281-2685F85781EE} = {DFA2FB97-D676-4B0D-B281-2685F85781EE}
EndProjectSection
EndProject
@ -25,6 +26,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lv2_t", "lv2_t\lv2_t.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "2", "2\2.csproj", "{0965C803-49B2-4311-B62F-1E60DBD9185F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "lv3_t", "lv3_t\lv3_t.csproj", "{244E68E6-90D2-447D-B380-13CA8DD3D4EC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "3", "3\3.csproj", "{8109040E-9D8D-43E7-A461-83475B2939C9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -59,6 +64,14 @@ Global
{0965C803-49B2-4311-B62F-1E60DBD9185F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0965C803-49B2-4311-B62F-1E60DBD9185F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0965C803-49B2-4311-B62F-1E60DBD9185F}.Release|Any CPU.Build.0 = Release|Any CPU
{244E68E6-90D2-447D-B380-13CA8DD3D4EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{244E68E6-90D2-447D-B380-13CA8DD3D4EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{244E68E6-90D2-447D-B380-13CA8DD3D4EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{244E68E6-90D2-447D-B380-13CA8DD3D4EC}.Release|Any CPU.Build.0 = Release|Any CPU
{8109040E-9D8D-43E7-A461-83475B2939C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8109040E-9D8D-43E7-A461-83475B2939C9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8109040E-9D8D-43E7-A461-83475B2939C9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8109040E-9D8D-43E7-A461-83475B2939C9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -70,6 +83,8 @@ Global
{D80DBBF2-307F-40A0-86F1-871C8DAA394B} = {69DC5824-3F89-4B47-BF1A-F25942094195}
{741EE70E-4CED-40EB-89F2-BD77D41FECED} = {69DC5824-3F89-4B47-BF1A-F25942094195}
{0965C803-49B2-4311-B62F-1E60DBD9185F} = {83BF22F9-3A2D-42A3-9DB0-C1E2AA1DD218}
{244E68E6-90D2-447D-B380-13CA8DD3D4EC} = {69DC5824-3F89-4B47-BF1A-F25942094195}
{8109040E-9D8D-43E7-A461-83475B2939C9} = {83BF22F9-3A2D-42A3-9DB0-C1E2AA1DD218}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {9631F8FF-AFC1-4583-9D27-6C2D97D3A2E9}

View File

@ -17,10 +17,10 @@
<value>False</value>
</setting>
<setting name="subs" serializeAs="String">
<value>False</value>
<value>True</value>
</setting>
<setting name="level" serializeAs="String">
<value>0</value>
<value>1</value>
</setting>
<setting name="lang" serializeAs="String">
<value>(Default)</value>

View File

@ -19,11 +19,11 @@ namespace LaptopSimulator2015
{
components.Dispose();
}
if (ptrHook != IntPtr.Zero)
/*if (ptrHook != IntPtr.Zero)
{
UnhookWindowsHookEx(ptrHook);
ptrHook = IntPtr.Zero;
}
}*/
base.Dispose(disposing);
}
@ -49,7 +49,7 @@ namespace LaptopSimulator2015
this.options_2 = new System.Windows.Forms.Panel();
this.levelWindow = new System.Windows.Forms.Panel();
this.levelWindowC1 = new System.Windows.Forms.Button();
this.levelWindowContents = new LaptopSimulator2015.FakeDesktop.TabControlH();
this.levelWindowContents = new System.Windows.Forms.TabControl();
this.levelWindow1 = new System.Windows.Forms.TabPage();
this.levelWindowText1 = new System.Windows.Forms.Label();
this.levelWindow2 = new System.Windows.Forms.TabPage();
@ -69,6 +69,7 @@ namespace LaptopSimulator2015
this.minigamePanel = new System.Windows.Forms.Panel();
this.minigameClockT = new System.Windows.Forms.Timer(this.components);
this.optionsWindow = new System.Windows.Forms.Panel();
this.optionsWindowReset = new System.Windows.Forms.Button();
this.optionsWindowLang = new System.Windows.Forms.ComboBox();
this.optionsWindowSubs = new System.Windows.Forms.CheckBox();
this.optionsWindowExit = new System.Windows.Forms.Button();
@ -252,24 +253,27 @@ namespace LaptopSimulator2015
//
// levelWindowContents
//
this.levelWindowContents.Appearance = System.Windows.Forms.TabAppearance.Buttons;
this.levelWindowContents.Controls.Add(this.levelWindow1);
this.levelWindowContents.Controls.Add(this.levelWindow2);
this.levelWindowContents.Controls.Add(this.levelWindow3);
this.levelWindowContents.Dock = System.Windows.Forms.DockStyle.Fill;
this.levelWindowContents.ItemSize = new System.Drawing.Size(20, 15);
this.levelWindowContents.Location = new System.Drawing.Point(0, 20);
this.levelWindowContents.Name = "levelWindowContents";
this.levelWindowContents.SelectedIndex = 0;
this.levelWindowContents.Size = new System.Drawing.Size(502, 248);
this.levelWindowContents.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
this.levelWindowContents.TabIndex = 2;
this.levelWindowContents.TabStop = false;
//
// levelWindow1
//
this.levelWindow1.Controls.Add(this.levelWindowText1);
this.levelWindow1.Location = new System.Drawing.Point(4, 22);
this.levelWindow1.Location = new System.Drawing.Point(4, 19);
this.levelWindow1.Name = "levelWindow1";
this.levelWindow1.Padding = new System.Windows.Forms.Padding(3);
this.levelWindow1.Size = new System.Drawing.Size(494, 222);
this.levelWindow1.Size = new System.Drawing.Size(494, 225);
this.levelWindow1.TabIndex = 0;
this.levelWindow1.UseVisualStyleBackColor = true;
//
@ -288,10 +292,10 @@ namespace LaptopSimulator2015
this.levelWindow2.Controls.Add(this.captchaBox);
this.levelWindow2.Controls.Add(this.captchaPanel);
this.levelWindow2.Controls.Add(this.levelWindowText2);
this.levelWindow2.Location = new System.Drawing.Point(4, 22);
this.levelWindow2.Location = new System.Drawing.Point(4, 14);
this.levelWindow2.Name = "levelWindow2";
this.levelWindow2.Padding = new System.Windows.Forms.Padding(3);
this.levelWindow2.Size = new System.Drawing.Size(494, 222);
this.levelWindow2.Size = new System.Drawing.Size(494, 230);
this.levelWindow2.TabIndex = 1;
this.levelWindow2.UseVisualStyleBackColor = true;
//
@ -328,9 +332,9 @@ namespace LaptopSimulator2015
//
this.levelWindow3.Controls.Add(this.levelWindowProgress);
this.levelWindow3.Controls.Add(this.levelWindowText3);
this.levelWindow3.Location = new System.Drawing.Point(4, 22);
this.levelWindow3.Location = new System.Drawing.Point(4, 14);
this.levelWindow3.Name = "levelWindow3";
this.levelWindow3.Size = new System.Drawing.Size(494, 222);
this.levelWindow3.Size = new System.Drawing.Size(494, 230);
this.levelWindow3.TabIndex = 2;
this.levelWindow3.UseVisualStyleBackColor = true;
//
@ -441,6 +445,7 @@ namespace LaptopSimulator2015
// optionsWindow
//
this.optionsWindow.BackColor = System.Drawing.SystemColors.Window;
this.optionsWindow.Controls.Add(this.optionsWindowReset);
this.optionsWindow.Controls.Add(this.optionsWindowLang);
this.optionsWindow.Controls.Add(this.optionsWindowSubs);
this.optionsWindow.Controls.Add(this.optionsWindowExit);
@ -454,6 +459,17 @@ namespace LaptopSimulator2015
this.optionsWindow.TabIndex = 6;
this.optionsWindow.Visible = false;
//
// optionsWindowReset
//
this.optionsWindowReset.BackColor = System.Drawing.Color.Red;
this.optionsWindowReset.Location = new System.Drawing.Point(332, 64);
this.optionsWindowReset.Name = "optionsWindowReset";
this.optionsWindowReset.Size = new System.Drawing.Size(75, 23);
this.optionsWindowReset.TabIndex = 7;
this.optionsWindowReset.Text = "Reset";
this.optionsWindowReset.UseVisualStyleBackColor = false;
this.optionsWindowReset.Click += new System.EventHandler(this.OptionsWindowReset_Click);
//
// optionsWindowLang
//
this.optionsWindowLang.FormattingEnabled = true;
@ -625,7 +641,7 @@ namespace LaptopSimulator2015
private System.Windows.Forms.Label levelWindowTitle;
private System.Windows.Forms.Panel levelWindowIcon;
private System.Windows.Forms.Label levelWindowText1;
private LaptopSimulator2015.FakeDesktop.TabControlH levelWindowContents;
private System.Windows.Forms.TabControl levelWindowContents;
private System.Windows.Forms.TabPage levelWindow1;
private System.Windows.Forms.TabPage levelWindow2;
private System.Windows.Forms.Button levelWindowC1;
@ -656,5 +672,6 @@ namespace LaptopSimulator2015
private System.Windows.Forms.ComboBox optionsWindowLang;
private System.Windows.Forms.Label levelWindowHeaderExit;
private System.Windows.Forms.Label optionsWindowHeaderExit;
private System.Windows.Forms.Button optionsWindowReset;
}
}

View File

@ -3,11 +3,9 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Windows.Forms;
using System.Media;
using System.Runtime.ExceptionServices;
using System.Reflection;
using System.Diagnostics;
using System.IO;
@ -19,16 +17,6 @@ namespace LaptopSimulator2015
#region Base
List<Level> levels = new List<Level>();
bool winShouldClose = false;
class TabControlH : TabControl
{
protected override void WndProc(ref Message m)
{
if (m.Msg == 0x1328 & !DesignMode)
m.Result = (IntPtr)1;
else
base.WndProc(ref m);
}
}
enum Mode
{
@ -65,52 +53,12 @@ namespace LaptopSimulator2015
subsLabel.Visible = optionsWindowSubs.Checked;
if (_mode == Mode.mainMenu)
winMenuStart.Select();
}
}
// Structure contain information about low-level keyboard input event
[StructLayout(LayoutKind.Sequential)]
private struct KBDLLHOOKSTRUCT
{
public Keys key;
public int scanCode;
public int flags;
public int time;
public IntPtr extra;
}
//System level functions to be used for hook and unhook keyboard input
private delegate IntPtr LowLevelKeyboardProc(int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr SetWindowsHookEx(int id, LowLevelKeyboardProc callback, IntPtr hMod, uint dwThreadId);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern bool UnhookWindowsHookEx(IntPtr hook);
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr CallNextHookEx(IntPtr hook, int nCode, IntPtr wp, IntPtr lp);
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
private static extern IntPtr GetModuleHandle(string name);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern short GetAsyncKeyState(Keys key);
//Declaring Global objects
private IntPtr ptrHook;
private LowLevelKeyboardProc objKeyboardProcess;
private IntPtr captureKey(int nCode, IntPtr wp, IntPtr lp)
{
if (nCode >= 0)
{
KBDLLHOOKSTRUCT objKeyInfo = (KBDLLHOOKSTRUCT)Marshal.PtrToStructure(lp, typeof(KBDLLHOOKSTRUCT));
if (objKeyInfo.key == Keys.RWin | objKeyInfo.key == Keys.LWin)
for (int i = 0; i < levels.Count; i++)
{
if (wp == (IntPtr)0x0101)
WinKey_Click(null, null);
return (IntPtr)1;
levels[i].desktopIcon.Visible = levels[i].LevelNumber >= Settings.Default.level;
Console.WriteLine(levels[i].LevelNumber + " - " + _mode.ToString() + ": " + levels[i].desktopIcon.Visible.ToString());
}
}
return CallNextHookEx(ptrHook, nCode, wp, lp);
}
public FakeDesktop()
@ -118,9 +66,8 @@ namespace LaptopSimulator2015
Directory.SetCurrentDirectory(Path.GetDirectoryName(Application.ExecutablePath));
if (!Directory.Exists("Levels"))
Directory.CreateDirectory("Levels");
objKeyboardProcess = new LowLevelKeyboardProc(captureKey);
ptrHook = SetWindowsHookEx(13, objKeyboardProcess, GetModuleHandle(Process.GetCurrentProcess().MainModule.ModuleName), 0);
InitializeComponent();
levelWindowContents.ItemSize = new Size(0, 1);
optionsWindowLang.Text = Settings.Default.lang.Name;
Thread.CurrentThread.CurrentUICulture = Settings.Default.lang;
optionsWindowWam.Value = Settings.Default.wam;
@ -150,27 +97,26 @@ namespace LaptopSimulator2015
for (int i = 0; i < tmp.Count; i++)
{
levels.Add((Level)Activator.CreateInstance(tmp[i]));
levels[i].desktopIcon = new Panel();
Panel tmp1 = new Panel();
Panel tmp2 = new Panel();
tmp1.Size = new Size(50, 50);
tmp1.BackColor = Color.FromArgb(128, 128, 255);
tmp1.Name = "lvl" + i.ToString() + "_1";
tmp1.Visible = i >= Settings.Default.level;
levels[i].desktopIcon.Size = new Size(50, 50);
levels[i].desktopIcon.BackColor = Color.FromArgb(128, 128, 255);
levels[i].desktopIcon.Name = "lvl" + i.ToString() + "_1";
levels[i].desktopIcon.Visible = levels[i].LevelNumber >= Settings.Default.level;
tmp2.BackColor = Color.Blue;
tmp2.BackgroundImageLayout = ImageLayout.Stretch;
tmp2.BackgroundImage = levels[i].installerIcon;
tmp2.Anchor = (AnchorStyles)15;
tmp2.Name = "lvl" + i.ToString() + "_2";
tmp2.Location = new Point(2, 2);
tmp2.Size = new Size(46, 46);
tmp2.Tag = i;
tmp2.DoubleClick += (sender, e) => { level_Start((int)((Panel)sender).Tag); };
tmp1.BackColor = Color.Blue;
tmp1.BackgroundImageLayout = ImageLayout.Stretch;
tmp1.BackgroundImage = levels[i].installerIcon;
tmp1.Anchor = (AnchorStyles)15;
tmp1.Name = "lvl" + i.ToString() + "_2";
tmp1.Location = new Point(2, 2);
tmp1.Size = new Size(46, 46);
tmp1.Tag = i;
tmp1.DoubleClick += (sender, e) => { level_Start((int)((Panel)sender).Tag); };
tmp1.Controls.Add(tmp2);
winDesktop.Controls.Add(tmp1);
levels[i].desktopIcon = tmp1;
levels[i].desktopIcon.Controls.Add(tmp1);
winDesktop.Controls.Add(levels[i].desktopIcon);
}
levels = levels.OrderBy(lv => lv.LevelNumber).ToList();
mode = Mode.mainMenu;
@ -311,14 +257,18 @@ namespace LaptopSimulator2015
break;
case 2:
LevelWindowHeaderExit_Click(sender, e);
if (levelInd == Settings.Default.level)
if (levels[levelInd].LevelNumber >= Settings.Default.level)
{
Settings.Default.level = Math.Min(levels.Count - 1, levelInd);
int closest = int.MaxValue;
for (int i = 0; i < levels.Count; i++)
if (levels[i].LevelNumber < closest & levels[i].LevelNumber > levels[levelInd].LevelNumber)
closest = levels[i].LevelNumber;
if (closest != int.MaxValue)
Settings.Default.level = closest;
Settings.Default.Save();
for (int i = 0; i < levels.Count; i++)
{
levels[i].desktopIcon.Visible = i >= Settings.Default.level;
}
levels[i].desktopIcon.Visible = levels[i].LevelNumber >= Settings.Default.level;
mode = Mode.game;
}
break;
}
@ -384,28 +334,6 @@ namespace LaptopSimulator2015
minigameTime++;
minigamePanel.Invalidate();
}
[DllImport("user32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
private static extern short GetKeyState(int keyCode);
public static bool IsKeyDown(Keys key)
{
try
{
int state = 0;
short retVal = GetKeyState((int)key);
if ((retVal & 0x8000) == 0x8000)
state |= 1;
if ((retVal & 1) == 1)
state |= 2;
return 1 == (state & 1);
}
catch (Exception e1)
{
Console.WriteLine("Invader: IsKeyDown failed:\r\n" + e1.ToString());
return false;
}
}
#endregion
#endregion
@ -530,6 +458,17 @@ namespace LaptopSimulator2015
e.Graphics.FillRectangle(new SolidBrush(rndCol), new RectangleF(Point.Empty, ((Control)sender).Size));
}
}
private void OptionsWindowReset_Click(object sender, EventArgs e)
{
if (MessageBox.Show(strings.resetWarning1, "", MessageBoxButtons.YesNo) == DialogResult.Yes && MessageBox.Show(strings.resetWarning2, "", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
Settings.Default.wam = 0;
Settings.Default.mlg = false;
Settings.Default.subs = true;
Settings.Default.level = 1;
Settings.Default.Save();
}
}
#endregion
}
}

View File

@ -1,6 +1,8 @@
using System;
using System.IO;
#if !DEBUG
using System.Runtime.InteropServices;
#endif
using System.Text;
using System.Threading;
using System.Windows.Forms;

View File

@ -12,7 +12,7 @@ namespace LaptopSimulator2015.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.1.0.0")]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.2.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
@ -49,7 +49,7 @@ namespace LaptopSimulator2015.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("False")]
[global::System.Configuration.DefaultSettingValueAttribute("True")]
public bool subs {
get {
return ((bool)(this["subs"]));
@ -61,7 +61,7 @@ namespace LaptopSimulator2015.Properties {
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("0")]
[global::System.Configuration.DefaultSettingValueAttribute("1")]
public int level {
get {
return ((int)(this["level"]));

View File

@ -9,10 +9,10 @@
<Value Profile="(Default)">False</Value>
</Setting>
<Setting Name="subs" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">False</Value>
<Value Profile="(Default)">True</Value>
</Setting>
<Setting Name="level" Type="System.Int32" Scope="User">
<Value Profile="(Default)">0</Value>
<Value Profile="(Default)">1</Value>
</Setting>
<Setting Name="lang" Type="System.Globalization.CultureInfo" Scope="User">
<Value Profile="(Default)">(Default)</Value>

View File

@ -70,7 +70,7 @@ namespace LaptopSimulator2015 {
}
/// <summary>
/// Looks up a localized string similar to ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.
/// Looks up a localized string similar to ABCDEFGHIJKLMNPQRSTUVWXYZ123456789.
/// </summary>
internal static string captchaLetters {
get {
@ -177,6 +177,24 @@ namespace LaptopSimulator2015 {
}
}
/// <summary>
/// Looks up a localized string similar to Are you sure you want to reset you progress?.
/// </summary>
internal static string resetWarning1 {
get {
return ResourceManager.GetString("resetWarning1", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Are you absolutly sure you want to reset you progress? This is your last chance to turn back!.
/// </summary>
internal static string resetWarning2 {
get {
return ResourceManager.GetString("resetWarning2", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Exit.
/// </summary>

View File

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="captchaLetters" xml:space="preserve">
<value>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</value>
<value>ABCDEFGHIJKLMNPQRSTUVWXYZ123456789</value>
</data>
<data name="consoleError" xml:space="preserve">
<value>Ein Fehler trat auf und die Anwendung wurde beendet. Melden sie dies bitte an den Entwickler.</value>
@ -156,6 +156,12 @@
<data name="ramInstallerWindowText3" xml:space="preserve">
<value>Bitte warten sie...</value>
</data>
<data name="resetWarning1" xml:space="preserve">
<value>Bist du sicher, dass du deinen Fortschritt zurücksetzten möchtest?</value>
</data>
<data name="resetWarning2" xml:space="preserve">
<value>Bist du dir wirklich sicher, dass du deinen Fortschritt zurücksetzten möchtest? Dies ist deine letzte Möglichkeit, dies abzubrechen!</value>
</data>
<data name="winMenuExit1" xml:space="preserve">
<value>Beenden</value>
</data>

View File

@ -118,7 +118,7 @@
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="captchaLetters" xml:space="preserve">
<value>ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789</value>
<value>ABCDEFGHIJKLMNPQRSTUVWXYZ123456789</value>
</data>
<data name="consoleError" xml:space="preserve">
<value>An unhandled Exception occured and the Application was terminated. Please contact the developer.</value>
@ -156,6 +156,12 @@
<data name="ramInstallerWindowText3" xml:space="preserve">
<value>Please wait for the installation to finish...</value>
</data>
<data name="resetWarning1" xml:space="preserve">
<value>Are you sure you want to reset you progress?</value>
</data>
<data name="resetWarning2" xml:space="preserve">
<value>Are you absolutly sure you want to reset you progress? This is your last chance to turn back!</value>
</data>
<data name="winMenuExit1" xml:space="preserve">
<value>Exit</value>
</data>

View File

@ -16,6 +16,7 @@ namespace SIT
Vector2 invadersPlayer;
uint minigameTime = 0;
uint minigamePrevTime = 0;
double speedMod = 5;
bool invadersCanShoot = true;
public MainForm()
{
@ -28,7 +29,8 @@ namespace SIT
private void Panel1_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
Graphics g = buffer.Graphics;
try
{
g.Clear(Color.Black);
@ -49,7 +51,7 @@ namespace SIT
invadersAliens.Add(new Vector2(minigamePanel.Width, random.Next(minigamePanel.Height - 10)));
for (int i = 0; i < invadersAliens.Count; i++)
{
invadersAliens[i].X -= 1;
invadersAliens[i].X -= 1.2;
if (invadersPlayer.distanceFromSquared(invadersAliens[i]) < 100 | invadersAliens[i].X < 0)
{
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
@ -74,20 +76,25 @@ namespace SIT
}
invadersAliens = invadersAliens.Except(aliensToRemove.Distinct()).Distinct().ToList();
invadersBullets = invadersBullets.Except(bulletsToRemove.Distinct()).Distinct().ToList();
speedMod += 0.1;
speedMod = Math.Max(Math.Min(speedMod, 5), 1);
if (Input.IsKeyDown(Keys.W))
invadersPlayer.Y -= 2;
invadersPlayer.Y -= speedMod;
if (Input.IsKeyDown(Keys.A))
invadersPlayer.X -= 2;
invadersPlayer.X -= speedMod;
if (Input.IsKeyDown(Keys.S))
invadersPlayer.Y += 2;
invadersPlayer.Y += speedMod;
if (Input.IsKeyDown(Keys.D))
invadersPlayer.X += 2;
invadersPlayer.X += speedMod;
if (Input.IsKeyDown(Keys.Space) & invadersCanShoot)
{
invadersBullets.Add(new Vector2(invadersPlayer));
invadersCanShoot = false;
speedMod--;
}
}
buffer.Render();
buffer.Dispose();
}
catch (Exception ex) {
if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe")
@ -100,6 +107,8 @@ namespace SIT
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
buffer.Render();
buffer.Dispose();
}
else
#if DEBUG

View File

@ -44,7 +44,6 @@
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">

View File

@ -37,14 +37,15 @@ namespace lv2_t
int lives = 3;
private void MinigamePanel_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
Graphics g = buffer.Graphics;
try
{
Random random = new Random();
for (int i = 0; i < enemies.Count; i++)
g.FillRectangle(new SolidBrush(Color.Red), new Rectangle(enemies[i].toPoint(), new Size(10, 10)));
g.FillRectangle(new SolidBrush(Color.Green), new Rectangle(player.toPoint(), new Size(10, 10)));
g.DrawString(lives.ToString(), new Font("Tahoma", 7), Brushes.White, new Rectangle(player.toPoint(), new Size(10, 10)));
Random random = new Random();
if (minigameTime != minigamePrevTime)
{
minigamePrevTime = minigameTime;
@ -87,6 +88,8 @@ namespace lv2_t
}
enemies = enemies.Except(enemiesToRemove.Distinct()).Distinct().ToList();
}
buffer.Render();
buffer.Dispose();
}
catch (Exception ex)
{
@ -100,6 +103,7 @@ namespace lv2_t
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
buffer.Render();
}
else
#if DEBUG

6
lv3_t/App.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
</startup>
</configuration>

93
lv3_t/MainForm.Designer.cs generated Normal file
View File

@ -0,0 +1,93 @@
namespace lv3_t
{
partial class MainForm
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.components = new System.ComponentModel.Container();
this.button1 = new System.Windows.Forms.Button();
this.minigamePanel = new System.Windows.Forms.Panel();
this.minigameClockT = new System.Windows.Forms.Timer(this.components);
this.minigamePanel.SuspendLayout();
this.SuspendLayout();
//
// button1
//
this.button1.Location = new System.Drawing.Point(777, 0);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(23, 23);
this.button1.TabIndex = 0;
this.button1.TabStop = false;
this.button1.Text = "X";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.Button1_Click);
//
// minigamePanel
//
this.minigamePanel.BackColor = System.Drawing.Color.Black;
this.minigamePanel.Controls.Add(this.button1);
this.minigamePanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.minigamePanel.Location = new System.Drawing.Point(0, 0);
this.minigamePanel.Name = "minigamePanel";
this.minigamePanel.Size = new System.Drawing.Size(800, 450);
this.minigamePanel.TabIndex = 1;
this.minigamePanel.Paint += new System.Windows.Forms.PaintEventHandler(this.MinigamePanel_Paint);
//
// minigameClockT
//
this.minigameClockT.Enabled = true;
this.minigameClockT.Interval = 17;
this.minigameClockT.Tick += new System.EventHandler(this.MinigameClockT_Tick);
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.ControlBox = false;
this.Controls.Add(this.minigamePanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "MainForm";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "Form1";
this.minigamePanel.ResumeLayout(false);
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel minigamePanel;
private System.Windows.Forms.Timer minigameClockT;
}
}

152
lv3_t/MainForm.cs Normal file
View File

@ -0,0 +1,152 @@
using Base;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace lv3_t
{
public partial class MainForm : Form
{
#region FRMBD
uint minigameTime = 0;
uint minigamePrevTime = 0;
public MainForm()
{
InitializeComponent();
cannon = center;
targ = center;
}
private void Button1_Click(object sender, EventArgs e) => Application.Exit();
private void MinigameClockT_Tick(object sender, EventArgs e)
{
minigameTime++;
minigamePanel.Invalidate();
}
#endregion
Vector2 center => new Vector2(minigamePanel.Width / 2, minigamePanel.Height / 2);
Vector2 cannon;
Vector2 targ;
List<Vector2> targets = new List<Vector2>();
Rectangle player => new Rectangle(center.toPoint().X - 5, center.toPoint().Y - 5, 10, 10);
double playerRot = 0;
double cannonL = 30;
double power = 10;
bool firing = false;
uint lastTarget = 0;
private void MinigamePanel_Paint(object sender, PaintEventArgs e)
{
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
Graphics g = buffer.Graphics;
try
{
g.Clear(Color.Black);
g.FillRectangle(new SolidBrush(Color.Green), player);
g.DrawLine(new Pen(new SolidBrush(Color.Green), 5), center.toPoint(), cannon.toPoint());
for (int i = 0; i < targets.Count; i++)
{
g.DrawEllipse(new Pen(new SolidBrush(Color.Red), 6), new RectangleF(Misc.d2f(targets[i].X - 10), Misc.d2f(targets[i].Y - 10), 20, 20));
g.DrawEllipse(new Pen(new SolidBrush(Color.White), 6), new RectangleF(Misc.d2f(targets[i].X - 7), Misc.d2f(targets[i].Y - 7), 14, 14));
g.FillEllipse(new SolidBrush(Color.Red), new RectangleF(Misc.d2f(targets[i].X - 3), Misc.d2f(targets[i].Y - 3), 6, 6));
g.DrawLine(new Pen(new SolidBrush(Color.Gray), 3), Misc.d2f(targets[i].X - 13), Misc.d2f(targets[i].Y - 15), Misc.d2f(targets[i].X + 13), Misc.d2f(targets[i].Y - 15));
g.DrawLine(new Pen(new SolidBrush(Color.Red), 3), Misc.d2f(targets[i].X - 13), Misc.d2f(targets[i].Y - 15), Misc.d2f(targets[i].X + ((((double)targets[i].Tag) * 0.2) - 12.9) + 0.1), Misc.d2f(targets[i].Y - 15));
}
if (firing)
{
g.DrawRectangle(new Pen(new SolidBrush(Color.Green), 1), new Rectangle(Misc.d2i(targ.X - power / 2), Misc.d2i(targ.Y - power / 2), Misc.d2i(power), Misc.d2i(power)));
g.DrawLine(new Pen(new SolidBrush(Color.Green), 1), new PointF(Misc.d2i(targ.X), Misc.d2i(targ.Y - power / 2)), new PointF(Misc.d2i(targ.X), Misc.d2i(targ.Y + power / 2)));
g.DrawLine(new Pen(new SolidBrush(Color.Green), 1), new PointF(Misc.d2i(targ.X - power / 2), Misc.d2i(targ.Y)), new PointF(Misc.d2i(targ.X + power / 2), Misc.d2i(targ.Y)));
}
else
{
g.FillRectangle(new SolidBrush(Color.Green), new RectangleF(Misc.d2f(targ.X - 2.5f), Misc.d2f(targ.Y - 2.5f), 5, 5));
}
Random random = new Random();
if (minigameTime != minigamePrevTime)
{
minigamePrevTime = minigameTime;
if (minigameTime - lastTarget > 90 + 40 / (minigameTime / 100 + 1))
{
targets.Add(new Vector2(random.Next(minigamePanel.Height + 25) + (minigamePanel.Width - minigamePanel.Height - 50) / 2, random.Next(minigamePanel.Height)));
targets[targets.Count - 1].Tag = (double)130;
lastTarget = minigameTime;
}
cannon = new Vector2(center);
cannon.moveInDirection(Misc.deg2rad(playerRot), 20);
if (Input.IsKeyDown(Keys.Space))
{
firing = true;
power = Math.Min(power + 5, 100);
}
else
if (firing)
{
firing = false;
List<Vector2> targetsToRemove = new List<Vector2>();
for (int i = 0; i < targets.Count; i++)
{
if (targets[i].distanceFromSquared(targ) <= Math.Pow(power + 10, 2))
targetsToRemove.Add(targets[i]);
}
targets = targets.Except(targetsToRemove.Distinct()).Distinct().ToList();
g.FillRectangle(new SolidBrush(Color.White), new Rectangle(Misc.d2i(targ.X - power / 2), Misc.d2i(targ.Y - power / 2), Misc.d2i(power), Misc.d2i(power)));
power = 10;
}
targ = new Vector2(center);
targ.Tag = playerRot;
if (Input.IsKeyDown(Keys.W))
cannonL += 100 / power;
if (Input.IsKeyDown(Keys.S))
cannonL -= 100 / power;
if (Input.IsKeyDown(Keys.D))
playerRot += 80 / power;
if (Input.IsKeyDown(Keys.A))
playerRot -= 80 / power;
while (playerRot > 360)
playerRot -= 360;
while (playerRot < 0)
playerRot += 360;
cannonL = Math.Max(Math.Min(cannonL, minigamePanel.Height / 2), 22.5f);
targ.moveInDirection(Misc.deg2rad((double)targ.Tag), cannonL);
for (int i = 0; i < targets.Count; i++)
{
targets[i].Tag = ((double)targets[i].Tag) - 1;
if ((double)targets[i].Tag <= 0)
throw new Exception("The VM was shut down to prevent damage to your Machine.", new Exception("0717750f-3508-4bc2-841e-f3b077c676fe"));
}
}
buffer.Render();
buffer.Dispose();
}
catch (Exception ex)
{
if (ex.InnerException?.Message == "0717750f-3508-4bc2-841e-f3b077c676fe")
{
minigameClockT.Enabled = false;
g.Clear(Color.Red);
g.SmoothingMode = SmoothingMode.AntiAlias;
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
g.PixelOffsetMode = PixelOffsetMode.HighQuality;
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
buffer.Render();
buffer.Dispose();
}
else
#if DEBUG
throw;
#else
Console.WriteLine(ex.ToString());
#endif
}
}
}
}

123
lv3_t/MainForm.resx Normal file
View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="minigameClockT.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>

22
lv3_t/Program.cs Normal file
View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace lv3_t
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("lv3_t")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("lv3_t")]
[assembly: AssemblyCopyright("Copyright © 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("244e68e6-90d2-447d-b380-13ca8dd3d4ec")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

68
lv3_t/Properties/Resources.Designer.cs generated Normal file
View File

@ -0,0 +1,68 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace lv3_t.Properties
{
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources
{
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources()
{
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager
{
get {
if ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("lv3_t.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture
{
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

29
lv3_t/Properties/Settings.Designer.cs generated Normal file
View File

@ -0,0 +1,29 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace lv3_t.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

89
lv3_t/lv3_t.csproj Normal file
View File

@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{244E68E6-90D2-447D-B380-13CA8DD3D4EC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>lv3_t</RootNamespace>
<AssemblyName>lv3_t</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="MainForm.Designer.cs">
<DependentUpon>MainForm.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Base\Base.csproj">
<Project>{9a9561a7-dd5f-43a5-a3f5-a95f35da204d}</Project>
<Name>Base</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -28,7 +28,8 @@ namespace lv_tst_base
private void MinigamePanel_Paint(object sender, PaintEventArgs e)
{
Graphics g = e.Graphics;
BufferedGraphics buffer = BufferedGraphicsManager.Current.Allocate(e.Graphics, new Rectangle(0, 0, minigamePanel.Width, minigamePanel.Height));
Graphics g = buffer.Graphics;
try
{
g.Clear(Color.Black);
@ -39,6 +40,7 @@ namespace lv_tst_base
minigamePrevTime = minigameTime;
//Game Logic
}
buffer.Render();
}
catch (Exception ex)
{
@ -52,6 +54,7 @@ namespace lv_tst_base
SizeF sLen = g.MeasureString("Lost.", new Font("Tahoma", 20));
RectangleF rectf = new RectangleF(minigamePanel.Width / 2 - sLen.Width / 2, minigamePanel.Height / 2 - sLen.Height / 2, 90, 50);
g.DrawString("Lost.", new Font("Tahoma", 20), Brushes.Black, rectf);
buffer.Render();
}
else
#if DEBUG