Exemple #1
0
        public bool CanPlaceDecoration(byte id, byte x, byte y)
        {
            if (PlacedDecorations.Count >= 16)
            {
                return(false);
            }
            SecretBasePlacementTypes[,] finalGrid = FinalPlacementGrid;
            DecorationData decorationData = ItemDatabase.GetDecorationFromID(id);

            for (int x2 = 0; x2 < decorationData.Width; x2++)
            {
                for (int y2 = 0; y2 < decorationData.Height; y2++)
                {
                    int finalX = x - decorationData.OriginX + x2;
                    int finalY = y - decorationData.OriginY + y2;
                    if (finalX < 0 || finalY < 0 || finalX >= RoomData.Width || finalY >= RoomData.Height)
                    {
                        return(false);
                    }
                    SecretBasePlacementTypes place = decorationData.PlacementGrid[x2, y2];
                    if (!CanPlaceTypeOn(finalGrid[finalX, finalY], place))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
Exemple #2
0
        public DecorationData(DataRow row)
        {
            this.id             = (byte)(long)row["ID"];
            this.name           = row["Name"] as string;
            this.description    = row["Description"] as string;
            this.decorationType = DecorationData.GetDecorationTypeFromString(row["Type"] as string);
            this.price          = (uint)(long)row["Price"];
            this.coinsPrice     = (uint)(long)row["Coins"];
            this.bpPrice        = (uint)(long)row["BP"];
            this.sootPrice      = (uint)(long)row["Soot"];
            this.sale           = (bool)row["Sale"];

            CompileTypeData(row["DataType"] as string);
        }
        public static void Initialize()
        {
            ItemDatabase.gen3ImageMap = new Dictionary <ushort, BitmapSource>();
            ItemDatabase.gen3ItemMap  = new Dictionary <ushort, ItemData>();
            ItemDatabase.gen3ItemList = new List <ItemData>();

            ItemDatabase.pokeblockLargeImageMap = new Dictionary <PokeblockColors, BitmapSource>();
            ItemDatabase.pokeblockSmallImageMap = new Dictionary <PokeblockColors, BitmapSource>();

            ItemDatabase.decorationImageMap         = new Dictionary <byte, BitmapSource>();
            ItemDatabase.decorationFullSizeImageMap = new Dictionary <byte, BitmapSource>();
            ItemDatabase.decorationMap  = new Dictionary <byte, DecorationData>();
            ItemDatabase.decorationList = new List <DecorationData>();

            ItemDatabase.easyChatMap        = new Dictionary <ushort, string>();
            ItemDatabase.easyChatReverseMap = new Dictionary <string, ushort>();
            ItemDatabase.easyChatList       = new List <string>();

            ItemDatabase.pocketNamesMap = new Dictionary <ItemTypes, string>()
            {
                { ItemTypes.PC, "PC" },
                { ItemTypes.Items, "Items" },
                { ItemTypes.KeyItems, "Key Items" },
                { ItemTypes.PokeBalls, "Poké Balls" },
                { ItemTypes.TMCase, "TMs & HMs" },
                { ItemTypes.Berries, "Berries" },
                { ItemTypes.CologneCase, "Cologne Case" },
                { ItemTypes.DiscCase, "Disc Case" },
                { ItemTypes.InBattle, "In-Battle Items" },
                { ItemTypes.Valuables, "Valuable Items" },
                { ItemTypes.Hold, "Hold Items" },
                { ItemTypes.Misc, "Other Items" },
                { ItemTypes.Any, "Any" },
                { ItemTypes.TheVoid, "The Void" }
            };
            ItemDatabase.decorationContainerNamesMap = new Dictionary <DecorationTypes, string>()
            {
                { DecorationTypes.Desk, "Desks" },
                { DecorationTypes.Chair, "Chairs" },
                { DecorationTypes.Plant, "Plants" },
                { DecorationTypes.Ornament, "Ornaments" },
                { DecorationTypes.Mat, "Mats" },
                { DecorationTypes.Poster, "Posters" },
                { DecorationTypes.Doll, "Dolls" },
                { DecorationTypes.Cushion, "Cushions" }
            };

            secretBaseUsedIcon = ResourceDatabase.GetImageFromName("DecorationSecretBase");
            bedroomUsedIcon    = ResourceDatabase.GetImageFromName("DecorationBedroom");

            SQLiteCommand    command;
            SQLiteDataReader reader;
            DataTable        table;

            SQLiteConnection connection = new SQLiteConnection("Data Source=ItemDatabase.db");

            connection.Open();

            // Load Gen3 Item Data
            command = new SQLiteCommand("SELECT * FROM Items", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("Items");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                ItemData item = new ItemData(row, Generations.Gen3);
                gen3ItemMap.Add(item.ID, item);
                gen3ItemList.Add(item);
            }

            // Load Gen3 Item Images
            command = new SQLiteCommand("SELECT * FROM ItemImages", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("Images");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                ushort       id    = (ushort)(long)row["ID"];
                BitmapSource image = LoadImage((byte[])row["Image"]);
                gen3ImageMap.Add(id, image);
            }

            // Load Gen3 Decoration Data
            command = new SQLiteCommand("SELECT * FROM Decorations", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("Decorations");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                DecorationData decoration = new DecorationData(row);
                decorationMap.Add(decoration.ID, decoration);
                decorationList.Add(decoration);
            }

            // Load Gen3 Decoration Images
            command = new SQLiteCommand("SELECT * FROM DecorationImages", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("DecorationImages");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                byte id = (byte)(long)row["ID"];
                decorationImageMap.Add(id, LoadImage((byte[])row["Image"]));
                decorationFullSizeImageMap.Add(id, LoadImage((byte[])row["ImageFullSize"]));
            }

            // Load Gen3 Pokeblock Small Images
            command = new SQLiteCommand("SELECT * FROM PokeblockImages", connection);
            reader  = command.ExecuteReader();
            table   = new DataTable("PokeblockImages");
            table.Load(reader);
            foreach (DataRow row in table.Rows)
            {
                PokeblockColors id = (PokeblockColors)(long)row["ID"];
                pokeblockSmallImageMap.Add(id, LoadImage((byte[])row["ImageSmall"]));
                pokeblockLargeImageMap.Add(id, LoadImage((byte[])row["ImageLarge"]));
            }
            // Load Gen3 Pokeblock Large Images

            /*command = new SQLiteCommand("SELECT * FROM PokeblockLargeImages", connection);
             * reader = command.ExecuteReader();
             * table = new DataTable("PokeblockLargeImages");
             * table.Load(reader);
             * foreach (DataRow row in table.Rows) {
             *      PokeblockColors id = (PokeblockColors)(long)row["ID"];
             *      BitmapImage image = LoadImage((byte[])row["Data"]);
             *      pokeblockLargeImageMap.Add(id, image);
             * }*/


            connection.Close();
        }