Exemple #1
0
    public void UpdateStoryScreen(Storylet currentStorylet)
    {
        currentStory = currentStorylet;
        GameObject choicesObjectParent = GameObject.Find("Choices");


        //Removing already present elements
        for (int i = 0; i < choicesObjectParent.transform.childCount; i++)
        {
            Transform child = choicesObjectParent.transform.GetChild(i);
            Destroy(child.gameObject);
        }

        storylets.Remove(currentStorylet.GetName());

        //Updating the current position of the Story
        GameManager.instance.chapterTitle.text = currentStorylet.GetName();
        charachter.position            = currentStorylet.GetPostCondition().position;
        GameManager.instance.text.text = ProcessText(currentStorylet.GetText());
        AddCurrentSupportActors(currentStorylet);



        //Displaying next possible storylets
        List <Storylet> nextStorylets = new List <Storylet>();

        foreach (KeyValuePair <string, Storylet> storylet in storylets)
        {
            Debug.Log("Current Post :" + currentStory.GetPostCondition().position);
            Debug.Log("<color=red>Next Pre: </color>" + storylet.Value.GetPrecondition().position);
            if (storylet.Value.GetPrecondition().position.Equals(currentStorylet.GetPostCondition().position))
            {
                nextStorylets.Add(storylet.Value);
            }
        }


        foreach (Storylet storylet in nextStorylets)
        {
            GameObject choice = Instantiate(GameManager.instance.choicePrefab);
            choice.transform.parent = choicesObjectParent.transform;
            choice.GetComponentInChildren <TextMeshProUGUI>().text = storylet.GetTileDisplayText();
            choice.GetComponent <Button>().onClick.AddListener(() => UpdateStoryScreen(storylet));
        }
    }
Exemple #2
0
 void AddCurrentSupportActors(Storylet storylet)
 {
     foreach (string s in storylet.GetPostCondition().actors)
     {
         if (!supportActors.Contains(s))
         {
             supportActors.Add(s);
         }
     }
 }