Example #1
0
    // Called on loading into Story scene
    void Start()
    {
        dialogFeed  = transform.Find("DialogFeed/Viewport/Content").gameObject;
        optionsFeed = transform.Find("OptionsFeed").gameObject;

        playerModel    = transform.Find("PlayerAvatar").gameObject;
        allyModel      = transform.Find("AllyAvatar").gameObject;
        enemyModel     = transform.Find("EnemyAvatar").gameObject;
        bystanderModel = transform.Find("BystanderAvatar").gameObject;

        textPrefab = Resources.Load("Prefabs/DialogBubble") as GameObject;
        // choicePrefab = Resources.Load("Prefabs/Button") as Button;

        Type storyClass = StoryLibrary.Instance.Lookup(GameState.currentStoryID);

        if (storyClass == null)
        {
            Debug.Log("No valid story was supplied; supplying test story instead");
            storyToRender = new StoryTest();
        }
        else
        {
            AbstractStory absStory = Activator.CreateInstance(storyClass) as AbstractStory;
            storyToRender = absStory;
        }
        storyToRender.SetupStory();
        story = storyToRender._inkStory;
        StartCoroutine(PlayStory());
    }
Example #2
0
    private StoryLibrary()
    {
        float    startUp  = Time.realtimeSinceStartup;
        Assembly assembly = typeof(AbstractStory).Assembly;

        // Use reflection to grab all of the subclasses of AbstractStory.
        // Definitely eats performance. But this *should* only be called once at the start of the game?
        Type[] storyClasses = assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(AbstractStory))).ToArray();        // Could also use t.baseClass == typeof(AbstractStory)
        foreach (Type story in storyClasses)
        {
            // For each story that inherits from AbstractStory, create one instance of it to grab the ID so we can form an ID -> class pairing.
            AbstractStory instance = Activator.CreateInstance(story) as AbstractStory;
            table.Add(instance.STORY_ID, story);
        }
        float endStartUp = Time.realtimeSinceStartup;

        Debug.Log("StoryLibrary loaded definition of ALL stories; took " + (endStartUp - startUp) + " seconds.");
    }