Exemplo n.º 1
0
    public StoryEventStore()
    {
        defaultEvent.name = "Default";
        StoryEventResult defaultResult = new StoryEventResult();

        defaultResult.eventText = "Nothing happens. Seems that developers of this game have not implemented this event.";
    }
Exemplo n.º 2
0
 public void addResult(StoryEventResult addition)
 {
     results.Add(addition);
 }
Exemplo n.º 3
0
    StoryEvent readEvent(StreamReader reader)
    {
        StoryEvent       story  = new StoryEvent();
        StoryEventResult result = null;

        string line;

        //next line is name of event
        line       = reader.ReadLine();
        story.name = line;
        Debug.Log("title: " + line);

        while ((line = reader.ReadLine()) != null)
        {
            line = line.Trim();
            if (line.Equals("</event>") || line.Equals("</choise>"))
            {
                Debug.Log("returning: " + story.name);
                return(story);
            }

            story.addLocation(line);
            Debug.Log("location " + line);

            if (line.Equals("<required>"))
            {
                result = new StoryEventResult();

                // story
                line             = reader.ReadLine();
                line             = line.Trim();
                result.eventText = line;
                Debug.Log("new result: " + result.eventText);

                // to do: fault tolerance
                while (!(line = reader.ReadLine()).Equals("</required>"))
                {
                    result.requirements.Add(parseResource(line));
                }



                story.addResult(result);
            }

            if (line.Equals("<result>"))
            {
                while (!(line = reader.ReadLine().Trim()).Equals("</result>"))
                {
                    StoryResource temp = parseResource(line);
                    Debug.Log("adding result component " + temp.name + " " + temp.amount);
                    result.results.Add(temp);
                    //result.results.Add(parseResource(line));
                }
            }

            if (line.Equals("<choises>"))
            {
                while (!(line = reader.ReadLine().Trim()).Equals("</choises>"))
                {
                    Debug.Log("adding choise event " + line);
                    result.choises.Add(line);
                }
            }
        }


        Debug.Log("file ended prematurely, event not properly terminated.");
        return(story);
    }