// sets both icons to false on close void CloseIcons() { onR = false; onZ = false; SendInfo?.Invoke(""); }
/// <summary> /// The function sends a log command to the server. /// </summary> public void SendToServer() { string[] args = { }; CommandRecievedEventArgs e = new CommandRecievedEventArgs((int)CommandEnum.LogCommand, args, "Empty"); SendInfo?.Invoke(this, e); }
public void Communicate() { if (cSocket != null) { //Console.WriteLine("Начало общения..."); SendInfo?.Invoke("Начало общения..."); while (true) { String d = ReceiveData(); Parse(d); } } }
/// <summary> /// A generic send to server function. we send a command and an item. /// </summary> /// <param name="commandEnum">The type of command we send</param> /// <param name="item">The path of the handler. If we don't pick any specific handler this will be "Empty" string.</param> public void SendCommandToServer(CommandEnum commandEnum, string item) { string[] args = { }; // we remove a specific handler // if item is not an empty string we initialize args[0] as item, and send it as args. if (!item.Equals("")) { args = new string[1]; args[0] = item; CommandRecievedEventArgs e = new CommandRecievedEventArgs((int)commandEnum, args, item); SendInfo?.Invoke(this, e); } else // we receive info from the server { CommandRecievedEventArgs e = new CommandRecievedEventArgs((int)commandEnum, args, "Empty"); SendInfo?.Invoke(this, e); } }
public String ReceiveData() { String res = ""; if (cSocket != null) { var b = new byte[65536]; //Console.WriteLine("Ожидание данных..."); SendInfo?.Invoke("Ожидание данных..."); var i = 0; do { var cnt = cSocket.Receive(b); //Console.WriteLine("Получена порция данных №{0}", ++i); var r = Encoding.UTF8.GetString(b, 0, cnt); res += r; } while (res[res.Length - 1] != '\n'); //Console.WriteLine("Данные успешно получены"); SendInfo?.Invoke("Данные успешно получены"); } return(res.Trim()); }
// sends the appropriate action command for each possible Z placement void DetermineZAction() { string infoToSend = ""; if (menuRotation.CurrentMenu == "item") { infoToSend = "To Equipment"; } else if (menuRotation.CurrentMenu == "equip") { infoToSend = "To Quest Status"; } else if (menuRotation.CurrentMenu == "quest") { infoToSend = "To Map"; } else if (menuRotation.CurrentMenu == "map") { infoToSend = "To Select Item"; } SendInfo?.Invoke(infoToSend); }
// manages player inputs on the icons when active void IconControl(float xInput) { if (onZ || onR) { // if the cursor is moving in the direction of either icon, rotates menu, sets changeBool to false so it doesn't automatically select right if (xInput < 0 && onZ) { changeBool = false; menuRotation.StartRotation(Vector3.up); } else if (xInput > 0 && onR) { changeBool = false; menuRotation.StartRotation(-Vector3.up); } // if the cursor moves inward on the item screen, activates item cursor else if (menuRotation.CurrentMenu == "item") { SendInfo?.Invoke(""); cursor.ShowCursor(xInput); moveAudio.Play(); HideIcons(); CloseIcons(); } // if the cursor moves inward on another screen, activates opposite cursor, sets changeBool to shift to right else if (menuRotation.CurrentMenu != "item") { changeBool = false; ActivateOppositeIcon(); moveAudio.Play(); } } }
public void SendData(String command, String data) { if (cSocket != null) { try { if (data.Trim().Equals("") || command.Trim().Equals("")) { return; } var b = Encoding.UTF8.GetBytes(command + "=" + data + "\n"); //Console.WriteLine("Отправка сообщения..."); SendInfo?.Invoke("Отправка сообщения..."); cSocket.Send(b); //Console.WriteLine("Сообщение успешно отправлено!"); } catch (Exception ex) { //Console.WriteLine("Не удалось отправить сообщение :("); SendInfo?.Invoke("Не удалось отправить сообщение :("); } } }