public void UpdateFeedbackForChoice(Dictionary <string, int> feedback, ScenarioController.FeedbackMode feedbackMode) { ResetFeedbackAnim(); if (feedback.Count > 0 && feedbackMode >= ScenarioController.FeedbackMode.InGame) { var rect = _feedbackPanel.RectTransform().rect; var width = (rect.width / feedback.Count) - 10; var height = Mathf.Min(rect.height, width / 3); foreach (var i in feedback) { var element = UnityEngine.Object.Instantiate(_feedbackElementPrefab, _feedbackPanel.transform, false); element.RectTransform().sizeDelta = new Vector2(width, height); element.transform.FindText("Title").text = Localization.Get("POINTS_" + i.Key.ToUpper()); element.transform.FindText("Value").text = i.Value > 0 ? "+" + i.Value : i.Value.ToString(); _feedbackElements.Add(element); } _feedbackPanel.BestFit(); _feedbackPanel.GetComponent <Animation>().Play(); } }
public void BuildReviewData(List <ScenarioController.ChatScoreObject> history, float mood, ScenarioController.FeedbackMode feedbackMode) { _reviewContent.verticalScrollbar.value = 1; _characterMood.fillAmount = (mood + 10) / 20; foreach (RectTransform child in _reviewContent.content) { UnityEngine.Object.Destroy(child.gameObject); } var scores = new List <GameObject>(); for (var i = 0; i < history.Count; i++) { var entryKey = history[i].ChatObject.Agent; if (entryKey == "Player" && i + 1 < history.Count) { foreach (var chatScore in history[i + 1].Scores) { if (history[i].Scores.ContainsKey(chatScore.Key)) { history[i].Scores[chatScore.Key] = chatScore.Value; } else { history[i].Scores.Add(chatScore.Key, chatScore.Value); } } } var chatObject = UnityEngine.Object.Instantiate(entryKey == "Client" ? _clientChatPrefab : _playerChatPrefab, _reviewContent.content, false); chatObject.transform.Find("Panel/BubbleText").GetComponent <Text>().text = history[i].ChatObject.Utterence; if (entryKey == "Player" && feedbackMode >= ScenarioController.FeedbackMode.EndGame && history[i] != null && history[i].Scores.Count > 0) { var feedbackPanel = chatObject.transform.Find("FeedbackPanel"); var scoreWidth = 0f; foreach (var feedbackScore in history[i].Scores) { if (feedbackPanel.GetComponent <LayoutGroup>().minWidth + scoreWidth > _reviewContent.content.rect.width) { var newFeedbackPanel = UnityEngine.Object.Instantiate(feedbackPanel, chatObject.transform, false); foreach (RectTransform child in newFeedbackPanel) { UnityEngine.Object.Destroy(child.gameObject); } feedbackPanel = newFeedbackPanel; } var score = UnityEngine.Object.Instantiate(_feedbackPrefab, feedbackPanel, false); score.transform.FindText("Title").text = Localization.Get("POINTS_" + feedbackScore.Key.ToUpper()); score.transform.FindText("Value").text = feedbackScore.Value > 0 ? "+" + feedbackScore.Value : feedbackScore.Value.ToString(); scores.Add(score); score.BestFit(); scoreWidth = score.RectTransform().rect.width; } } } scores.BestFit(); }