Beispiel #1
0
 /// <summary>
 /// Add a reply to the dictionary of selected responses. If the number of responses matches the number expected, get replies from crew members.
 /// </summary>
 public Dictionary <CrewMember, PostRaceEventState> AddReply(PostRaceEventState response)
 {
     //create dictionary if null
     if (_selectedResponses == null)
     {
         _selectedResponses = new Dictionary <CrewMember, PostRaceEventState>();
     }
     //overwrite response if one had already been given for this crew member.
     if (_selectedResponses.ContainsKey(response.CrewMember))
     {
         _selectedResponses[response.CrewMember] = response;
     }
     else
     {
         _selectedResponses.Add(response.CrewMember, response);
     }
     if (_selectedResponses.Count == GameManagement.CurrentEventCount)
     {
         foreach (var res in _selectedResponses.Values)
         {
             TrackerEventSender.SendEvent(new TraceEvent("PostRaceEventDialogueSelected", TrackerAsset.Verb.Selected, new Dictionary <TrackerContextKey, object>
             {
                 { TrackerContextKey.DialogueID, res.Dialogue.NextState },
                 { TrackerContextKey.DialogueStyle, res.Dialogue.Meaning.Split('_').First(sp => !string.IsNullOrEmpty(sp)) },
                 { TrackerContextKey.EventID, res.Dialogue.NextState.EventKeys() }
             }, res.Dialogue.NextState, AlternativeTracker.Alternative.Dialog));
             SUGARManager.GameData.Send("Post Race Event Reply", res.Dialogue.NextState);
         }
         var beforeValues = GameManagement.AverageTeamMood + GameManagement.AverageTeamManagerOpinion + GameManagement.AverageTeamOpinion;
         //send chosen dialogue and get response
         var replies = GameManagement.GameManager.SendPostRaceEvent(_selectedResponses.Values.ToList());
         _selectedResponses = null;
         var afterValues = GameManagement.AverageTeamMood + GameManagement.AverageTeamManagerOpinion + GameManagement.AverageTeamOpinion;
         if (afterValues > beforeValues)
         {
             SUGARManager.GameData.Send("Post Race Event Positive Outcome", true);
         }
         else if (afterValues < beforeValues)
         {
             SUGARManager.GameData.Send("Post Race Event Positive Outcome", false);
         }
         var replyDict = new Dictionary <CrewMember, PostRaceEventState>();
         foreach (var ev in GameManagement.CurrentEvent)
         {
             if (!replyDict.ContainsKey(ev.CrewMember))
             {
                 replyDict.Add(ev.CrewMember, null);
             }
         }
         foreach (var reply in replies)
         {
             replyDict[reply.CrewMember] = reply;
         }
         return(replyDict);
     }
     return(null);
 }
Beispiel #2
0
 /// <summary>
 /// Reset and populate the pop-up for a new event
 /// </summary>
 public void ResetDisplay(PostRaceEventState current)
 {
     if (current.Dialogue != null)
     {
         LastState = current.Dialogue.NextState;
         if (current.Dialogue.NextState == "-")
         {
             LastState = current.Dialogue.CurrentState;
         }
         var subjects = current.Subjects.Select(s => Localization.HasKey(s) ? Localization.Get(s) : Regex.Replace(s, @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0")).ToArray();
         _dialogueText.text = Localization.GetAndFormat(current.Dialogue.Utterance, false, subjects);
     }
     _avatarDisplay.SetAvatar(current.CrewMember.Avatar, current.CrewMember.GetMood());
     _avatarDisplay.Parent().GetComponent <Image>().color = AvatarDisplay.MoodColor(current.CrewMember.GetMood());
     CurrentCrewMember = current.CrewMember;
     _nameText.text    = current.CrewMember.Name;
 }
Beispiel #3
0
    /// <summary>
    /// Triggered by button. Send the selected dialogue to the character
    /// </summary>
    public void SendReply(PostRaceEventState reply)
    {
        var responses = AddReply(reply);

        if (responses != null)
        {
            foreach (var person in _postRacePeople)
            {
                foreach (var res in responses)
                {
                    if (res.Key == person.CurrentCrewMember)
                    {
                        person.UpdateDialogue(res.Value.Dialogue, res.Value.Subjects);
                    }
                }
            }
            ResetQuestions();
        }
    }
Beispiel #4
0
    /// <summary>
    /// Reset the available dialogue options for the player
    /// </summary>
    public void ResetQuestions(PostRaceEventState current, List <PostRaceEventState> replies)
    {
        UpdateSelected(null);
        var eventMember = current.CrewMember;

        //set text and onclick handlers for each question UI object
        for (var i = 0; i < _questions.Length; i++)
        {
            if (replies.Count <= i)
            {
                _questions[i].Active(false);
                continue;
            }
            _questions[i].Active(true);
            var subjects = current.Subjects.Select(s => Localization.HasKey(s) ? Localization.Get(s) : Regex.Replace(s, @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0")).ToArray();
            _questions[i].GetComponentInChildren <Text>().text = Localization.GetAndFormat(replies[i].Dialogue.Utterance, false, subjects);
            var currentReply  = replies[i];
            var postRaceEvent = GetComponentInParent <PostRaceEventUI>();
            var question      = _questions[i];
            var button        = _questions[i].GetComponent <Button>();
            button.onClick.RemoveAllListeners();
            button.onClick.AddListener(() => UpdateSelected(question));
            button.onClick.AddListener(() => postRaceEvent.SendReply(currentReply));
        }
        //display the button for closing the pop-up and update the displayed character mood if there are no more dialogue options
        if (replies.Count == 0)
        {
            //update displayed avatar moods
            if (eventMember != null)
            {
                _avatarDisplay.UpdateMood(eventMember.GetMood());
            }
            foreach (var crewMember in UIManagement.TeamSelection.CrewMembers)
            {
                crewMember.UpdateAvatar(crewMember.CrewMember.GetMood());
            }
        }
    }