Beispiel #1
0
        public static Story LoadStory(int storyNum)
        {
            Story  story    = new Story();
            string FileName = IO.Paths.StoriesFolder + "story" + storyNum + ".dat";

            using (System.IO.StreamReader read = new System.IO.StreamReader(FileName)) {
                string   str;
                string[] parse;
                while (!(read.EndOfStream))
                {
                    str   = read.ReadLine();
                    parse = str.Split('|');
                    switch (parse[0].ToLower())
                    {
                    case "storydata":
                        if (parse[1].ToLower() != "v3")
                        {
                            read.Close();
                            return(null);
                        }
                        story.Revision = parse[2].ToInt();
                        break;

                    case "data": {
                        story.Name       = parse[1];
                        story.StoryStart = parse[2].ToInt();
                    }
                    break;

                    case "segment": {
                        StorySegment segment = new StorySegment();
                        story.Segments.Add(segment);
                        story.Segments[parse[1].ToInt()].Action = (StorySegment.StoryAction)parse[2].ToInt();
                        int totalParameters = parse[3].ToInt();
                        int z = 4;
                        for (int i = 0; i < totalParameters; i++)
                        {
                            segment.Parameters.Add(parse[z], parse[z + 1]);

                            z += 2;
                        }
                    }
                    break;

                    case "exitandcontinue": {
                        int max = parse[1].ToInt();
                        int z   = 2;
                        for (int i = 0; i < max; i++)
                        {
                            story.ExitAndContinue.Add(parse[z].ToInt());
                            z++;
                        }
                    }
                    break;
                    }
                }
            }
            return(story);
        }
Beispiel #2
0
        public static Story LoadStory(int storyNum)
        {
            Story story = new Story();
            string FileName = IO.Paths.StoriesFolder + "story" + storyNum + ".dat";
            using (System.IO.StreamReader read = new System.IO.StreamReader(FileName)) {
                string str;
                string[] parse;
                while (!(read.EndOfStream)) {
                    str = read.ReadLine();
                    parse = str.Split('|');
                    switch (parse[0].ToLower()) {
                        case "storydata":
                            if (parse[1].ToLower() != "v3") {
                                read.Close();
                                return null;
                            }
                            story.Revision = parse[2].ToInt();
                            break;
                        case "data": {
                                story.Name = parse[1];
                                story.StoryStart = parse[2].ToInt();
                            }
                            break;
                        case "segment": {
                                StorySegment segment = new StorySegment();
                                story.Segments.Add(segment);
                                story.Segments[parse[1].ToInt()].Action = (StorySegment.StoryAction)parse[2].ToInt();
                                int totalParameters = parse[3].ToInt();
                                int z = 4;
                                for (int i = 0; i < totalParameters; i++) {
                                    segment.Parameters.Add(parse[z], parse[z + 1]);

                                    z += 2;
                                }
                            }
                            break;
                        case "exitandcontinue": {
                                int max = parse[1].ToInt();
                                int z = 2;
                                for (int i = 0; i < max; i++) {
                                    story.ExitAndContinue.Add(parse[z].ToInt());
                                    z++;
                                }
                            }
                            break;
                    }
                }
            }
            return story;
        }
Beispiel #3
0
        public static Stories.V3.StorySegment ConvertSegment(Stories.V2.StorySegment segment)
        {
            Stories.V3.StorySegment newSegment = new Stories.V3.StorySegment();
            //bool paramsNeeded = true; ;
            switch (segment.Action) {
                case Stories.V2.StorySegment.StoryAction.SaySlow: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Say;

                        newSegment.Parameters.Add("Text", segment.Data1);
                        newSegment.Parameters.Add("Mugshot", segment.Data3);
                        newSegment.Parameters.Add("Speed", segment.Data2);
                        newSegment.Parameters.Add("PauseLocation", segment.Data4);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Say: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Say;

                        newSegment.AddParameter("Text", segment.Data1);
                        newSegment.AddParameter("Mugshot", segment.Data3);
                        newSegment.Parameters.Add("Speed", "0");
                        newSegment.Parameters.Add("PauseLocation", "0");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Pause: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Pause;

                        newSegment.AddParameter("Length", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HideMap: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.MapVisibility;

                        newSegment.Parameters.Add("Visible", "False");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowMap: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.MapVisibility;

                        newSegment.Parameters.Add("Visible", "True");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Unlock: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Padlock;

                        newSegment.AddParameter("State", "Unlock");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Lock: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Padlock;

                        newSegment.AddParameter("State", "Lock");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.PlayMusic: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayMusic;

                        newSegment.AddParameter("File", segment.Data1);
                        newSegment.AddParameter("HonorSettings", segment.Data2);
                        newSegment.AddParameter("Loop", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.StopMusic: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.StopMusic;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowImage: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowImage;

                        newSegment.AddParameter("File", segment.Data1);
                        newSegment.AddParameter("ImageID", segment.Data4);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HideImage: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.HideImage;

                        newSegment.AddParameter("ImageID", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.WarpToMap: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.Warp;

                        newSegment.AddParameter("MapID", "s" + segment.Data1);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.LockPlayer: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayerPadlock;

                        newSegment.AddParameter("MovementState", "Lock");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.UnlockPlayer: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayerPadlock;

                        newSegment.AddParameter("MovementState", "Unlock");
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowBackground: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowBackground;

                        newSegment.AddParameter("File", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HideBackground: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.HideBackground;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.CreateNPC: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.CreateFNPC;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("ParentMapID", segment.Data2);
                        newSegment.AddParameter("X", segment.Data3);
                        newSegment.AddParameter("Y", segment.Data4);
                        newSegment.AddParameter("Sprite", segment.Data5);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.MoveNPC: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.MoveFNPC;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                        newSegment.AddParameter("Speed", segment.Data4);
                        newSegment.AddParameter("Pause", segment.Data5);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.MoveNPCQuick: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.WarpFNPC;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ChangeNPCDir: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ChangeFNPCDir;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("Direction", segment.Data2);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.DeleteNPC: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.DeleteFNPC;

                        newSegment.AddParameter("ID", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.StoryScript: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.RunScript;

                        newSegment.AddParameter("ScriptIndex", segment.Data1);
                        newSegment.AddParameter("Pause", segment.Data2);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HidePlayers: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.HidePlayers;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowPlayers: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowPlayers;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.NPCEmotion: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.FNPCEmotion;

                        newSegment.AddParameter("ID", segment.Data1);
                        newSegment.AddParameter("Emotion", segment.Data2);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.Weather: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ChangeWeather;

                        newSegment.AddParameter("Weather", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.HideNPCs: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.HideNPCs;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ShowNPCs: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowNPCs;
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.WaitForMap: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.WaitForMap;

                        newSegment.AddParameter("MapID", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.WaitForLoc: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.WaitForLoc;

                        newSegment.AddParameter("MapID", segment.Data1);
                        newSegment.AddParameter("X", segment.Data2);
                        newSegment.AddParameter("Y", segment.Data3);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.AskQuestion: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.AskQuestion;

                        newSegment.AddParameter("Question", segment.Data1);
                        newSegment.AddParameter("SegmentOnYes", segment.Data2);
                        newSegment.AddParameter("SegmentOnNo", segment.Data3);
                        newSegment.AddParameter("Mugshot", segment.Data5); // I used Data5 instead of Data4 in the old system, for some reason...
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.GoToSegment: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.GoToSegment;

                        newSegment.AddParameter("Segment", segment.Data1);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ScrollCamera: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ScrollCamera;

                        newSegment.AddParameter("X", segment.Data1);
                        newSegment.AddParameter("Y", segment.Data2);
                        newSegment.AddParameter("Speed", segment.Data3);
                        newSegment.AddParameter("Pause", segment.Data4);
                    }
                    break;
                case Stories.V2.StorySegment.StoryAction.ResetCamera: {
                        newSegment.Action = Stories.V3.StorySegment.StoryAction.ResetCamera;
                    }
                    break;
            }
            return newSegment;
        }
Beispiel #4
0
        public static Stories.V3.StorySegment ConvertSegment(Stories.V2.StorySegment segment)
        {
            Stories.V3.StorySegment newSegment = new Stories.V3.StorySegment();
            //bool paramsNeeded = true; ;
            switch (segment.Action)
            {
            case Stories.V2.StorySegment.StoryAction.SaySlow: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.Say;

                newSegment.Parameters.Add("Text", segment.Data1);
                newSegment.Parameters.Add("Mugshot", segment.Data3);
                newSegment.Parameters.Add("Speed", segment.Data2);
                newSegment.Parameters.Add("PauseLocation", segment.Data4);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.Say: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.Say;

                newSegment.AddParameter("Text", segment.Data1);
                newSegment.AddParameter("Mugshot", segment.Data3);
                newSegment.Parameters.Add("Speed", "0");
                newSegment.Parameters.Add("PauseLocation", "0");
            }
            break;

            case Stories.V2.StorySegment.StoryAction.Pause: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.Pause;

                newSegment.AddParameter("Length", segment.Data1);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.HideMap: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.MapVisibility;

                newSegment.Parameters.Add("Visible", "False");
            }
            break;

            case Stories.V2.StorySegment.StoryAction.ShowMap: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.MapVisibility;

                newSegment.Parameters.Add("Visible", "True");
            }
            break;

            case Stories.V2.StorySegment.StoryAction.Unlock: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.Padlock;

                newSegment.AddParameter("State", "Unlock");
            }
            break;

            case Stories.V2.StorySegment.StoryAction.Lock: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.Padlock;

                newSegment.AddParameter("State", "Lock");
            }
            break;

            case Stories.V2.StorySegment.StoryAction.PlayMusic: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayMusic;

                newSegment.AddParameter("File", segment.Data1);
                newSegment.AddParameter("HonorSettings", segment.Data2);
                newSegment.AddParameter("Loop", segment.Data3);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.StopMusic: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.StopMusic;
            }
            break;

            case Stories.V2.StorySegment.StoryAction.ShowImage: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowImage;

                newSegment.AddParameter("File", segment.Data1);
                newSegment.AddParameter("ImageID", segment.Data4);
                newSegment.AddParameter("X", segment.Data2);
                newSegment.AddParameter("Y", segment.Data3);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.HideImage: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.HideImage;

                newSegment.AddParameter("ImageID", segment.Data1);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.WarpToMap: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.Warp;

                newSegment.AddParameter("MapID", "s" + segment.Data1);
                newSegment.AddParameter("X", segment.Data2);
                newSegment.AddParameter("Y", segment.Data3);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.LockPlayer: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayerPadlock;

                newSegment.AddParameter("MovementState", "Lock");
            }
            break;

            case Stories.V2.StorySegment.StoryAction.UnlockPlayer: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.PlayerPadlock;

                newSegment.AddParameter("MovementState", "Unlock");
            }
            break;

            case Stories.V2.StorySegment.StoryAction.ShowBackground: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowBackground;

                newSegment.AddParameter("File", segment.Data1);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.HideBackground: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.HideBackground;
            }
            break;

            case Stories.V2.StorySegment.StoryAction.CreateNPC: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.CreateFNPC;

                newSegment.AddParameter("ID", segment.Data1);
                newSegment.AddParameter("ParentMapID", segment.Data2);
                newSegment.AddParameter("X", segment.Data3);
                newSegment.AddParameter("Y", segment.Data4);
                newSegment.AddParameter("Sprite", segment.Data5);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.MoveNPC: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.MoveFNPC;

                newSegment.AddParameter("ID", segment.Data1);
                newSegment.AddParameter("X", segment.Data2);
                newSegment.AddParameter("Y", segment.Data3);
                newSegment.AddParameter("Speed", segment.Data4);
                newSegment.AddParameter("Pause", segment.Data5);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.MoveNPCQuick: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.WarpFNPC;

                newSegment.AddParameter("ID", segment.Data1);
                newSegment.AddParameter("X", segment.Data2);
                newSegment.AddParameter("Y", segment.Data3);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.ChangeNPCDir: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.ChangeFNPCDir;

                newSegment.AddParameter("ID", segment.Data1);
                newSegment.AddParameter("Direction", segment.Data2);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.DeleteNPC: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.DeleteFNPC;

                newSegment.AddParameter("ID", segment.Data1);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.StoryScript: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.RunScript;

                newSegment.AddParameter("ScriptIndex", segment.Data1);
                newSegment.AddParameter("Pause", segment.Data2);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.HidePlayers: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.HidePlayers;
            }
            break;

            case Stories.V2.StorySegment.StoryAction.ShowPlayers: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowPlayers;
            }
            break;

            case Stories.V2.StorySegment.StoryAction.NPCEmotion: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.FNPCEmotion;

                newSegment.AddParameter("ID", segment.Data1);
                newSegment.AddParameter("Emotion", segment.Data2);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.Weather: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.ChangeWeather;

                newSegment.AddParameter("Weather", segment.Data1);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.HideNPCs: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.HideNPCs;
            }
            break;

            case Stories.V2.StorySegment.StoryAction.ShowNPCs: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.ShowNPCs;
            }
            break;

            case Stories.V2.StorySegment.StoryAction.WaitForMap: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.WaitForMap;

                newSegment.AddParameter("MapID", segment.Data1);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.WaitForLoc: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.WaitForLoc;

                newSegment.AddParameter("MapID", segment.Data1);
                newSegment.AddParameter("X", segment.Data2);
                newSegment.AddParameter("Y", segment.Data3);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.AskQuestion: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.AskQuestion;

                newSegment.AddParameter("Question", segment.Data1);
                newSegment.AddParameter("SegmentOnYes", segment.Data2);
                newSegment.AddParameter("SegmentOnNo", segment.Data3);
                newSegment.AddParameter("Mugshot", segment.Data5);         // I used Data5 instead of Data4 in the old system, for some reason...
            }
            break;

            case Stories.V2.StorySegment.StoryAction.GoToSegment: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.GoToSegment;

                newSegment.AddParameter("Segment", segment.Data1);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.ScrollCamera: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.ScrollCamera;

                newSegment.AddParameter("X", segment.Data1);
                newSegment.AddParameter("Y", segment.Data2);
                newSegment.AddParameter("Speed", segment.Data3);
                newSegment.AddParameter("Pause", segment.Data4);
            }
            break;

            case Stories.V2.StorySegment.StoryAction.ResetCamera: {
                newSegment.Action = Stories.V3.StorySegment.StoryAction.ResetCamera;
            }
            break;
            }
            return(newSegment);
        }