Ejemplo n.º 1
0
        private void LoadWorldModelForm()
        {
            var wm = WorldModelAsset.LoadFromFile(LoadedAsset.m_worldModelSource.Source);

            _wmForm             = new WorldModelWF.MainForm();
            _wmForm.LoadedAsset = wm;

            this.pathTextBoxWorldModel.Text = LoadableAsset <WorldModelAsset> .ToRelativePath(LoadedAsset.AssetFilePath, this.LoadedAsset.m_worldModelSource.Source);

            _wmForm.Refresh();
            FormHelper.ShowFormInContainerControl(groupBox7, _wmForm);
        }
    private IEnumerator LoadScenario(ScenarioData data)
    {
        ClearButtons();

        _iat = data.IAT;

        _introPanel.SetActive(true);
        _introText.text = string.Format("<b>{0}</b>\n\n\n{1}", _iat.ScenarioName, _iat.ScenarioDescription);
        previousState   = "";
        var characterSources = _iat.GetAllCharacterSources().ToList();
        var addedDialogs     = new List <string>();

        _wm = WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().Source);
        foreach (var source in characterSources)
        {
            var rpc = RolePlayCharacterAsset.LoadFromFile(source.Source);
            rpc.LoadAssociatedAssets();
            if (rpc.CharacterName.ToString() == "Player")
            {
                Player = rpc;
                _iat.BindToRegistry(Player.DynamicPropertiesRegistry);
                continue;
            }
            _iat.BindToRegistry(rpc.DynamicPropertiesRegistry);
            AddButton(characterSources.Count <= 2 ? "Start" : rpc.CharacterName.ToString(),
                      () =>
            {
                Debug.Log("Interacted with the start button");
                var body         = m_bodies.FirstOrDefault(b => b.BodyName == rpc.BodyName);
                _agentController = new AgentControler(data, rpc, _iat, body.CharaterArchtype, m_characterAnchor, m_dialogController);
                StopAllCoroutines();
                _agentController.storeFinalScore(_finalScore);
                _agentController.Start(this, VersionMenu);
                _agentController.startingTime = this.startingTime;

                InstantiateScore();
            });
        }
        if (m_scenarios.Length > 1)
        {
            AddButton("Back to Scenario Selection Menu", () =>
            {
                _iat = null;
                LoadScenarioMenu();
            });
        }
        yield return(nextframe);
    }
Ejemplo n.º 3
0
        private void HandleEffects(IAction action, RolePlayCharacterAsset actor, DialogueStateActionDTO dialog)
        {
            if (LoadedAsset.m_worldModelSource == null)
            {
                return;
            }

            if (LoadedAsset.m_worldModelSource.Source == null)
            {
                return;
            }

            if (LoadedAsset.m_worldModelSource.Source == "")
            {
                return;
            }

            var wm = WorldModelAsset.LoadFromFile(LoadedAsset.m_worldModelSource.Source);

            var target = action.Target;

            var toString = "Speak(" + dialog.CurrentState + "," + dialog.NextState + "," + dialog.Meaning + "," + dialog.Style + ")";
            var ev       = EventHelper.ActionEnd(actor.CharacterName.ToString(), toString, target.ToString());

            foreach (var a in agentsInChat)
            {
                a.Perceive(ev);
            }
            var    effects = wm.Simulate(new[] { ev });
            string toWrite = "";

            toWrite += "Effects: \n";

            Dictionary <string, List <string> > observerAgents = new Dictionary <string, List <string> >();

            foreach (var eff in effects)
            {
                var evt = EventHelper.PropertyChange(eff.PropertyName.ToString(), eff.NewValue.ToString(), actor.CharacterName.ToString());
                foreach (var a in agentsInChat)
                {
                    if (eff.ObserverAgent == a.CharacterName || eff.ObserverAgent.ToString() == "*")
                    {
                        if (!observerAgents.ContainsKey(a.CharacterName.ToString()))
                        {
                            observerAgents.Add(a.CharacterName.ToString(), new List <string>()
                            {
                                evt.GetNTerm(3).ToString()
                            });
                        }
                        else
                        {
                            observerAgents[a.CharacterName.ToString()].Add(evt.GetNTerm(3).ToString());
                        }

                        a.Perceive(evt);
                    }
                }
            }
            foreach (var o in observerAgents)
            {
                toWrite += o.Key + ": ";

                foreach (var e in o.Value)
                {
                    var value = agentsInChat.Find(x => x.CharacterName.ToString() == o.Key).GetBeliefValue(e);

                    toWrite += e + " = " + value + ", ";
                }
                toWrite  = toWrite.Substring(0, toWrite.Length - 2);
                toWrite += "\n";
            }

            if (effects.Any())
            {
                textBoxBelChat_TextChanged(null, null);
            }

            if (effectTickBox.Checked)
            {
                EditorTools.WriteText(richTextBoxChat,
                                      toWrite, Color.Black, true);
            }
        }