private void Form1_KeyUp(object sender, KeyEventArgs e) { ActionParams ap = new ActionParams(); ap.A = e.KeyData == Keys.A; ap.D = e.KeyData == Keys.D; ap.L = e.KeyData == Keys.L; ap.J = e.KeyData == Keys.J; ap.N = e.KeyData == Keys.N; }
private void Form1_KeyPress(object sender, KeyPressEventArgs e) { ActionParams ap = new ActionParams(); ap.A = e.KeyChar == 'a'; ap.D = e.KeyChar == 'd'; ap.J = e.KeyChar == 'j'; ap.L = e.KeyChar == 'l'; ap.N = e.KeyChar == 'n'; string key = e.KeyChar.ToString(); GameClient.Client(key); }
public static void Server() { TcpListener listener = new TcpListener(IPAddress.Any, 51111); listener.Start(); using (TcpClient c = listener.AcceptTcpClient()) using (NetworkStream n = c.GetStream()) { string msg = new BinaryReader(n).ReadString(); if (msg == "a" || msg == "A") { ActionParams ap = new ActionParams(); ap.A = true; ap.D = false; ap.J = false; ap.L = false; ap.N = false; GameController.KeyDown(ap); } else if (msg == "d" || msg == "D") { ActionParams ap = new ActionParams(); ap.A = false; ap.D = true; ap.J = false; ap.L = false; ap.N = false; GameController.KeyDown(ap); } } listener.Stop(); }
private void Form1_KeyPress(object sender, KeyPressEventArgs e) { ActionParams ap = new ActionParams(); ap.A = e.KeyChar == 'a'; ap.D = e.KeyChar == 'd'; ap.J = e.KeyChar == 'j'; ap.L = e.KeyChar == 'l'; ap.N = e.KeyChar == 'n'; gameArea.KeyDown(ap); }
public void KeyUp(ActionParams actions) { int count = gameObjects.Count; for (int i = 0; i < count; ++i) { if (gameObjects[i] is PlayerVehicle) { (gameObjects[i] as PlayerVehicle).KeyUp(actions); } } }
public void KeyUp(ActionParams actions) { if (actions.A) { left = false; } if (actions.D) { right = false; } if (actions.L) { driveForward = false; } if (actions.J) { driveBackward = false; } if (actions.N) { shoot = false; } }
public void KeyDown(ActionParams actions) { if (actions.A) { left = true; } if (actions.D) { right = true; } if (actions.L) { driveForward = true; } if (actions.J) { driveBackward = true; } if (actions.N) { shoot = true; } }