void Start() { if (Instance == null) { Instance = this; } }
/// <summary> /// Handles the corresponding event. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="ValueChangedEventArgs{T}"/> instance containing the event data.</param> void World_MapChanged(World sender, ValueChangedEventArgs <Map> e) { ChatBubble.ClearAll(); // Update the mini map MiniMapForm.MapChanged(e.NewValue); // Stop all sounds SoundManager.Stop(); // Set the new music if (!e.NewValue.MusicID.HasValue) { ScreenMusic = null; } else if (!MusicManager.Play(e.NewValue.MusicID.Value)) { var musicTrack = MusicManager.GetMusicInfo(e.NewValue.MusicID.Value); if (musicTrack == null) { const string errmsg = "Failed to play map music with ID `{0}`. No music with that ID could be found."; if (log.IsErrorEnabled) { log.ErrorFormat(errmsg, e.NewValue.MusicID); } Debug.Fail(string.Format(errmsg, e.NewValue.MusicID)); } ScreenMusic = musicTrack; } // Remove the lights from the old map if (e.OldValue != null) { foreach (var light in e.OldValue.Lights) { DrawingManager.LightManager.Remove(light); } } // Add the lights for the new map foreach (var light in e.NewValue.Lights) { DrawingManager.LightManager.Add(light); } // Remove the refraction effects from the old map if (e.OldValue != null) { foreach (var fx in e.OldValue.RefractionEffects) { DrawingManager.RefractionManager.Remove(fx); } } // Add the refraction effects for the new map foreach (var fx in e.NewValue.RefractionEffects) { DrawingManager.RefractionManager.Add(fx); } }
private void Chatter() { ChatBubble.Create(InnKeeperTransform, new Vector2(0, 1f), "howdy partner"); }
void Start() { AttemptInitialize(); if (Instance == null) { Instance = this; } }
public override void InitiateComponent(string param, ChatBubble bubble) { base.InitiateComponent(param, bubble); mImage.transform.SetParent(mChatBubble.mediaParent); }
public static void ReceiveChatMessage(Entity who, MessageType type, string text) { if (instance == null) { return; } if (who != null && (instance.currentMessageType == MessageType.say || instance.currentMessageType == MessageType.yell)) { float width, height; int index = text.IndexOf(':') + 1; Transform tempChatBubble = Instantiate(instance.chatBubblePrefab); tempChatBubble.SetParent(instance.chatBubbleHolder, false); Text bubbleText = tempChatBubble.GetChild(0).GetComponent <Text>(); bubbleText.text = text.Substring(index, text.Length - index); float readTime = Mathf.Clamp(bubbleText.text.Length * instance.charCharacterReadTime, instance.chatBubbleMinimalReadTime, instance.chatBubbleMaximalReadTime); width = bubbleText.preferredWidth; height = bubbleText.preferredHeight; width += 20; //magical number that perfectly fit if (width > 200) { width = 200; } height += 20; bubbleText.rectTransform.sizeDelta = new Vector2(bubbleText.rectTransform.sizeDelta.x, height); tempChatBubble.GetComponent <RectTransform>().sizeDelta = new Vector2(width, height); Vector3 ownerPos = PlayerCamera.instance.GetComponent <Camera>().WorldToScreenPoint(who.transform.position + new Vector3(0, instance.chatBubbleHeight, 0)); tempChatBubble.position = ownerPos.z > 0 ? new Vector2(ownerPos.x, ownerPos.y) : new Vector2(-1000, -1000); tempChatBubble.gameObject.SetActive(true); ChatBubble tempBubble = new ChatBubble(who.transform, tempChatBubble, readTime); //remove old bubbles for same target for (int i = 0; i < instance.chatBubblesList.Count; i++) { if (instance.chatBubblesList[i].who == who.transform) { instance.chatBubblesList[i].timer = 0; } } instance.chatBubblesList.Add(tempBubble); //apply lipSync //who.GetComponent<EntityAnimations>().LipSync(EntityAnimations.GenerateLipSync(bubbleText.text)); } ChatText tempChatText = new ChatText(); tempChatText.text = text; Transform tempChatTextPrefab = Instantiate(instance.chatTextPrefab); tempChatTextPrefab.SetParent(instance.chatTextHolder, false); tempChatTextPrefab.GetComponent <Text>().text = text; tempChatTextPrefab.GetComponent <Text>().fontSize = instance.textSizeInChat; tempChatTextPrefab.GetComponent <Text>().color = instance.chatTextColor[(int)type]; tempChatTextPrefab.gameObject.SetActive(true); tempChatText.visual = tempChatTextPrefab; instance.chatTextList.Add(tempChatText); instance.EnsureChatTextCount(); }
public override void OnApplyTemplate() { base.OnApplyTemplate(); Comment dataContent = DataContext as Comment; Uri authorLink = new Uri(_profilePage.FormatWith(dataContent.AuthorID), UriKind.Relative); _authorPhotoLink = GetTemplateChild(AuthorPhotoLink) as HyperlinkButton; _authorPhotoLink.NavigateUri = authorLink; _authorPhoto = GetTemplateChild(AuthorPhoto) as Image; _authorPhoto.Source = new BitmapImage(dataContent.AuthorPhoto); if (dataContent.HasPlusOne) { _plusOneCount = GetTemplateChild(PlusOneCount) as TextBlock; _plusOneCount.Text = "+{0}".FormatWith(dataContent.PlusOneCount); _plusOneCount.Foreground = dataContent.PlusOneButtonBrush; } _information = GetTemplateChild(Information) as TextBlock; _information.Text = dataContent.Information; _authorNameLink = GetTemplateChild(AuthorNameLink) as HyperlinkButton; _authorNameLink.NavigateUri = authorLink; _authorName = GetTemplateChild(AuthorName) as TextBlock; _authorName.Text = dataContent.Author; _contentChatBubble = GetTemplateChild(ContentChatBubble) as ChatBubble; if (_contentCache == null) { _contentCache = new RichTextBox(); _contentCache.FontSize = (double)Application.Current.Resources["PhoneFontSizeMedium"]; _contentCache.TextWrapping = TextWrapping.Wrap; _contentCache.VerticalScrollBarVisibility = ScrollBarVisibility.Disabled; _contentCache.Blocks.Add(RichTextHelper.Clone(dataContent.Content)); _contentCache.Hold += select; } _contentChatBubble.Content = _contentCache; _copy = GetTemplateChild(Copy) as MenuItem; _copy.Click += copy; _plusOne = GetTemplateChild(PlusOne) as MenuItem; _plusOne.Click += (s, e) => dataContent.PlusOne(); _report = GetTemplateChild(Report) as MenuItem; _edit = GetTemplateChild(Edit) as MenuItem; _edit.Click += edit; _delete = GetTemplateChild(Delete) as MenuItem; _delete.Click += (s, e) => delete(); if (dataContent.IsMine) { _report.Visibility = Visibility.Collapsed; _edit.Visibility = Visibility.Visible; _delete.Visibility = Visibility.Visible; } }
public static From GetDirectionExtended(ChatBubble element) { return((From)element.GetValue(DirectionExtendedProperty)); }
void Start() { instance = this; Speak(); }
public static void SetDirectionExtended(ChatBubble element, From value) { element.SetValue(DirectionExtendedProperty, value); }
public void SetUp(ChatBubble chatBubble) { chatBubble.ExtenderDock = extenderDock; chatBubble.ExtenderPosition = Mathf.Clamp(position, 0, 1); }
public override void InitiateComponent(string param, ChatBubble bubble) { base.InitiateComponent(param, bubble); SetupSticker(param); }
public void AddChatBubble(Entity owner, string text) { ChatBubble.Create(_cScreen, owner, text); }
private async void InitializeSignalR() { try { connection = new HubConnectionBuilder() .WithUrl("http://localhost:5000/ThoughtSoupChat") .WithAutomaticReconnect() .Build(); #region snippet_ClosedRestart connection.Closed += async(error) => { await Task.Delay(new Random().Next(0, 5) * 1000); await connection.StartAsync(); }; #endregion connection.On( "ReceiveMessage", (ChatMessage message) => Dispatcher.Invoke(() => { ChatBubble bubble; if (message.ConnectionID == _connectionID) { bubble = new ChatBubble(new SentMessageOptions(), message); } else { bubble = new ChatBubble(new ReceivedMessageOptions(), message); } MessageBubble messageBubble = new MessageBubble(bubble); ChatWindow.Children.Add(messageBubble); }) ); connection.On( "ReceiveUsers", (string profiles) => Dispatcher.Invoke(() => { var userProfiles = JsonConvert.DeserializeObject <UserProfile[]>(profiles); _userProfiles = new List <UserProfile>(userProfiles); FriendsAndRoomTabs.FriendsList.Items.Clear(); _userProfiles.ForEach(profile => { ListItemContent listItem = new ListItemContent(profile.Username); Binding binding = new Binding(); binding.Mode = BindingMode.OneWay; binding.Source = listItem.Parent; listItem.SetBinding(FrameworkElement.WidthProperty, binding); listItem.ListItemTextbox.SetBinding(FrameworkElement.WidthProperty, binding); if (profile.UserConnectionID != _connectionID) { FriendsAndRoomTabs.FriendsList.Items.Add(listItem); } }); }) ); try { await connection.StartAsync(); _connectionID = connection.ConnectionId; await connection.InvokeAsync( "SendConnectionMessage", new ChatMessage { Message = $"{_username} has joined.", ConnectionID = _connectionID, ProfilePic = _profilePicturePath } ); UserProfile profile = new UserProfile(_username, _connectionID); await connection.InvokeAsync("AddUserConnection", JsonConvert.SerializeObject(profile)); await connection.InvokeAsync("GetUsers"); } catch (Exception ex) { MessageBubble errorMessage = new MessageBubble(new ChatBubble(new SentMessageOptions(), new ChatMessage { Message = ex.Message })); ChatWindow.Children.Add(errorMessage); } } catch (Exception ex) { throw ex; } }