private static void SendMessages(Coroner coroner) { var killerPlayer = coroner.KillerSpectator as Player; var killedPlayer = coroner.KilledSpectator as Player; var players = coroner.Game.DataEngine.Players; switch (coroner.DeathType) { default: throw new ApplicationException("Unexpected DeathType " + coroner.DeathType); case Coroner.DeathTypeType.Kill: CreateKillMessage(coroner.KillerSpectator, coroner.DamageInfo.Target.Pos); if (killerPlayer != null) killerPlayer.Messages.Add(new PlayerMessage(coroner.MessageToKiller, PlayerMessage.KILL_COLOR)); if (killedPlayer != null) killedPlayer.Messages.Add(new PlayerMessage(coroner.MessageToCorpse, PlayerMessage.DEATH_COLOR)); break; case Coroner.DeathTypeType.TeamKill: CreateTeamKillMessage(coroner.KillerSpectator, coroner.DamageInfo.Target.Pos); if (killerPlayer != null) killerPlayer.Messages.Add(new PlayerMessage(coroner.MessageToKiller, PlayerMessage.SUICIDE_COLOR)); if (killedPlayer != null) killedPlayer.Messages.Add(new PlayerMessage(coroner.MessageToCorpse, PlayerMessage.DEATH_COLOR)); break; case Coroner.DeathTypeType.Accident: CreateSuicideMessage(coroner.KilledSpectator, coroner.DamageInfo.Target.Pos); if (killedPlayer != null) killedPlayer.Messages.Add(new PlayerMessage(coroner.MessageToCorpse, PlayerMessage.SUICIDE_COLOR)); break; } var bystanderMessage = new PlayerMessage(coroner.MessageToBystander, PlayerMessage.DEFAULT_COLOR); foreach (var plr in coroner.GetBystandingPlayers(players)) plr.Messages.Add(bystanderMessage); if (coroner.SpecialMessage != null) { var specialMessage = new PlayerMessage(coroner.SpecialMessage, PlayerMessage.SPECIAL_KILL_COLOR); foreach (var plr in players) plr.Messages.Add(specialMessage); } }
public void SendPlayerMsg(int idx, int portalIdx = 0) { if (!NetworkClient.active) { return; } PlayerMessage msg = new PlayerMessage { connID = network.connID, targetConnID = idx, pos = players[idx].position, camPos = cameras[idx].transform.position, portalIdx = portalIdx }; network.Send(NSGMsgType.Player, msg); }
public static bool ValidateAndModify(PlayerMessage playerMessage) { if (playerMessage.Text == null) { return(false); } playerMessage.Text = playerMessage.Text.Trim(); if (playerMessage.Text.Length == 0) { return(false); } return(true); }
private void UpdateLobby(PlayerMessage pMsg, int i) { //Check for duplicate (i.e. leaving player) foreach (var player in matchLobby) { if (player.playerName == pMsg.playerName) { matchLobby.Remove(player); Debug.Log("Player Removed!: " + pMsg.playerName); return; } } //No Player Found Debug.Log("Player Added!:" + pMsg.playerName); pMsg.serverID = m_Connections[i].InternalId; matchLobby.Add(pMsg); }
public void AddHero_ThenRemoveHim_ThenUndoIt_ResultsInAddedHero_Test() { // Arrange var quest = QuestFactory.CreateStored(out var gameStore, out var gameId); var addBonnie = PlayerMessage.CreateAdd(1, new[] { bonnie }); var removeBonnie = PlayerMessage.CreateRemove(2, new[] { bonnie }); // Act quest.AddMessage(gameId, addBonnie); quest.AddMessage(gameId, removeBonnie); var game = quest.Undo(gameId); // Assert Assert.Single(game.Score.Heroes); Assert.Equal(bonnie.Name, game.Score.Heroes.First().Player.Name); Assert.Equal(bonnie.Gender, game.Score.Heroes.First().Player.Gender); }
//Display player responses with a delay between each message. IEnumerator PlayerTalk(PlayerMessage[] messages) { pButton.onClick.RemoveAllListeners(); //Remove the StartPlayerTalk listener and replace with OptionSelected. pButton.onClick.AddListener(OptionSelected); //OptionSelected will tell textmanager what option player has selected. foreach (PlayerMessage message in messages) //Loop through player messages. { pButton.interactable = false; //Set button to not clickable so that it can't be clicked while scrolling. StartCoroutine(ScrollPlayerOptions(playerText.gameObject, message.getText())); //Scroll player options. currPlayerOption = message; //Store current message in order to tell NPC what was selected. yield return(new WaitForSeconds(textDelay)); //This delays displaying the next player text. if (message == messages[messages.Length - 1]) //If it has been two seconds and current message is last player option. { OptionSelected(); //Select current option. } } }
public INetworkMessage ReadJoingingAreaMessage(DataStreamReader reader, Message message) { switch (message.messageType) { // Read a NewPlayer message. case MessageType.NewPlayer: var newPlayerMessage = new NewPlayerMessage(message.id); newPlayerMessage.Deserialize(ref reader); return(newPlayerMessage); // Set your playedID and playerInfo. case MessageType.Welcome: var welcomeMessage = new WelcomeMessage(message.id); welcomeMessage.Deserialize(ref reader); playerID = welcomeMessage.playerID; playerInfo.color = welcomeMessage.color; Send(new SetNameMessage(MessageID.nextID, playerInfo.name)); return(welcomeMessage); // Read a PlayerLeft message. case MessageType.PlayerLeft: var playerLeftMessage = new PlayerMessage(message.id, message.messageType); playerLeftMessage.Deserialize(ref reader); return(playerLeftMessage); // Load Cave Quest and initialize the players stats. case MessageType.StartGame: var startGameMessage = new StartGameMessage(message.id); startGameMessage.Deserialize(ref reader); var caveQuestPlayer = gameObject.AddComponent <CaveQuestPlayer>(); SceneManager.LoadSceneAsync("Cave Quest").completed += (asyncOperation) => { caveQuestPlayer.Initialize(startGameMessage.startHP); }; return(startGameMessage); default: return(null); } }
protected override void MessageReceivedAsync(object sender, MessageReceivedEventArgs e) { object data = new PlayerMessage(); e.GetDeserializedMessage(ref data); var message = data as PlayerMessage; if (message.Type == PlayerMessageType.Join) { OnPlayerJoined(message); App.SessionManager.SendDebugMessage($"{message.PlayerName} joined."); } else if (message.Type == PlayerMessageType.Leave) { App.SessionManager.SendDebugMessage($"{message.PlayerName} left."); OnPlayerLeft(message); } }
void WhatsInTheBox(Transform t) { Box box = t.GetComponent <Box>(); if (box != null) { PlayerMessage.Add($"<color={Colors.ITEM_NAMES}>{box.contents}</color>"); if (t == grabbedItem) { PlayerMessage.Add(dropBoxMessage); } else if (t == lookingAt) { PlayerMessage.Add(pickUpBoxMessage); } } }
private void ReadConnections() { NetworkEvent.Type command; // Read Events. for (int i = 0; i < connections.Length; i++) { var connection = connections[i]; Assert.IsTrue(connection.IsCreated); while ((command = driver.PopEventForConnection(connection, out var reader)) != NetworkEvent.Type.Empty) { switch (command) { case NetworkEvent.Type.Data: var message = new Message(); message.Deserialize(ref reader); readMessage?.Invoke(connection, reader, message); break; // Let the other connections now which player has disconnected. case NetworkEvent.Type.Disconnect: var playerLeftMessage = new PlayerMessage(MessageID.nextID, MessageType.PlayerLeft, connection.InternalId); foreach (var otherConnection in connections) { if (otherConnection == connection) { continue; } Send(otherConnection, playerLeftMessage); } onConnectionDisconnected?.Invoke(connection); connections[i] = default; break; } } } }
private void SendMessageButton_OnClick(object sender, RoutedEventArgs e) { var player = PlayersListView.SelectedItem as Player; if (player == null) { return; } var message = new PlayerMessage { Message = MessageContentTextBox.Text, SenderId = _myId, ReceiverId = player.Id }; _messages.Add(message); _serviceConnector.SendMessage(message.ReceiverId.ToString(), message.Message); MessageContentTextBox.Text = ""; }
public void CmdSynchroniseWorld() { PlayerMessage pm = new PlayerMessage(); //GET THE COMPLETE VERSION OF WORLD ON THE HOST PLAYER WorldSerialization //Debug.Log ("je serialise le monde chez l'host"); GameManager.gm.wd.SerializeWorld(); pm.wd = GameManager.gm.wd.worldData; //(new GameObject ("TEST WORLDATA DEFORE SENDING")).AddComponent<Test> ().wd = pm.wd; //SET THE MESSAGE TYPE TO SYNC THE PLANTS pm.pma = PlayerMessageAction.LoadWorld; //SEND THE MESSAGE base.connectionToClient.Send(1000, pm); }
void SendBattleMessage(PlayerMessage enemy, bool turn, NetworkConnection c) { Assert.IsTrue(c.IsCreated); var bMsg = new BattleMessage(); bMsg.turn = turn; bMsg.enemyID = enemy.connectionID; bMsg.playerName = enemy.playerName; bMsg.pokemonName = enemy.pokemonName; bMsg.hp = enemy.hp; bMsg.Lvl = enemy.Lvl; string message = JsonUtility.ToJson(bMsg); var writer = m_Driver.BeginSend(NetworkPipeline.Null, c); NativeArray <byte> bytes = new NativeArray <byte>(Encoding.ASCII.GetBytes(message), Allocator.Temp); writer.WriteBytes(bytes); m_Driver.EndSend(writer); }
void OnData(DataStreamReader stream, int i) { NativeArray <byte> bytes = new NativeArray <byte>(stream.Length, Allocator.Temp); stream.ReadBytes(bytes); string recMsg = Encoding.ASCII.GetString(bytes.ToArray()); MessageHeader header = JsonUtility.FromJson <MessageHeader>(recMsg); switch (header.type) { case MessageType.PLAYER_MSG: PlayerMessage pMsg = JsonUtility.FromJson <PlayerMessage>(recMsg); Debug.Log("Player message received!: " + pMsg.playerName); UpdateLobby(pMsg, i); break; case MessageType.HEARTBEAT: Debug.Log("Heartbeat received from: " + m_Connections[i].InternalId); break; case MessageType.BATTLE_MSG: BattleMessage bMsg = JsonUtility.FromJson <BattleMessage>(recMsg); Debug.Log("Battle started for: " + bMsg.playerName); AddBattle(bMsg, i); break; case MessageType.MOVE_MSG: Debug.Log("Move received"); SendMove(recMsg, i); break; case MessageType.DISCONNECT: Debug.Log("Disconnection Received"); OnDisconnect(i); break; default: Debug.Log("SERVER ERROR: Unrecognized message received!"); break; } }
/// <summary> /// When a message is received from a player. /// </summary> private async void OnMessageReceived(object sender, IMessageReceivedEventArgs e) { // Deserialize the message object data = new PlayerMessage(); e.GetDeserializedMessage(ref data); var message = data as PlayerMessage; switch (message.Command) { case PlayerMessageType.Answer: await callOnUiThread(() => OnAnswerReceived(message.PlayerName, message.QuestionAnswer)); break; case PlayerMessageType.Leave: await callOnUiThread(() => OnPlayerLeft(message.PlayerName)); break; } }
public void Route(PlayerMessage message) { foreach (ServerModule module in _moduleProvider.Modules) { module.OnMessage(ref message); } Type messageType = message.GetType(); foreach (MessageRoute route in _routes) { if (route.Attribute.MessageType == messageType) { object result = route.Method.DynamicInvoke(message); if (result is PlayerMessage newMessage) { message = newMessage; } } } }
public void AddMessage(PlayerMessage e) { var desc = e.Desc; if (HistoryLog.Count == 0) { var entry = new HistoryEntry(desc); HistoryLog.Add(entry); HistoryRecent.Add(entry); } else { var last = HistoryLog.Last(); if (last._desc.ToString() == desc.ToString()) { last.times++; last.SetScreenTime(); if (HistoryRecent.Any()) { if (HistoryRecent.Last() != last) { HistoryRecent.Remove(last); HistoryRecent.Add(last); } } else { HistoryRecent.Add(last); } } else { var entry = new HistoryEntry(desc); HistoryLog.Add(entry); HistoryRecent.Add(entry); } } }
/// <summary> /// Updates the UI when a player has joined. /// </summary> /// private void OnPlayerJoined(PlayerMessage message, Guid guid) { Guid duplicatePlayerID; if (!_playerToParticipantMap.TryGetValue(message.PlayerName, out duplicatePlayerID)) { _playerToParticipantMap.Add(message.PlayerName, guid); if (PlayerNames.Contains(message.PlayerName)) { message.PlayerName += "."; } PlayerNames.Add(message.PlayerName); SubmittedAnswers.Add(message.PlayerName, new Dictionary <Question, int?>(Questions.Count)); OnPropertyChanged(nameof(PlayerNames)); OnPropertyChanged(nameof(SubmittedAnswers)); } }
void GotClient(NetworkMessage netMsg) { Debug.Log("Got client..."); // send everyone else to the new player. foreach (KeyValuePair <int, BasePlayer> entry in players) { var playerMessage = new PlayerMessage(); playerMessage.id = entry.Value.GetPlayerId(); playerMessage.name = entry.Value.GetName(); playerMessage.ready = entry.Value.ready; playerMessage.role = entry.Value.GetRoleId(); netMsg.conn.Send(CustomNetMsg.Player, playerMessage); } //default anme is player + id, default roleint is 0 players[netMsg.conn.connectionId] = new BasePlayer("Player " + netMsg.conn.connectionId, 0, netMsg.conn.connectionId); //players[netMsg.conn.connectionId].id = netMsg.conn.connectionId; if (lobbyGui != null) { lobbyGui.UpdateUI(players); } // send the new player to everyone else. var idMessage = new IdMessage(); idMessage.id = netMsg.conn.connectionId; NetworkServer.SendToAll(CustomNetMsg.Id, idMessage); // send server dissonance id to the new player. var dissonanceIdMessage = new DissonanceIdMessage(); dissonanceIdMessage.id = 0; dissonanceIdMessage.dissonanceId = UNetDissonance.PlayerName; netMsg.conn.Send(CustomNetMsg.DissonanceId, dissonanceIdMessage); }
// Update is called once per frame void Update() { if (client.isConnected) { float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); /*StringMessage msg = new StringMessage(); * msg.value = h + "|" + v; * client.Send (888, msg);*/ PlayerMessage msg = new PlayerMessage(); msg.position = player.transform.position; msg.lives = mov.lives; msg.holding = mov.holding; msg.completed = mov.completed; msg.forward = vrcamera.TransformDirection(Vector3.forward); msg.right = vrcamera.TransformDirection(Vector3.right); msg.h = h; msg.v = v; //client.Send (MyMsgType.Player, msg); client.Send(888, msg); for (int i = 0; i < cubes.Length; i++) { if (cubes[i] != null) //si no fue destruido { CubeMessage msgc = new CubeMessage(); msgc.numcube = mv[i].numcube; msgc.position = cubes[i].transform.position; client.Send(MsgType.Animation, msgc); } } } }
//------------------------------------------------------------------------------------------------------------------------- //类型转换工具类 public CombatMessage playerSaveToCombat(PlayerMessage play) //玩家数据 转换 战斗场景数据 { CombatMessage mess = new CombatMessage(); mess.UnitData["id"] = 0; mess.UnitData["physical"] = play.hpmax; mess.UnitData["vigor"] = play.mpmax; mess.UnitData["attack"] = play.atk; mess.UnitData["speed"] = play.speed; mess.UnitData["type"] = 0; mess.UnitData["adPat"] = play.adPat; mess.UnitData["apPat"] = play.apPat; mess.UnitData["strike"] = play.strike; mess.UnitData["dodge"] = play.dodge; mess.UnitData["curHp"] = play.hpcur; mess.UnitData["curMp"] = play.mpcur; mess.UnitData["defence"] = play.def; mess.IconName = GameData.Data.PLAYER; mess.IsPlayer = true; mess.NumID = 0; mess.AttackID = 2; mess.SkillData = play.skills; return(mess); }
void SpawnPlayer(object sender, MessageReceivedEventArgs e) { using (Message message = e.GetMessage()) using (DarkRiftReader reader = message.GetReader()) { PlayerMessage playerMessage = reader.ReadSerializable <PlayerMessage>(); Vector3 position = new Vector3(playerMessage.X, 1f, playerMessage.Y); GameObject obj; Inventory inv; // if the message refers to us as a local player, instantiate controllable local player if (playerMessage.ID == client.ID) { obj = Instantiate(localPlayerPrefab, position, Quaternion.identity) as GameObject; obj.GetComponent <Player>().Client = client; inv = obj.GetComponent <Inventory>(); inv.networkID = playerMessage.networkInventoryID; // else instantiate non-controllable network player } else { obj = Instantiate(networkPlayerPrefab, position, Quaternion.identity) as GameObject; inv = obj.GetComponent <Inventory>(); inv.networkID = playerMessage.networkInventoryID; } itemSpawnManager.itemContainerDict.Add(inv.networkID, inv); inv.itemSpawnManager = itemSpawnManager; foreach (Item item in playerMessage.networkInventoryContents) { inv.contents.Add(item); } networkPlayerManager.Add(playerMessage.ID, obj.GetComponent <NetworkPlayer>()); } }
/// <summary> /// Message /// </summary> /// <param name="message"></param> void OnMessage(PlayerMessage message) { this.chat.AddMessage(message.Name, message.Message); }
/// <summary> /// /// </summary> /// <param name="Message"></param> protected override void HandlePlayerMessage(PlayerMessage Message) { base.HandlePlayerMessage(Message); }
public void SendSetupUi(GameObject player) { var msg = new PlayerMessage() { player = player }; var connectionId = player.GetComponent<NetworkIdentity>().connectionToClient.connectionId; NetworkServer.SendToClient(connectionId, MessageTypes.SetupUi, msg); }
/// <summary> /// When a player has been connected to the host. /// </summary> private async void OnParticipantConnected(object sender, ParticipantConnectedEventArgs e) { // A player has joined the game. _participantCommunicationChannels.Add(_manager.CreateCommunicationChannel(e.Id)); PlayerMessage data = new PlayerMessage { PlayerName = e.Message.ToString(), QuestionAnswer = 0, Command = PlayerMessageType.Join }; await callOnUiThread(() => OnPlayerJoined(data, e.Id)); }
public void SetupGameOver(GameObject player) { var gameOver = player.GetComponent<PlayerRespawn>(); gameOver.gameSetup = this; var msg = new PlayerMessage(); msg.player = player; var connectionId = player.GetComponent<NetworkIdentity>().connectionToClient.connectionId; NetworkServer.SendToClient(connectionId, MessageTypes.SetupGameOver, msg); }
public void enqueueMessage(PlayerMessage msg) { this.qmsg.Enqueue(msg); }
void OnPlayerMessage(PlayerMessage message) { Messages.Add(message); }
public void RemoveMessage(PlayerMessage message) { messageList.Remove(message); }
void Update() { if (isServer) { if (GetComponent <Damageable> ().IsDead() && state != ActionState.DEAD) { RpcKillPlayer(); } for (int i = 0; i < messageList.Count; i++) { PlayerMessage m = messageList [i]; if (m.timed) { m.elapsed += Time.deltaTime; m.percent = 1 - (m.elapsed / m.fullTime); } messageList [i] = m; } int index = 0; while (index < messageList.Count) { if (messageList [index].timed && messageList [index].elapsed >= messageList [index].fullTime) { messageList.RemoveAt(index); } else { index++; } } } if (state == ActionState.PAUSED) { canUse = false; canDrop = false; canMelee = false; canSwitch = false; playerActor.canInteract = false; playerMove.canJump = false; playerMove.canMove = false; playerMove.canMoveHead = false; playerMove.canTurnBody = false; } else if (state == ActionState.FREE) { canUse = true; canDrop = true; canMelee = true; canSwitch = true; playerActor.canInteract = true; playerMove.canJump = true; playerMove.canMove = true; playerMove.canMoveHead = true; playerMove.canTurnBody = true; } else if (state == ActionState.ACTING) { canUse = action.canUseItems; canDrop = action.canDrop; canMelee = false; canSwitch = action.canSwitchItems; playerActor.canInteract = action.canInteract; playerMove.canJump = action.canJump; playerMove.canMove = action.canMove; playerMove.canMoveHead = action.canCameraTurn; playerMove.canTurnBody = action.canTurnBody; } else if (state == ActionState.DEAD) { canUse = false; canDrop = false; canMelee = false; canSwitch = false; playerActor.canInteract = false; playerMove.canJump = false; playerMove.canMove = false; playerMove.canMoveHead = false; playerMove.canTurnBody = false; } else if (state == ActionState.COOLDOWN) { cooldownRemain -= Time.deltaTime; if (cooldownRemain <= 0) { state = ActionState.FREE; canUse = true; canDrop = true; canMelee = true; canSwitch = true; playerActor.canInteract = true; playerMove.canJump = true; playerMove.canMove = true; playerMove.canMoveHead = true; playerMove.canTurnBody = true; } else { canUse = false; canDrop = true; canMelee = false; canSwitch = true; playerActor.canInteract = false; playerMove.canJump = true; playerMove.canMove = true; playerMove.canMoveHead = true; playerMove.canTurnBody = true; } } prevState = state; if (isLocalPlayer) { if (Input.GetButton("Interact")) { playerActor.InteractWithObject(); } if (canDrop && Input.GetButton("Drop") && inventory.IsHoldingItem()) { if (inventory.held.GetComponent <Item> ().canDrop) { inventory.DropItem(inventory.items[inventory.selected], inventory.selected); } else { CmdEndAction(1.0f, "Can't drop that"); } } if (canUse && Input.GetButton("Use") && inventory.IsHoldingItem() && !prevHeld) { CmdUse(); } if (canMelee && Input.GetButton("Special1")) { CmdSpecial1(); } if (canMelee && Input.GetButton("Melee")) { attacker.CmdAttemptMeleeAttack(); } if (canSwitch) { if (Input.GetAxis("Mouse ScrollWheel") < 0) { inventory.selected += 1; if (inventory.selected >= inventory.items.Length) { inventory.selected = 0; } } else if (Input.GetAxis("Mouse ScrollWheel") > 0) { inventory.selected -= 1; if (inventory.selected < 0) { inventory.selected = inventory.items.Length - 1; } } } prevHeld = Input.GetButton("Use"); } }
//change panel on client public void OnServerMessageReceived(NetworkMessage msg) { ServerMessage mx = msg.ReadMessage<ServerMessage>(); Debug.Log(string.Format("SERVER: {0}", mx)); switch (mx.currentMode) { case NetworkMode.Level: Debug.Log("OnServerMessageReceived Change levelPanel"); ChangeTo(levelPanel); if (mx.isCreatePlayer) { PlayerMessage pm = new PlayerMessage(); pm.userName = LoginController.userName; ClientScene.AddPlayer(client.connection, 0, pm); hasCreatePlayer = true; } break; case NetworkMode.Lobby: Debug.Log("OnServerMessageReceived Change lobbyPanel"); ChangeTo(lobbyPanel); if (mx.isCreatePlayer) { PlayerMessage pm = new PlayerMessage(); pm.userName = LoginController.userName; ClientScene.AddPlayer(client.connection, 0, pm); hasCreatePlayer = true; } break; case NetworkMode.Game: Debug.Log("OnServerMessageReceived Change Game"); //Application.LoadLevel("Level1"); break; } }
public override void OnClientSceneChanged(NetworkConnection conn) { Debug.Log("OnClientSceneChanged " + conn.connectionId); Debug.Log("SetReady " + conn.isReady); Debug.Log("SetReady2 " + ClientScene.ready); DisableLobbyUI(); //ClientScene.Ready(conn); if (!ClientScene.ready) { Debug.Log("SetReady"); base.OnClientSceneChanged(conn); if (!hasCreatePlayer) { PlayerMessage pm = new PlayerMessage(); pm.userName = LoginController.userName; ClientScene.AddPlayer(client.connection, 0, pm); hasCreatePlayer = true; } } Debug.Log("SetReady " + conn.isReady); Debug.Log("SetReady2 " + ClientScene.ready); //ClientScene.Ready(connetion); }
/// <summary> /// Updates the UI when a player has joined. /// </summary> /// private void OnPlayerJoined(PlayerMessage message, Guid guid) { Guid duplicatePlayerID; if (!_playerToParticipantMap.TryGetValue(message.PlayerName, out duplicatePlayerID)) { _playerToParticipantMap.Add(message.PlayerName, guid); if (PlayerNames.Contains(message.PlayerName)) { message.PlayerName += "."; } PlayerNames.Add(message.PlayerName); SubmittedAnswers.Add(message.PlayerName, new Dictionary<Question, int?>(Questions.Count)); OnPropertyChanged(nameof(PlayerNames)); OnPropertyChanged(nameof(SubmittedAnswers)); } }
void Start() { instance = this; text = GetComponent <TextMeshProUGUI>(); ResetString(); }
public ActionResult AddViewNotification(AddViewNotificationViewModel vModel) { string message = string.Empty; string userId = User.Identity.GetUserId(); ApplicationUser authedUser = UserManager.FindById(userId); try { if (string.IsNullOrWhiteSpace(vModel.Body) || string.IsNullOrWhiteSpace(vModel.Subject)) { message = "You must include a valid body and subject."; } else { if (string.IsNullOrWhiteSpace(vModel.RecipientAccount)) { message = "You must include a valid recipient."; } else { IAccount recipient = Account.GetByHandle(vModel.RecipientAccount); if (recipient == null || recipient.Config.Acquaintences.Any(acq => acq.IsFriend == false && acq.PersonHandle.Equals(authedUser.GameAccount.GlobalIdentityHandle))) { message = "You must include a valid recipient."; } else { PlayerMessage newMessage = new PlayerMessage { Body = vModel.Body, Subject = vModel.Subject, Sender = authedUser.GameAccount, RecipientAccount = recipient }; IPlayerTemplate recipientCharacter = TemplateCache.GetByName <IPlayerTemplate>(vModel.Recipient); if (recipientCharacter != null) { newMessage.Recipient = recipientCharacter; } //messages come from players always here if (newMessage.Save(authedUser.GameAccount, StaffRank.Player)) { message = "Successfully sent."; } else { LoggingUtility.Log("Message unsuccessful.", LogChannels.SystemWarnings); } } } } } catch (Exception ex) { LoggingUtility.LogError(ex, LogChannels.SystemWarnings); } return(RedirectToAction("Notifications", new { Message = message })); }
public void AddMessage(PlayerMessage message) { messageList.Add(message); }
public void DrawMessages(SpriteBatch b) { if (Game1.chatBox != null) { ObjectCache cache = MemoryCache.Default; long uniqueMultiplayerID = Game1.player.UniqueMultiplayerID; int startIndex = chatCommandsIsLoaded ? displayLineIndexField.GetValue() : messagesField.GetValue().Count - 1; int endIndex = chatCommandsIsLoaded ? getEndDisplayIndexMethod.Invoke <int>() : 0; int verticalPosAcum = 0; for (int i = startIndex; i >= endIndex; --i) { ChatMessage message = messagesField.GetValue()[i]; verticalPosAcum += message.verticalSize; int messageHash = message.GetHashCode(); if (!(cache[$"{messageHash}_message"] is PlayerMessage cachedPlayerMessage)) { #if DEBUG ModEntry.ModLogger.LogToMonitor = false; ModEntry.ModLogger.Log($"Message hash: {messageHash}"); ModEntry.ModLogger.LogToMonitor = true; #endif cachedPlayerMessage = PlayerMessageList.Find(msg => msg.MessageHash == messageHash); if (cachedPlayerMessage == null) { string msg = string.Concat(message.message.Select(chatSnippet => chatSnippet.message)); cachedPlayerMessage = new PlayerMessage(Game1.player, LocalizedContentManager.CurrentLanguageCode, msg, messageHash); PlayerMessageList.Add(cachedPlayerMessage); } // Cache message for later cache[$"{messageHash}_message"] = cachedPlayerMessage; #if DEBUG ModEntry.ModLogger.LogToMonitor = false; ModEntry.ModLogger.Log($"vvvvvv Cached {cache.GetCount()} elements vvvvvv"); foreach (var item in cache) { ModEntry.ModLogger.Log($"Message hash: {item}"); } ModEntry.ModLogger.Log($"^^^^^^ Cached {cache.GetCount()} elements ^^^^^^"); ModEntry.ModLogger.LogToMonitor = true; #endif } int x = 12; int y = Game1.chatBox.yPositionOnScreen - verticalPosAcum - 8 + (Game1.chatBox.chatBox.Selected ? 0 : Game1.chatBox.chatBox.Height); foreach (MessageEmoji msgEmoji in cachedPlayerMessage.MessageEmojis) { Vector2 position = new Vector2(msgEmoji.HorizontalPosition + x + 1.0f, msgEmoji.VerticalPosition + y - 4.0f); bool playerLeft = Game1.getAllFarmers().Any(farmer => farmer.UniqueMultiplayerID == cachedPlayerMessage.Player.UniqueMultiplayerID); if (playerLeft && Game1.chatBox.isWithinBounds((int)position.X, (int)position.Y) && msgEmoji.Index >= NumberVanillaEmoji) { msgEmoji.DrawEmoji(b, position, message.alpha); } } } // Draw the emoji menu if (choosingEmojiField.GetValue()) { Game1.chatBox.emojiMenu.draw(b); } // Draw the cursor on top if ((Game1.chatBox.isWithinBounds(Game1.getMouseX(), Game1.getMouseY()) || Game1.chatBox.isActive()) && !Game1.options.hardwareCursor) { b.Draw(Game1.mouseCursors, new Vector2((float)Game1.getOldMouseX(), (float)Game1.getOldMouseY()), new Rectangle?(Game1.getSourceRectForStandardTileSheet(Game1.mouseCursors, Game1.options.gamepadControls ? 44 : 0, 16, 16)), Color.White, 0.0f, Vector2.Zero, (float)(4.0 + Game1.dialogueButtonScale / 150.0), SpriteEffects.None, 1f); } } }
private void SendStatusToPlayer(Player player, PlayerMessage status) { T("Sending to {0} message {1}", player.Name, status); ThreadStart action = () => { Thread.Sleep(250); player.CallBack.ProcessMessage(status); }; new Thread(action).Start(); }
public void ProcessMessage(PlayerMessage message) { if (OnServerMessage != null) OnServerMessage(message); }
private PlayerMessage GetPlayerMessage(EntityEventType type) { var message = new PlayerMessage(); message.EntityEvent = new EntityEvent(); message.EntityEvent.TimeStamp = gameClient.TimeStamp; message.EntityEvent.Type = type; return message; }