-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Collections.Generic; | ||
using System.Windows.Forms; | ||
|
||
namespace SharpMCL | ||
{ | ||
public class KonamiSequence | ||
{ | ||
List<Keys> Keys = new List<Keys>{System.Windows.Forms.Keys.Up, System.Windows.Forms.Keys.Up, | ||
System.Windows.Forms.Keys.Down, System.Windows.Forms.Keys.Down, | ||
System.Windows.Forms.Keys.Left, System.Windows.Forms.Keys.Right, | ||
System.Windows.Forms.Keys.Left, System.Windows.Forms.Keys.Right, | ||
System.Windows.Forms.Keys.B, System.Windows.Forms.Keys.A}; | ||
private int mPosition = -1; | ||
|
||
public int Position | ||
{ | ||
get { return mPosition; } | ||
private set { mPosition = value; } | ||
} | ||
|
||
public bool IsCompletedBy(Keys key) | ||
{ | ||
if (Keys[Position + 1] == key) | ||
{ | ||
// move to next | ||
Position++; | ||
} | ||
else if (Position == 1 && key == System.Windows.Forms.Keys.Up) | ||
{ | ||
// stay where we are | ||
} | ||
else if (Keys[0] == key) | ||
{ | ||
// restart at 1st | ||
Position = 0; | ||
} | ||
else | ||
{ | ||
// no match in sequence | ||
Position = -1; | ||
} | ||
if (Position == Keys.Count - 1) | ||
{ | ||
Position = -1; | ||
return true; | ||
} | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters