Ejemplo n.º 1
0
    public ConversationDependancy(JSONNode dependancyJSON)
    {
        var jsonType = dependancyJSON["type"];

        switch (jsonType)
        {
        case "player-has":
            type = DependancyType.PlayerHasItem;
            break;

        case "player-does-not-have":
            type = DependancyType.PlayerDoesNotHaveItem;
            break;

        default:
            Debug.LogError("Unknown dependancy type");
            return;
        }

        var actionsJSON = dependancyJSON["actions"];

        if (actionsJSON == null)
        {
            actions = null;
        }
        else
        {
            actions = new ConversationAction[actionsJSON.Count];
            for (int i = 0; i < actionsJSON.Count; i++)
            {
                actions[i] = new ConversationAction(actionsJSON[i]);
            }
        }

        objects = ConversationLoader.JSONToStringArray(dependancyJSON, "objects");
    }
Ejemplo n.º 2
0
    public ConversationAction(JSONNode actionJSON)
    {
        string JSONtype = actionJSON["action"];

        switch (JSONtype)
        {
        case "remove-item":
            type = ActionType.RemoveItem;
            break;

        case "add-item":
            type = ActionType.AddItem;
            break;

        case "replace-responses":
            type = ActionType.ReplaceResponses;
            break;

        case "walk-to":
            type = ActionType.WalkTo;
            break;

        case "run-conversation":
            type = ActionType.RunConversation;
            break;

        case "set-flag":
            type = ActionType.SetFlag;
            break;

        case "say":
            type = ActionType.Say;
            break;

        default:
            type = ActionType.AddItem;
            break;
        }

        objects = ConversationLoader.JSONToStringArray(actionJSON, "objects");

        var requirementsJSON = actionJSON["requirements"];

        if (requirementsJSON == null)
        {
            requirements = null;
        }
        else
        {
            requirements = new ActionRequirement[requirementsJSON.Count];
            for (int i = 0; i < requirementsJSON.Count; i++)
            {
                requirements[i] = new ActionRequirement(requirementsJSON[i]);
            }
        }

        var actionsJSON = actionJSON["actions"];

        if (actionsJSON == null)
        {
            nextActions = null;
        }
        else
        {
            nextActions = new ConversationAction[actionsJSON.Count];
            for (int i = 0; i < actionsJSON.Count; i++)
            {
                nextActions[i] = new ConversationAction(actionsJSON[i]);
            }
        }
    }