void ProcessTurnResults(ActionResult results) { foreach (var message in results.GetMessages()) { _log.AddMessage(message); } var deadEntities = results.GetEntityEvent("dead"); if (deadEntities.Count() > 0) { var actionResult = new ActionResult(); foreach (var dead in deadEntities) { if (dead == _player) { actionResult.Append(dead.ConvertToDeadPlayer()); _gameState = GameState.Global_PlayerDead; } else { actionResult.Append(dead.ConvertToDeadMonster()); } _entityMap.SwapEntityToMap(dead, _entityMapBackground); _actors.Remove(dead.actor); } foreach (var message in actionResult.GetMessages()) { _log.AddMessage(message); } } }
public void Receive(ZoneChangedEvent message) { if (message.DisplayInformationInUi()) { MessageLog.AddMessage(message.ToString()); } }
private static void LoadGame() { GameWorld = File.LoadGame(); GameWorld.State = Constants.GameState.Playing; MessageLog.AddMessage("Game loaded.", "white"); }
public void uLink_OnServerUninitialized(uLink.NetworkDisconnection error) { MessageLog.AddMessage("Disconnected from server: " + error); if (CurrentServer != null) { Destroy(CurrentServer.gameObject); } TryingToConnect = false; }
public void Receive(AbilityActivatedEvent message) { // do not show repeated activation of same ability if (Game.Stack.IsEmpty || message.Ability != Game.Stack.TopSpell.Source) { ShowActivationDialog(message); } MessageLog.AddMessage(message.ToString()); }
private void Update() { //process ai move results if (activeMoveState != null) { foreach (var result in activeMoveState.Results) { if (result is MessageActionResult) { log.AddMessage(result); } else if (result is DeadActionResult) { //player is dead! log.AddMessage(new MessageActionResult("You died!")); OnPlayerDead.Invoke(this); } } activeMoveState.Results.Clear(); if (activeMoveState.Finished) { activeMoveState = null; } } //next move else { gameMap.RecalulatePathfinding(); if (moveQueue.Count > 0) { var enemy = moveQueue.Dequeue(); activeMoveState = enemy.TakeTurn(); } else { //all enemies have moved OnEnemyTurnEnded.Invoke(this); } } }
public void uLink_OnServerInitialized() { TryingToConnect = false; var sb = new StringBuilder(); sb.AppendLine("Started server on port " + Port); sb.Append("Your address is " + AddressFinder.ExternalAddress); MessageLog.AddMessage(sb.ToString()); // Instantiated server will assign itself as the CurrentServer uLink.Network.Instantiate(BaseServer, Vector3.zero, Quaternion.identity, 0); }
private void Connection_MessageReceived(object sender, MessageEventArgs e) { if (e.Message.Type == MessageType.Chat) { Application.Current.Dispatcher.Invoke(() => MessageLog.AddMessage(e.Message, true)); Application.Current.Dispatcher.Invoke(() => StatusTextBlock.Text = LocaleSelector.GetLocaleString("StatusIndicator_StrangerIdle")); } else if (e.Message.Type == MessageType.Topic) { Application.Current.Dispatcher.Invoke(() => MessageLog.AddTopic(e.Message)); } }
public DungeonLevel GoToFloor(int floor, Entity player, MessageLog messageLog) { if (floor > LevelNumber) { Entities.Remove(player); if (NextFloor == null) { NextFloor = new DungeonLevel { LevelNumber = LevelNumber + 1, Map = new DungeonMap(LevelNumber + 1, Constants.MapWidth, Constants.MapHeight) }; NextFloor.Map.Tiles = NextFloor.Map.InitializeTiles(); NextFloor.Map.MakeMap(Constants.MaxRooms, Constants.MinRoomSize, Constants.MaxRoomSize, Constants.MapWidth, Constants.MapHeight, player, NextFloor.Entities); NextFloor.PreviousFloor = this; player.Get <FighterComponent>().Heal(player.Get <FighterComponent>().MaxHp / 2); messageLog.AddMessage("You take a moment to rest, and recover your strength.", Color.Violet); } else { Entity stairsEntity = NextFloor.Entities.Single(entity => entity.Get <StairsComponent>() != null && entity.Get <StairsComponent>()?.ToFloor == LevelNumber); player.X = stairsEntity.X; player.Y = stairsEntity.Y; NextFloor.Entities.Add(player); } return(NextFloor); } if (floor < LevelNumber) { if (PreviousFloor == null) { return(null); } Entities.Remove(player); Entity stairsEntity = PreviousFloor.Entities.Single(entity => entity.Get <StairsComponent>() != null && entity.Get <StairsComponent>()?.ToFloor == LevelNumber); player.X = stairsEntity.X; player.Y = stairsEntity.Y; PreviousFloor.Entities.Add(player); return(PreviousFloor); } return(this); }
private void ChatBox_KeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter && !string.IsNullOrWhiteSpace(ChatBox.Text) && _connection.IsStrangerConnected) { _connection.SendMessage(ChatBox.Text); if (SettingsSelector.GetConfigurationValue <bool>("Behavior_SendChatstate")) { _connection.ReportChatstate(false); _typing = false; } MessageLog.AddMessage(new Message(ChatBox.Text, -1, -1, MessageType.Chat), false); ChatBox.Clear(); OnMessageSent(); } }
public void Connect(RunMode mode) { switch (mode) { case RunMode.Client: TryingToConnect = true; uLink.Network.Connect(ConnectingServerHostname, Port); MessageLog.AddMessage("Connecting to " + ConnectingServerHostname + ":" + Port); break; case RunMode.Server: TryingToConnect = true; uLink.Network.InitializeServer(32, Port, false); // true = use nat facilitator break; default: throw new ArgumentOutOfRangeException(); } }
private void ConnectToExternalListedServer(ServerInfoRaw serverInfo) { TryingToConnect = true; // If it looks like it's coming from local LAN, try to connect to // localhost. It seems some routers (like mine) will not respect UPnP // port mappings if the origin is from within the local network, which // obviously makes playtesting locally kind of hard! Obviously this is // not a great solution, since you can't play a local LAN game on a // separate machine, but our current setup of using WAN/external IPs // only doesn't support that anyway. if (serverInfo.address == AddressFinder.ExternalAddress) { uLink.Network.Connect("127.0.0.1", Port); MessageLog.AddMessage("Connecting to 127.0.0.1"); } else { uLink.Network.Connect(serverInfo.address, Port); MessageLog.AddMessage("Connecting to " + serverInfo.address); } }
private void Update() { if (Input.GetKeyDown(KeyCode.I)) { if (inventoryWindow.Visible) { inventoryWindow.Hide(); } else { var inv = Player.GetComponent <Inventory>(); inventoryWindow.Show(inv); } } //process player move results if (activeMoveState != null) { foreach (var result in activeMoveState.Results) { log.AddMessage(result); } activeMoveState.Results.Clear(); //next turn if (activeMoveState.Finished) { gameMap.RecalulatePathfinding(); activeMoveState = null; PlayerTurnEnded.Invoke(this); } } }
public void Receive(PlayerFlippedCoinEvent message) { MessageLog.AddMessage(message.ToString()); }
public void uLink_OnFailedToConnect(uLink.NetworkConnectionError error) { MessageLog.AddMessage("Failed to connect: " + error); TryingToConnect = false; }
private void FillMessageLog(string path) { Application.Current.Dispatcher.Invoke(() => { using (var sr = new StreamReader(path)) { var array = sr.ReadToEnd().Split('\n'); foreach (var s in array) { object item; try { item = Presence.Parse(s); } catch { try { item = Message.Parse(s); } catch { try { item = Topic.Parse(s); } catch { return; } } } if (item is Presence) { var p = item as Presence; MessageLog.AddPresence(p.Connect); } if (item is Message) { var m = item as Message; MessageLog.AddMessage( new ObcyProtoRev.Protocol.Client.Message( m.Body, -1, -1, MessageType.Chat ), m.Incoming, m.Timestamp.FromUnixTimestamp() ); } if (item is Topic) { var t = item as Topic; MessageLog.AddTopic( new ObcyProtoRev.Protocol.Client.Message( t.Body, 0, 0, MessageType.Topic ) ); } } } }); }
public void Receive(CardWasRevealedEvent message) { MessageLog.AddMessage(message.ToString()); }
public void Receive(SpellCastEvent message) { ShowActivationDialog(message); MessageLog.AddMessage(message.ToString()); }
private void ReceiveServerMessage(string text) { MessageLog.AddMessage(text); }
public void Receive(OptionsChosenEvent message) { MessageLog.AddMessage(message.Text); }
public void Receive(DamageDealtEvent message) { MessageLog.AddMessage(message.ToString()); }
private void ReceiveMasterListFetchError(string message) { MessageLog.AddMessage("Failed to get server list: " + message); }
public void Receive(LifeChangedEvent message) { MessageLog.AddMessage(message.ToString()); }
public void Receive(PlayerTookMulliganEvent message) { MessageLog.AddMessage(String.Format("{0} took mulligan.", message.Player.Name)); }
private void OnSelectionChanged(ISelectionChangedEventArgs args) { m_MessageLog?.AddMessage(string.Format("Object explorer selection: {0}", args.Selection.Path)); }