public bool sendPrivateMsg(string newMessage, string username) { Sfs2X.Entities.User user = CommunicationManager.Inst.FindUser(username); if (user != null) { sendPrivateMsg(newMessage, user); return(true); } return(false); }
public override void Add(Sfs2X.Entities.User user, SFSObject data) { if (_bullets != null) { if (data.ContainsKey(Consts.X) && (data.ContainsKey(Consts.Y) && data.ContainsKey(Consts.GO_ID))) { int objectId = (int)data.GetDouble(Consts.GO_ID); if (!_bullets.ContainsKey(objectId)) { _bullets.Add((int)data.GetDouble(Consts.GO_ID), new Bullet((float)data.GetDouble(Consts.X), (float)data.GetDouble(Consts.Y), (ulong)objectId)); _bullets[objectId].LoadContents(_contents); _s_fire.Play(); } } } base.Add(user, data); }
void ChatWindowFunc(int windowID) { chatHistoryRect = new Rect(20, 25, chatWindowRect.width - chatHistoryBuffer - userListPanelWidth, chatWindowRect.height - 80); userListRect = new Rect(20 + chatHistoryRect.width, 25, userListPanelWidth, chatHistoryRect.height); GUILayout.BeginVertical(); GUILayout.BeginHorizontal(); GUILayout.BeginArea(chatHistoryRect); chatScrollPosition = GUILayout.BeginScrollView(chatScrollPosition, false, false); GUIStyle textStyle = new GUIStyle(GUI.skin.label); textStyle.normal.textColor = Color.white; GUILayout.TextArea(chatHistory, textStyle, GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(false)); GUILayout.EndScrollView(); GUILayout.EndArea(); GUILayout.BeginArea(userListRect); userScrollPosition = GUILayout.BeginScrollView(userScrollPosition, false, false); foreach (Sfs2X.Entities.User u in CommunicationManager.LastJoinedRoom.UserList) { if (u == CommunicationManager.MySelf) { continue; } if (GUILayout.Button(new GUIContent(u.Name, "Click to chat privately with " + u.Name))) { chatTo = u.Name; lastSelectedUser = CommunicationManager.UserManager.GetUserByName(u.Name); } } GUILayout.EndScrollView(); GUILayout.EndArea(); GUILayout.EndHorizontal(); // Send chat message text field and button GUILayout.BeginArea(new Rect(gutter, chatWindowRect.height - chatHistoryBuffer, chatWindowRect.width - 20, chatHistoryBuffer)); GUILayout.BeginHorizontal(); if (GUILayout.Button(chatTo)) { if (lastSelectedUser == null || chatTo == lastSelectedUser.Name) { chatTo = "Public"; } else { chatTo = lastSelectedUser.Name; } } GUI.SetNextControlName("ChatInput"); newMessage = GUILayout.TextField(newMessage, 146, GUILayout.Width(chatWindowRect.width - 80)); if (GUI.GetNameOfFocusedControl() == "ChatInput" && Event.current.type == EventType.keyUp && Event.current.keyCode == KeyCode.Return) { if (chatTo == "Public") { ChatManager.Inst.sendPublicMsg(newMessage); } else { ChatManager.Inst.sendPrivateMsg(newMessage, lastSelectedUser); } newMessage = ""; } if (setFocusOnInput > 0) { GUI.FocusControl("ChatInput"); setFocusOnInput--; } GUILayout.EndHorizontal(); GUILayout.EndArea(); GUILayout.EndVertical(); chatWindowRect = ResizeGUIWindow.ResizeWindow(chatWindowRect); GUI.DragWindow(); }