Ejemplo n.º 1
0
        private Beat[] GenerateStoryline(Rule storyline)
        {
            Rule toDecompose = new Rule(storyline);
            HashSet <NarrativeObject> ruleObjects = new HashSet <NarrativeObject>();

            for (int idx = 0; idx < toDecompose.Right.Count; idx++)
            {
                if (toDecompose.Right[idx].CanDecompose)
                {
                    Rule replaceWith = _ruleManager.GetWeightedRandomMatchingRule(toDecompose.Right[idx], ruleObjects);
                    if (replaceWith == null)
                    {
                        //If we can't decompose any of the tokens in the rule, we just can't fulfil that rule, so quit out
                        Debug.LogWarningFormat($"Can't decompose token {toDecompose.Right[idx]}, when generating from storyline {storyline}");
                        return(null);
                    }

                    toDecompose.Right.RemoveAt(idx);
                    toDecompose.Right.InsertRange(idx, replaceWith.Right);
                }
            }

            List <Beat> beats = new List <Beat>();

            foreach (Token token in toDecompose.Right)
            {
                Debug.Assert(!token.CanDecompose, "Shouldn't be able to decompose this token");
                beats.AddRange(NarrativePlanner.LoadBeats(token.Graph));
            }

            return(beats.ToArray());
        }
Ejemplo n.º 2
0
Archivo: App.cs Proyecto: Yann4/Thesis
        private IEnumerator Start()
        {
            new LocManager(_localisation);             //Need to create the instance, but don't need to worry about holding a reference

            AIBlackboard = new Blackboard(_conversations);

            WorldState = new WorldStateManager();
            Planner    = new NarrativePlanner(WorldState, this, _beatGraph);

#if UNITY_EDITOR
            Generator = new NarrativeGenerator(_beatGraph, _ruleSet, _templates, WorldState);
#endif //UNITY_EDITOR

            yield return(LoadScene(_HUDSceneName));

            if (_loadWhitebox || _worldConfig == null)
            {
                yield return(LoadScene(_whiteboxScene));
            }
            else
            {
                foreach (WorldConfig.SceneLocation scene in _worldConfig.Scenes)
                {
                    yield return(LoadScene(scene.WorldSceneName));

                    Scene loadedScene = SceneManager.GetSceneByName(scene.WorldSceneName);
                    foreach (GameObject sceneRoot in loadedScene.GetRootGameObjects())
                    {
                        sceneRoot.transform.position += scene.Offset;
                    }
                }
            }

            StartCoroutine(InvokeLevelLoaded());

            _timeScale = Time.timeScale;
        }