public void Send() { ConsoleKeyInfo message = new ConsoleKeyInfo(); try { NetworkStream n = client.GetStream(); while ((message.Key != ConsoleKey.Q) && (message.Key != ConsoleKey.Escape)) { message = Console.ReadKey(); if (message.Key.ToString().Equals("Spacebar") || message.Key.ToString().Equals("Z")) { SoundPlayer player = new SoundPlayer(); player.SoundLocation = AppDomain.CurrentDomain.BaseDirectory + "\\sword-gesture1.wav"; player.Play(); } BinaryWriter w = new BinaryWriter(n); ActionProtocol ap = new ActionProtocol(name, message.Key.ToString()); string json = JsonConvert.SerializeObject(ap); w.Write(json); w.Flush(); } client.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private static Player CreateNewPlayer(ActionProtocol ap) { Player newPlayer = new Player(ap.UserName); newPlayer.Location = new Location(1, 1); game.Players.Add(newPlayer); game.GameBoard.AddPlayerToRoom(newPlayer); return(newPlayer); }
public PlayerAction(ActionProtocol protocol) { action = protocol.Type; obj = new DirectObject(protocol.Target); }