示例#1
0
 public FormData(int species, int form, Enums.Gender gender, Enums.Coloration shiny)
 {
     Species = species;
     Form    = form;
     Gender  = gender;
     Shiny   = shiny;
 }
示例#2
0
 public FormData(int species, int form, Enums.Gender gender, Enums.Coloration shiny)
 {
     Species = species;
     Form = form;
     Gender = gender;
     Shiny = shiny;
 }
示例#3
0
 public void LoadMember(int slot, string name, int mugshot, int form, Enums.Coloration shiny, Enums.Sex gender, ulong exp, ulong maxExp, int hp, int maxHP)
 {
     members[slot]               = new PartyMember();
     members[slot].Name          = name;
     members[slot].MugshotNum    = mugshot;
     members[slot].MugshotForm   = form;
     members[slot].MugshotShiny  = shiny;
     members[slot].MugshotGender = gender;
     members[slot].Exp           = exp;
     members[slot].MaxExp        = maxExp;
     members[slot].HP            = hp;
     members[slot].MaxHP         = maxHP;
 }
示例#4
0
        public void Load(string id, string parentMapID, int x, int y, int sprite, int form, Enums.Coloration shiny, Enums.Sex gender)
        {
            this.id          = id;
            this.parentMapID = parentMapID;
            this.x           = x;
            this.y           = y;
            this.sprite      = sprite;
            this.form        = form;
            this.shiny       = shiny;
            this.gender      = gender;

            if (this.parentMapID == "s-2")
            {
                this.parentMapID = "-2";
            }
        }
示例#5
0
        public static TileSheet GetMugshot(int num, int form, Enums.Coloration shiny, Enums.Gender gender)
        {
            string formString = "r";

            if (form >= 0)
            {
                formString += "-" + form;
                if (shiny >= 0)
                {
                    formString += "-" + (int)shiny;
                    if (gender >= 0)
                    {
                        formString += "-" + (int)gender;
                    }
                }
            }

            TileSheet sheet = mugshotCache.Get(num + formString);

            if (sheet != null)
            {
                return(sheet);
            }

            try
            {
                // If we are still here, that means the sprite wasn't in the cache
                if (File.Exists(Paths.CachedGFXPath + "Portrait\\Portrait" + num + ".portrait"))
                {
                    sheet = new TileSheet();
                    string changedFormString = formString;

                    using (FileStream fileStream = File.OpenRead(Paths.CachedGFXPath + "Portrait\\Portrait" + num + ".portrait"))
                    {
                        using (BinaryReader reader = new BinaryReader(fileStream))
                        {
                            int formCount = reader.ReadInt32();
                            Dictionary <string, int[]> formData = new Dictionary <string, int[]>();

                            for (int i = 0; i < formCount; i++)
                            {
                                // Read the form name
                                string formName = reader.ReadString();

                                int[] formIntData = new int[2];

                                // Load form position
                                formIntData[0] = reader.ReadInt32();
                                // Load form size
                                formIntData[1] = reader.ReadInt32();

                                // Add form data to collection
                                formData.Add(formName, formIntData);
                            }

                            while (true)
                            {
                                if (mugshotCache.ContainsKey(num + changedFormString))
                                {//this point will be hit if the first fallback data to be found is already in the cache
                                 //the cache needs to be updated for aliases, but that's it.  No need to load any new data.

                                    sheet = mugshotCache.Get(num + changedFormString);
                                    break;
                                }
                                else if (formData.ContainsKey(changedFormString) || changedFormString == "r")
                                {//we've found a spritesheet in the file, so load it.
                                    int[] formInt = formData[changedFormString];

                                    // Jump to the correct position
                                    fileStream.Seek(formInt[0], SeekOrigin.Current);

                                    try
                                    {
                                        int    frameCount = reader.ReadInt32();
                                        int    size       = reader.ReadInt32();
                                        byte[] imgData    = reader.ReadBytes(size);
                                        using (MemoryStream stream = new MemoryStream(imgData))
                                        {
                                            sheet.LoadPixelsFromBytes(stream);
                                            sheet.LoadTextureFromPixels32();
                                        }

                                        sheet.GenerateDataBuffer(sheet.ImageWidth / frameCount, sheet.ImageHeight);
                                    }
                                    catch (Exception ex)
                                    {
                                        sheet.Dispose();
                                        throw new Exception("Error reading image data.\n", ex);
                                    }

                                    mugshotCache.Add(num + changedFormString, sheet);

                                    break;
                                }

                                // If the form specified wasn't found, continually revert to the backup until only "r" is reached
                                changedFormString = changedFormString.Substring(0, changedFormString.LastIndexOf('-'));
                            }
                        }
                    }

                    //continually add aliases
                    string aliasString = formString;
                    while (aliasString != changedFormString)
                    {
                        //add aliases here
                        mugshotCache.AddAlias(num + aliasString, num + changedFormString);
                        // If the form specified wasn't found, continually revert to the backup until only "r" is reached
                        aliasString = aliasString.Substring(0, aliasString.LastIndexOf('-'));
                    }

                    return(sheet);
                }
            }
            catch (Exception ex)
            {
                Logs.Logger.LogError(new Exception("Error retrieving portrait " + num + " " + formString + "\n", ex));
            }

            //add error sheet
            mugshotCache.Add(num + formString, ErrorTexture);
            return(ErrorTexture);
        }
示例#6
0
        public static SpriteSheet GetSpriteSheet(int num, int form, Enums.Coloration shiny, Enums.Gender gender)
        {
            string formString = "r";

            if (form >= 0)
            {
                formString += "-" + form;
                if (shiny >= 0)
                {
                    formString += "-" + (int)shiny;
                    if (gender >= 0)
                    {
                        formString += "-" + (int)gender;
                    }
                }
            }

            SpriteSheet sheet = spriteCache.Get(num + formString);

            if (sheet != null)
            {
                return(sheet);
            }

            try
            {
                // If we are still here, that means the sprite wasn't in the cache
                if (File.Exists(Paths.CachedGFXPath + "Sprite\\Sprite" + num + ".sprite"))
                {
                    sheet = new SpriteSheet();
                    string changedFormString = formString;

                    using (FileStream fileStream = File.OpenRead(Paths.CachedGFXPath + "Sprite\\Sprite" + num + ".sprite"))
                    {
                        using (BinaryReader reader = new BinaryReader(fileStream))
                        {
                            int formCount = reader.ReadInt32();
                            Dictionary <string, int[]> formData = new Dictionary <string, int[]>();

                            for (int i = 0; i < formCount; i++)
                            {
                                // Read the form name
                                string formName = reader.ReadString();

                                int[] formIntData = new int[2];

                                // Load form position
                                formIntData[0] = reader.ReadInt32();
                                // Load form size
                                formIntData[1] = reader.ReadInt32();

                                // Add form data to collection
                                formData.Add(formName, formIntData);
                            }

                            while (true)
                            {
                                if (spriteCache.ContainsKey(num + changedFormString))
                                {//this point will be hit if the first fallback data to be found is already in the cache
                                 //the cache needs to be updated for aliases, but that's it.  No need to load any new data.

                                    sheet = spriteCache.Get(num + changedFormString);
                                    break;
                                }
                                else if (formData.ContainsKey(changedFormString) || changedFormString == "r")
                                {//we've found a spritesheet in the file, so load it.
                                    int[] formInt = formData[changedFormString];

                                    // Jump to the correct position
                                    fileStream.Seek(formInt[0], SeekOrigin.Current);

                                    sheet.LoadFromData(reader, formInt[1]);

                                    spriteCache.Add(num + changedFormString, sheet);

                                    break;
                                }

                                // If the form specified wasn't found, continually revert to the backup until only "r" is reached
                                changedFormString = changedFormString.Substring(0, changedFormString.LastIndexOf('-'));
                            }
                        }
                    }

                    //continually add aliases
                    string aliasString = formString;
                    while (aliasString != changedFormString)
                    {
                        //add aliases here
                        spriteCache.AddAlias(num + aliasString, num + changedFormString);
                        // If the form specified wasn't found, continually revert to the backup until only "r" is reached
                        aliasString = aliasString.Substring(0, aliasString.LastIndexOf('-'));
                    }

                    //string rootForm = spriteCache.GetOriginalKeyFromAlias(num + formString);
                    //if (rootForm != num + formString)
                    //{
                    //    Logs.Logger.LogDebug("Could not load " + num + formString + ", loaded " + num + rootForm +" instead.");
                    //}

                    return(sheet);
                }
            }
            catch (Exception ex)
            {
                Logs.Logger.LogError(new Exception("Error retrieving sprite " + num + " " + formString + "\n", ex));
            }

            //add error sheet
            sheet = new SpriteSheet();
            spriteCache.Add(num + formString, sheet);
            return(sheet);
        }
示例#7
0
        public void Load(string id, string parentMapID, int x, int y, int sprite, int form, Enums.Coloration shiny, Enums.Sex gender)
        {
            this.id = id;
            this.parentMapID = parentMapID;
            this.x = x;
            this.y = y;
            this.sprite = sprite;
            this.form = form;
            this.shiny = shiny;
            this.gender = gender;

            if (this.parentMapID == "s-2") {
                this.parentMapID = "-2";
            }
        }
示例#8
0
 public CreateFNPCSegment(string id, string parentMapID, int x, int y, int sprite, int form, Enums.Coloration shiny, Enums.Sex gender)
 {
     Load(id, parentMapID, x, y, sprite, form, shiny, gender);
 }