mirror of
https://github.com/Lendaia/oe-alga-feladatok.git
synced 2026-04-23 12:26:07 +01:00
Add project files.
This commit is contained in:
43
Engine/BillentyuzetKezelo.cs
Normal file
43
Engine/BillentyuzetKezelo.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
namespace OE.ALGA.Engine
|
||||
{
|
||||
public interface IBillentyuLenyomasKezelo
|
||||
{
|
||||
void BillentyuLenyomas(ConsoleKey billentyu);
|
||||
}
|
||||
|
||||
public class BillentyuzetKezelo : IOrajelFogado
|
||||
{
|
||||
private readonly List<IBillentyuLenyomasKezelo> billentyuLenyomasKezelok = new List<IBillentyuLenyomasKezelo>();
|
||||
|
||||
public void BillentyuLenyomasKezeloFelvetele(IBillentyuLenyomasKezelo kezelo)
|
||||
{
|
||||
billentyuLenyomasKezelok.Add(kezelo);
|
||||
}
|
||||
|
||||
public void BillentyuLenyomasKezeloEltavolitasa(IBillentyuLenyomasKezelo kezelo)
|
||||
{
|
||||
billentyuLenyomasKezelok.Remove(kezelo);
|
||||
}
|
||||
|
||||
private readonly Dictionary<ConsoleKey, Action> billentyuAkciok = new Dictionary<ConsoleKey, Action>();
|
||||
|
||||
public void BillentyuAkcioFelvetele(ConsoleKey billentyu, Action akcio)
|
||||
{
|
||||
billentyuAkciok.Add(billentyu, akcio);
|
||||
}
|
||||
|
||||
public void Orajel(int ido)
|
||||
{
|
||||
while (Console.KeyAvailable)
|
||||
{
|
||||
ConsoleKey billentyu = Console.ReadKey(true).Key;
|
||||
foreach (IBillentyuLenyomasKezelo kezelo in billentyuLenyomasKezelok)
|
||||
{
|
||||
kezelo.BillentyuLenyomas(billentyu);
|
||||
}
|
||||
if (billentyuAkciok.TryGetValue(billentyu, out Action? value))
|
||||
value();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user