Пример #1
0
        private void PerceiveActionStart(RolePlayCharacterAsset rpc)
        {
            var e = EventHelper.ActionStart(Subject, Name, Value);

            Debug.WriteLine(e.ToString());
            rpc.Perceive(e);
        }
Пример #2
0
        /// <summary>
        /// Check to see if any events are about to be triggered
        /// </summary>
        internal void CurrentEventCheck(Team team, IntegratedAuthoringToolAsset iat)
        {
            var spacelessName = Name.NoSpaces();

            //if the crew member is expecting to be selected
            if (LoadBelief(NPCBelief.ExpectedSelection) != null)
            {
                //if the crew member is not in a position
                if (team.Boat.GetCrewMemberPosition(this) == Position.Null)
                {
                    //reduce opinion of the manager
                    AddOrUpdateOpinion(team.ManagerName, -3);
                    //send event on record that this happened
                    var eventString = EventHelper.ActionStart("Player", "PostRace(NotPickedNotDone)", spacelessName);
                    RolePlayCharacter.Perceive(eventString);
                    eventString = EventHelper.ActionStart("Player", "MoodChange(-3)", spacelessName);
                    RolePlayCharacter.Perceive(eventString);
                }
                //set their belief to 'null'
                UpdateSingleBelief(NPCBelief.ExpectedSelection);
                TickUpdate(0);
            }
            //if the crew member is expecting to be selecting in a particular position
            if (LoadBelief(NPCBelief.ExpectedPosition) != null)
            {
                var expected = LoadBelief(NPCBelief.ExpectedPosition);
                if (expected != null && team.Boat.Positions.Any(p => p.ToString() == expected))
                {
                    //if they are currently not in the position they expected to be in
                    if (team.Boat.GetCrewMemberPosition(this).ToString() != expected)
                    {
                        //reduce opinion of the manager
                        AddOrUpdateOpinion(team.ManagerName, -3);
                        //send event on record that this happened
                        var eventString = EventHelper.ActionStart("Player", "PostRace(PWNotDone)", spacelessName);
                        RolePlayCharacter.Perceive(eventString);
                        eventString = EventHelper.ActionStart("Player", "MoodChange(-3)", spacelessName);
                        RolePlayCharacter.Perceive(eventString);
                    }
                    //set their belief to 'null'
                    UpdateSingleBelief(NPCBelief.ExpectedPosition);
                    TickUpdate(0);
                }
            }
            //if the crew member expects to be selected in a position after this current race, set them to instead be expecting to be selected for the current race
            if (LoadBelief(NPCBelief.ExpectedPositionAfter) != null)
            {
                var expected = LoadBelief(NPCBelief.ExpectedPositionAfter);
                if (expected != null)
                {
                    UpdateSingleBelief(NPCBelief.ExpectedPositionAfter);
                    UpdateSingleBelief(NPCBelief.ExpectedPosition, expected);
                    TickUpdate(0);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Retire this CrewMember
        /// </summary>
        internal void Retire()
        {
            UpdateSingleBelief(NPCBelief.Position, "Retired");
            var spacelessName = Name.NoSpaces();
            var eventString   = EventHelper.ActionStart("Player", "Status(Retired)", spacelessName);

            RolePlayCharacter.Perceive(eventString);
            Avatar = new Avatar(this, false);
            SaveStatus();
        }
    private IEnumerator PlayerReplyAction(string replyActionName, string nextState)
    {
        const float WAIT_TIME = 0.5f;

        _agentController.RPC.Perceive(EventHelper.ActionStart(IATConsts.PLAYER, replyActionName, _agentController.RPC.CharacterName.ToString()));
        yield return(new WaitForSeconds(WAIT_TIME));

        _agentController.RPC.Perceive(EventHelper.ActionEnd(IATConsts.PLAYER, replyActionName, _agentController.RPC.CharacterName.ToString()));
        _agentController.RPC.Perceive(EventHelper.PropertyChange(string.Format(IATConsts.DIALOGUE_STATE_PROPERTY, IATConsts.PLAYER), nextState, "SELF"));
    }
    private IEnumerator PlayerReplyAction(string replyActionName, string nextState)
    {
        ClearButtons();
        const float WAIT_TIME = 0.1f;

        _agentController.RPC.Perceive(EventHelper.ActionStart(IATConsts.PLAYER, replyActionName, _agentController.RPC.CharacterName.ToString()));
        yield return(new WaitForSeconds(WAIT_TIME));

        _agentController.RPC.Perceive(EventHelper.ActionEnd(IATConsts.PLAYER, replyActionName, _agentController.RPC.CharacterName.ToString()));

        HandleEffects(new List <Name> {
            EventHelper.ActionEnd(IATConsts.PLAYER, replyActionName, _agentController.RPC.CharacterName.ToString())
        });
    }
Пример #6
0
    public void SetPlayerAction(Guid actionId)
    {
        var reply = _currentPlayerDialogue.FirstOrDefault(a => a.Id.Equals(actionId));

        if (reply != null && _chatScoreHistory.LastOrDefault(c => c.ChatObject.Agent == "Player")?.ChatObject.CurrentState != reply.CurrentState)
        {
            var actionFormat = $"Speak({reply.CurrentState},{reply.NextState},{reply.Meaning},{reply.Style})";

            // Submit dialogue choice to the IAT event list.
            _events.Add(EventHelper.ActionStart(IATConsts.PLAYER, actionFormat, CurrentCharacter.CharacterName.ToString()));
            _events.Add(EventHelper.ActionEnd(IATConsts.PLAYER, actionFormat, CurrentCharacter.CharacterName.ToString()));
            _events.Add(EventHelper.PropertyChange(string.Format(IATConsts.DIALOGUE_STATE_PROPERTY, IATConsts.PLAYER), reply.NextState, "Player"));

            // UCM tracker tracks the filename ID of each player dialogue choice made
            TrackerEventSender.SendEvent(new TraceEvent("DialogueSelection", TrackerAsset.Verb.Initialized, new Dictionary <string, string>
            {
                { TrackerContextKey.PlayerDialogueState.ToString(), reply.CurrentState },
                { TrackerContextKey.PlayerDialogueCode.ToString(), reply.FileName },
                { TrackerContextKey.PlayerDialogueText.ToString(), reply.Utterance }
            }));
            TrackerEventSender.SendEvaluationEvent(TrackerEvalautionEvent.AssetActivity, new Dictionary <TrackerEvaluationKey, string>
            {
                { TrackerEvaluationKey.AssetId, "FAtiMA" },
                { TrackerEvaluationKey.Action, "DialogueSelection" }
            });
            TrackerEventSender.SendEvaluationEvent(TrackerEvalautionEvent.GameActivity, new Dictionary <TrackerEvaluationKey, string>
            {
                { TrackerEvaluationKey.Event, "DialogueSelection" },
                { TrackerEvaluationKey.GoalOrientation, "Progression" },
                { TrackerEvaluationKey.Tool, "DialogueChoices" }
            });
            _feedbackScores.Clear();
            UpdateFeedbackScores(reply, "Player");
            GetCharacterResponse();
            GetFeedbackEvent?.Invoke(_feedbackScores, FeedbackLevel);
        }
    }
Пример #7
0
        /// <summary>
        /// Save the current boat line-up to the manager's RPC file
        /// </summary>
        public void SaveLineUp(int offset)
        {
            //set-up boat for saving
            var boat    = Team.Boat;
            var manager = Team.Manager;

            //get results
            boat.UpdateScore(manager.Name);
            boat.GetIdealCrew(Team.CrewMembers, manager.Name);
            var boatType = boat.Type;
            var crew     = string.Empty;

            //set up string to save
            foreach (var position in boat.Positions)
            {
                //add comma to split information if this isn't the first part of the string
                if (!string.IsNullOrEmpty(crew))
                {
                    crew += ",";
                }
                //add positioned crewmembers and their position rating to the string
                if (boat.PositionCrew.ContainsKey(position))
                {
                    crew += boat.PositionCrew[position].Name.NoSpaces();
                    crew += "," + boat.PositionScores[position];
                }
                else
                {
                    crew += "null,0";
                }
            }
            //add PerfectSelections and ImperfectSelections to the string
            crew += "," + boat.PerfectSelections + "," + boat.ImperfectSelections;
            //add every selection mistake to the string
            boat.SelectionMistakes.ForEach(sm => crew += "," + sm);
            //add time offset to the string
            crew += "," + offset;
            //add to CurrentRaceSession and add to string
            CurrentRaceSession++;
            if (RaceSessionLength == CurrentRaceSession)
            {
                CurrentRaceSession = 0;
            }
            crew += "," + CurrentRaceSession;
            //send event with string of information within
            var eventString = EventHelper.ActionStart("Player", $"SelectedLineUp({boatType},{crew})", manager.Name.NoSpaces());

            manager.RolePlayCharacter.Perceive(eventString);
            manager.SaveStatus();
            //store saved details in new local boat copy
            var lastBoat = boat.Copy();

            lastBoat.PositionCrew.Clear();
            lastBoat.PositionScores.Clear();
            foreach (var position in boat.Positions)
            {
                if (boat.PositionCrew.ContainsKey(position))
                {
                    lastBoat.PositionCrew.Add(position, boat.PositionCrew[position]);
                    lastBoat.PositionScores.Add(position, boat.PositionScores[position]);
                }
            }
            Team.LineUpHistory.Add(lastBoat);
            Team.HistoricTimeOffset.Add(offset);
            Team.HistoricSessionNumber.Add(CurrentRaceSession);
            if (CurrentRaceSession == 0)
            {
                Team.TickCrewMembers(ConfigKey.TicksPerSession.GetIntValue(), false);
                EventController.SelectPostRaceEvents(Team, ConfigKey.EventChance.GetIntValue());
                Team.ConfirmChanges();
                ResetAllowances();
            }
            else
            {
                Team.TickCrewMembers();
            }
        }
Пример #8
0
        /// <summary>
        /// Make changes based off of post-race events
        /// </summary>
        private void PostRaceFeedback(string ev, Team team, List <string> subjects)
        {
            var spacelessName = Name.NoSpaces();
            var eventString   = EventHelper.ActionStart("Player", $"PostRace({ev})", spacelessName);

            if (ev.Contains("("))
            {
                eventString = EventHelper.ActionStart("Player", ev, spacelessName);
            }
            //event perceived to trigger any mood change events kept in the EA file
            RolePlayCharacter.Perceive(eventString);
            if (Enum.IsDefined(typeof(PostRaceEventImpact), ev))
            {
                //trigger different changes based off of what dialogue the player last picked
                switch ((PostRaceEventImpact)Enum.Parse(typeof(PostRaceEventImpact), ev))
                {
                //improve opinion of manager, crew member now expects to be picked in the selected position (subjects[0]) next race
                case PostRaceEventImpact.ExpectedPosition:
                    AddOrUpdateOpinion(team.ManagerName, 1);
                    UpdateSingleBelief(NPCBelief.ExpectedPosition, subjects[0]);
                    break;

                //improve opinion of manager, crew member now expects to be picked in the selected position (subjects[0]) in two races time
                case PostRaceEventImpact.ExpectedPositionAfter:
                    AddOrUpdateOpinion(team.ManagerName, 1);
                    UpdateSingleBelief(NPCBelief.ExpectedPositionAfter, subjects[0]);
                    break;

                //make opinion of manager worse
                case PostRaceEventImpact.ManagerOpinionWorse:
                    AddOrUpdateOpinion(team.ManagerName, -1);
                    break;

                //make all crew members' opinion of manager worse
                case PostRaceEventImpact.ManagerOpinionAllCrewWorse:
                    foreach (var cm in team.CrewMembers)
                    {
                        cm.Value.AddOrUpdateOpinion(team.ManagerName, -2);
                        cm.Value.SaveStatus();
                    }
                    break;

                //improve opinion of manager
                case PostRaceEventImpact.ManagerOpinionBetter:
                    AddOrUpdateOpinion(team.ManagerName, 1);
                    break;

                //make all crew members' opinion of manager better
                case PostRaceEventImpact.ManagerOpinionAllCrewBetter:
                    foreach (var cm in team.CrewMembers)
                    {
                        cm.Value.AddOrUpdateOpinion(team.ManagerName, 2);
                        cm.Value.SaveStatus();
                    }
                    break;

                //improve opinion of manager greatly
                case PostRaceEventImpact.ManagerOpinionMuchBetter:
                    AddOrUpdateOpinion(team.ManagerName, 5);
                    break;

                //make opinion of manager much worse
                case PostRaceEventImpact.ManagerOpinionMuchWorse:
                    AddOrUpdateOpinion(team.ManagerName, -5);
                    break;

                //reveal two random skills for this crew member (can be already revealed skills)
                case PostRaceEventImpact.RevealTwoSkills:
                    AddOrUpdateOpinion(team.ManagerName, 1);
                    for (var i = 0; i < 2; i++)
                    {
                        var randomStat = Math.Pow(2, StaticRandom.Int(0, Skills.Count));
                        var statName   = ((Skill)randomStat).ToString();
                        var statValue  = Skills[(Skill)randomStat];
                        RevealedSkills[(Skill)randomStat] = statValue;
                        UpdateSingleBelief(NPCBelief.RevealedSkill, statValue, statName);
                    }
                    break;

                //reveal four random skills for this crew member (can be already revealed skills)
                case PostRaceEventImpact.RevealFourSkills:
                    AddOrUpdateOpinion(team.ManagerName, 3);
                    for (var i = 0; i < 4; i++)
                    {
                        var randomStat = Math.Pow(2, StaticRandom.Int(0, Skills.Count));
                        var statName   = ((Skill)randomStat).ToString();
                        var statValue  = Skills[(Skill)randomStat];
                        RevealedSkills[(Skill)randomStat] = statValue;
                        UpdateSingleBelief(NPCBelief.RevealedSkill, statValue, statName);
                    }
                    break;

                //improve all crew members' opinion of the crew member who was the subject of the event (subjects[0]) greatly and reveals their opinion.
                //Regex adds spaces back before each capital letter
                case PostRaceEventImpact.ImproveConflictOpinionGreatly:
                    var subGreatHelp = Regex.Replace(subjects[0], @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0");
                    foreach (var cm in team.CrewMembers)
                    {
                        if (cm.Key != subGreatHelp)
                        {
                            cm.Value.AddOrUpdateOpinion(subGreatHelp, 2);
                            cm.Value.AddOrUpdateRevealedOpinion(subGreatHelp, cm.Value.CrewOpinions[subGreatHelp]);
                            cm.Value.SaveStatus();
                        }
                    }
                    break;

                //improve all crew members' opinion of the crew member who was the subject of the event (subjects[0]) and reveals their opinion.
                //Regex adds spaces back before each capital letter
                case PostRaceEventImpact.ImproveConflictTeamOpinion:
                    var subHelp = Regex.Replace(subjects[0], @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0");
                    foreach (var cm in team.CrewMembers)
                    {
                        if (cm.Key != subHelp)
                        {
                            cm.Value.AddOrUpdateOpinion(subHelp, 1);
                            cm.Value.AddOrUpdateRevealedOpinion(subHelp, cm.Value.CrewOpinions[subHelp]);
                            cm.Value.SaveStatus();
                        }
                    }
                    break;

                //reveals all crew members' opinion of the crew member who was the subject of the event (subjects[0]) and slightly improves this the opinion of the manager for this crew member.
                //Regex adds spaces back before each capital letter
                case PostRaceEventImpact.ImproveConflictKnowledge:
                    var subKnow = Regex.Replace(subjects[0], @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0");
                    AddOrUpdateOpinion(team.ManagerName, 1);
                    foreach (var cm in team.CrewMembers)
                    {
                        if (cm.Key != subKnow)
                        {
                            cm.Value.AddOrUpdateRevealedOpinion(subKnow, cm.Value.CrewOpinions[subKnow]);
                            cm.Value.SaveStatus();
                        }
                    }
                    break;

                //improve opinion of manager, expects to be placed in perferred position (subjects[0]) next race
                //other crew member involved in this event (subjects[1]) - improve opinion of manager, expects to be placed in perferred position (subjects[0]) in two races times
                //Regex adds spaces back before each capital letter
                case PostRaceEventImpact.CausesSelectionAfter:
                    AddOrUpdateOpinion(team.ManagerName, 1);
                    UpdateSingleBelief(NPCBelief.ExpectedPosition, subjects[0]);
                    var otherPlayer = Regex.Replace(subjects[1], @"((?<=\p{Ll})\p{Lu})|((?!\A)\p{Lu}(?>\p{Ll}))", " $0");
                    team.CrewMembers[otherPlayer].AddOrUpdateOpinion(team.ManagerName, 1);
                    team.CrewMembers[otherPlayer].UpdateSingleBelief(NPCBelief.ExpectedPositionAfter, subjects[0]);
                    team.CrewMembers[otherPlayer].SaveStatus();
                    break;

                //improves opinion of manager greatly, all unselected crew members' opinion of manager improves and expect to be selected next race
                case PostRaceEventImpact.WholeTeamChange:
                    AddOrUpdateOpinion(team.ManagerName, 4);
                    foreach (var cm in team.CrewMembers)
                    {
                        if (!team.PreviousSession.PositionCrew.Values.Select(v => v.Name).Contains(cm.Key))
                        {
                            cm.Value.AddOrUpdateOpinion(team.ManagerName, 1);
                            cm.Value.UpdateSingleBelief(NPCBelief.ExpectedSelection, "true");
                            cm.Value.SaveStatus();
                        }
                    }
                    break;
                }
            }
            TickUpdate(0);
        }