public static IntroContainer Load(string path) { var serializer = new XmlSerializer(typeof(IntroContainer)); IntroContainer deserialized = null; string path2; #if WINDOWS_UWP path2 = Path.GetFullPath(Path.Combine(Application.persistentDataPath + "/" + "data.xml")); try { using (FileStream reader = File.Open(path2, FileMode.Open)) { return(serializer.Deserialize(reader) as IntroContainer); } } catch (System.Exception e) { Debug.LogWarningFormat("Error loading animation : {0}", e.Message); return(deserialized); } #else using (var stream = new FileStream(path, FileMode.Open)) { return(serializer.Deserialize(stream) as IntroContainer); } #endif }
void populateIntro() { var IntroPageCollection = IntroContainer.Load(Path.Combine(Application.dataPath, "Resources/data.xml")); foreach (IntroPage page in IntroPageCollection.Pages) { GameObject myPage = Instantiate(introPrefab, new Vector3(0, 0, 0), Quaternion.identity); //create new introPage instant myPage.transform.parent = intro.transform; //make this child to intro in hierarchy //populate it with data from IntroPageCollection //add dialogue myPage.transform.Find("text").GetComponent <TextMeshPro>().text = page.dialogue; //add page number myPage.transform.GetComponent <IntroPageController>().number = page.number; myPage.name = "Page" + page.number; GameObject ButtonLabel = myPage.transform.Find("ButtonNext").transform.GetChild(0).transform.Find("Text").gameObject; GameObject ButtonPrevious = myPage.transform.Find("ButtonPrevious").gameObject; if (page.number == IntroPageCollection.Pages.Length - 1) { ButtonLabel.GetComponent <TextMeshPro>().text = "Finish"; //Finish label in last page } if (page.number == 0) { ButtonPrevious.SetActive(false); // not previous button at the 1st page } //add directional arrow to corresponding artifact or deactivate arrow if (page.directional == -1) //for pages that should point at an artifact { myPage.transform.Find("GuideArrow").gameObject.SetActive(false); } else if (page.directional == -2) //for pages that shouldnt have an arrow nor text { myPage.transform.Find("GuideArrow").gameObject.SetActive(false); myPage.transform.Find("text").gameObject.SetActive(false); } else { myPage.transform.Find("GuideArrow").GetComponent <ArrowHandler>().DirectionalTarget = arts.transform.GetChild(page.directional); } //add image MeshRenderer mr = myPage.transform.Find("BigCapsule").GetComponent <MeshRenderer>(); mr.material = Resources.Load(page.image, typeof(Material)) as Material; //deactivate page myPage.gameObject.SetActive(false); } }
static IntroHelper LoadIntro(IntroContainer Intro, Size Size) { var Helper = new IntroHelper(); int Steps = 100; Helper.Fade = new Bitmap[Steps]; using (var Texture = Intro.Texture) { Color Pixel = Texture.GetPixel(0, 0); Helper.Background = Color.FromArgb(255, Pixel); Helper.Position = Texture.Size.GetCenterPoint(Size); } for (int Step = 0; Step < Steps; Step++) { using (var Texture = Intro.Texture) { Bitmap Opacity = SetBitmapOpacity(Texture, ((float)Step) / Steps); Bitmap Result = new Bitmap(Texture.Width, Texture.Height); using (Graphics Draw = Graphics.FromImage(Result)) { Draw.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; Draw.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; Draw.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.High; Draw.Clear(Helper.Background); Draw.DrawImage(Opacity, 0, 0); Draw.Flush(); Helper.Fade[Step] = Result; } Opacity.Dispose(); } } if (Intro.HasSound) { Helper.Sound = Intro.Wav; } else { Helper.Sound = null; } return(Helper); }
/// <summary> /// Build the String.srl /// </summary> internal static void CompileStrMap() { var DBAr = new List <SRLDatabase2>(); var COri = new List <char>(); var CFak = new List <char>(); var UOri = new List <char>(); var UErr = new List <ushort>(); var ROri = new List <string>(); var RNew = new List <string>(); if (File.Exists(CharMapSrc)) { Log("Compiling Char Reloads..."); using (TextReader Reader = File.OpenText(CharMapSrc)) { while (Reader.Peek() >= 0) { string line = Reader.ReadLine(); if (line.Length == 3 && line[1] == '=') { char cOri = line[0], cFak = line[2]; COri.Add(cOri); CFak.Add(cFak); } if (line.Contains("0x") && line.Contains('=')) { string hex = line.Split('=')[1].Split('x')[1]; ushort Val = ushort.Parse(hex, System.Globalization.NumberStyles.HexNumber); UOri.Add(line[0]); UErr.Add(Val); } } Reader.Close(); } } Log("Generating String Reload Database..."); //Splited String Dump string[] TLMaps = Directory.GetFiles(BaseDir, Path.GetFileName(string.Format(TLMapSrcMsk, "*"))); foreach (string TLMap in TLMaps) { var In = new List <string>(); var Out = new List <string>(); ReadDump(TLMap, ref In, ref Out, IgnoreMask: true); const string NamedLstPrefix = "Strings-"; string DBN = Path.GetFileNameWithoutExtension(TLMap); DBN = DBN.Substring(NamedLstPrefix.Length); DBAr.Add(new SRLDatabase2() { Original = In.ToArray(), Replace = Out.ToArray(), Name = DBN }); Log("{0} Found, Importing, Database ID: {1}...", false, Path.GetFileName(TLMap), DBAr.Count - 1); } if (File.Exists(TLMapSrc)) { var In = new List <string>(); var Out = new List <string>(); ReadDump(TLMapSrc, ref In, ref Out, IgnoreMask: true); DBAr.Add(new SRLDatabase2() { Original = In.ToArray(), Replace = Out.ToArray(), Name = Path.GetFileNameWithoutExtension(TLMapSrc) }); Log("{0} Found, Importing, Database ID: {1}...", false, Path.GetFileName(TLMapSrc), DBAr.Count - 1); } var DBS = DBAr.ToArray(); var Ilegals = CFak.ToArray(); SearchViolations(DBS, Ilegals); if (RemoveIlegals) { RemoveViolations(ref DBS, Ilegals); } Log("{0} Databases Generated.", true, DBAr.Count); if (File.Exists(ReplLst)) { Log("Compiling Replace List..."); ReadDump(ReplLst, ref ROri, ref RNew); } Log("Building String Reloads..."); SRLData3 Data = new SRLData3() { Signature = "SRL3", Version = 1, Databases = DBS, OriLetters = COri.ToArray(), MemoryLetters = Ilegals, UnkChars = UErr.ToArray(), UnkReps = UOri.ToArray(), RepOri = ROri.ToArray(), RepTrg = RNew.ToArray() }; List <IntroContainer> Container = new List <IntroContainer>(); while (File.Exists(string.Format(IntroMsk, Container.Count, "png"))) { string pTexture = string.Format(IntroMsk, Container.Count, "png"); string pSound = string.Format(IntroMsk, Container.Count, "wav"); IntroContainer cContainer = new IntroContainer() { Bitmap = File.ReadAllBytes(pTexture), Wav = new byte[0] }; if (File.Exists(pSound)) { cContainer.Wav = File.ReadAllBytes(pSound); } Container.Add(cContainer); } SRLIntro Intros = new SRLIntro() { Intros = Container.ToArray() }; Log("{0} Intro(s) Found", true, Intros.Intros.Length); if (File.Exists(TLMap)) { File.Delete(TLMap); } using (StructWriter Writer = new StructWriter(TLMap)){ Writer.WriteStruct(ref Data); Writer.WriteStruct(ref Intros); Writer.Close(); } Log("Builded Successfully."); }