private void LoadScenario(SingleCharacterDemo.ScenarioData data) { ClearButtons(); _iat = data.IAT; if (skipDescription) { _introPanel.SetActive(true); _introText.text = string.Format("<b>{0}</b>\n\n\n{1}", _iat.ScenarioName, _iat.ScenarioDescription); } if (_iat.m_worldModelSource != null) { if (_iat.m_worldModelSource.Source != "" && _iat.m_worldModelSource.Source != null) { _wm = WorldModel.WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().Source); } } var characterSources = _iat.GetAllCharacterSources().ToList(); int CharacterCount = 0; foreach (var source in characterSources) { var rpc = RolePlayCharacterAsset.LoadFromFile(source.Source); rpc.LoadAssociatedAssets(); _iat.BindToRegistry(rpc.DynamicPropertiesRegistry); rpcList.Add(rpc); var body = m_bodies.FirstOrDefault(b => b.BodyName == rpc.BodyName); UnityEngine.Random.InitState((int)System.DateTime.Now.Ticks); var r = UnityEngine.Random.Range(0, 30); Debug.Log("Going to wait" + r); StartCoroutine(JustWait(UnityEngine.Random.Range(0, 3))); _agentController = new MultiCharacterAgentController(data, rpc, _iat, body.CharaterArchtype, m_characterAnchors[CharacterCount], m_dialogController); // StopAllCoroutines(); _agentControllers.Add(_agentController); if (rpc.CharacterName == _player.CharacterName) { _player = rpc; } CharacterCount++; } foreach (var agent in _agentControllers) { if (agent.RPC.CharacterName != _player.CharacterName) { agent.StartBehaviour(this, VersionMenu); } } foreach (var actor in rpcList) { foreach (var anotherActor in rpcList) { if (actor != anotherActor) { var changed = new[] { EventHelper.ActionEnd(anotherActor.CharacterName.ToString(), "Enters", "Room") }; actor.Perceive(changed); } } } SetCamera(); PlayerDecide(); }
private void 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); if (_iat.m_worldModelSource != null) { if (!string.IsNullOrEmpty(_iat.m_worldModelSource.Source)) { var wat = _iat.GetWorldModelSource(); string errorsOnLoad; // _wm = WorldModel.WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().RelativePath); _wm = WorldModel.WorldModelAsset.LoadFromFile(_iat.GetWorldModelSource().Source, out errorsOnLoad); if (errorsOnLoad != null) { throw new Exception(errorsOnLoad); } } } var characterSources = _iat.GetAllCharacterSources().ToList(); foreach (var source in characterSources) { var rpc = RolePlayCharacterAsset.LoadFromFile(source.Source); rpc.LoadAssociatedAssets(); _iat.BindToRegistry(rpc.DynamicPropertiesRegistry); if (rpc.CharacterName.ToString().Contains("Player")) { Player = rpc; continue; } AddButton(characterSources.Count <= 2 ? "Start" : rpc.CharacterName.ToString(), () => { var body = m_bodies.FirstOrDefault(b => b.BodyName == rpc.BodyName); _agentController = new AgentControler(data, rpc, _iat, body.CharaterArchtype, m_characterAnchor, m_dialogController); StopAllCoroutines(); _agentController.Start(this, VersionMenu); _background.SetActive(true); if (!backgrounds.IsEmpty()) { if (!backgrounds.ToList().FindAll(x => x.scenarioName == _iat.ScenarioName).IsEmpty()) { _background.GetComponent <Renderer>().material = backgrounds.ToList().Find(x => x.scenarioName == _iat.ScenarioName).mat; } else { _background.GetComponent <Renderer>().material = activeBackgroundMaterial; } } else { _background.GetComponent <Renderer>().material = activeBackgroundMaterial; } }); } AddButton("Back to Scenario Selection Menu", () => { _iat = null; LoadScenarioMenu(); }); }