Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // QuestDataLoader.js
- // Loads the Quest Data into the QuestManager
- // Works on Start with ExecuteInEditMode()
- // Attach to a GameObject (and for convenience make it a child of QuestManager)
- // Leave the GameObject it is attached to DEACTIVATED unless you want to reload the quest data.
- // REMOVE THIS GameObject before release!
- // Requires a text file from Questy.fmp.
- // Replace all % with <PR><PR>
- // Replace all <tab>#<PR> with #
- // Remove last "#" and any TRAILING WHITE SPACE from the output file!
- #pragma strict
- @script ExecuteInEditMode ()
- var gameController : GameController;
- var questData : TextAsset;
- var questArray : Quest[];
- function Start () {
- gameController.questsArray = QuestDataLoader();
- }
- function QuestDataLoader () {
- var questDataText = questData.text;
- var dynamicQuestArray : Array = new Array ();
- var quests = questDataText.Split("#"[0]);
- for (var quest : String in quests) {
- var questDetails = quest.Split("|"[0]);
- var currentQuest : Quest = new Quest ();
- var tempData : String = questDetails[0].ToString();
- currentQuest.id = int.Parse(tempData);
- tempData = questDetails[1].ToString();
- currentQuest.progress = int.Parse(tempData);
- currentQuest.title = questDetails[2].ToString();
- currentQuest.description = questDetails[3].ToString();
- currentQuest.hint = questDetails[4].ToString();
- currentQuest.summary = questDetails[5].ToString();
- currentQuest.congratulations = questDetails[6].ToString();
- tempData = questDetails[7].ToString();
- if (tempData != "")
- currentQuest.nextQuest = int.Parse(tempData);
- currentQuest.questObjective = questDetails[8].ToString();
- tempData = questDetails[9].ToString();
- if (tempData != "")
- currentQuest.questObjectiveRequirement = int.Parse(tempData);
- // else
- // currentQuest.nextQuest = null;
- dynamicQuestArray.Push (currentQuest);
- }
- // Copy the js array into a builtin array
- questArray = dynamicQuestArray.ToBuiltin(Quest);
- // To Check that the data has been pushed and copied to the final array (CURRENTLY STALE! NEW FIELDS NEED TO BE INCLUDED!)
- // for (var checkQuest : Quest in questArray) {
- // Debug.Log ("ID: " + checkQuest.id + " Title: " + checkQuest.title + " Start Progress: " + checkQuest.progress + "\n\nDescription: " + checkQuest.description + "\n\nHint: " + checkQuest.hint + "\n\nSummary: " + checkQuest.summary + "\n\nCongratulations: " + checkQuest.congratulations + "\n\nNext Quest: " + checkQuest.nextQuest);
- // }
- return questArray;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement