Пример #1
0
        private void verifyPointToolStripMenuItem_Click(object sender, EventArgs e)
        {
            GiftWrapper gw = new GiftWrapper(1, 10);

            Geometry.Point p = gw.Points[0];
            //Geometry.Point p = new Geometry.Point(3, 9);
            p.Lock = false;

            this.Plan.DrawAxis();
            this.Polygon = new List <Geometry.Point>(this.GiftWrap.Points);
            this.Plan.Trace(this.Polygon);

            this.GiftWrap.Points.Add(p);
            this.Plan.Plot(this.GiftWrap.Points);

            IList <Geometry.Point> convexHull = this.GiftWrap.GetConvexHull();

            if (convexHull.Count == 3 && !convexHull.Contains(p))
            {
                MessageBox.Show(string.Format("The point {0} is inside the triangle.", p));
            }
            else
            {
                MessageBox.Show(string.Format("The point {0} is outside the triangle.", p));
            }

            this.GiftWrap.Points.Remove(p);
        }
Пример #2
0
        /// <summary>
        ///     Loads the items.
        /// </summary>
        /// <param name="dbClient">The database client.</param>
        internal void LoadItems(IQueryAdapter dbClient)
        {
            _items.Clear();

            GiftWrapper.Clear();

            dbClient.SetQuery("SELECT * FROM catalog_furnitures");

            DataTable table = dbClient.GetTable();

            if (table == null)
            {
                return;
            }

            List <double> heights = null;

            foreach (DataRow dataRow in table.Rows)
            {
                try
                {
                    uint id     = (uint)dataRow["id"];
                    uint modes  = (uint)dataRow["interaction_modes_count"];
                    uint effect = (uint)dataRow["effectid"];

                    char type = char.Parse((string)dataRow["type"]);

                    uint flatId = (uint)dataRow["flat_id"];
                    int  sprite = 0;

                    string name           = (string)dataRow["item_name"];
                    string publicName     = (string)dataRow["item_name"];
                    string stackHeightStr = (string)dataRow["stack_height"];
                    string vendingIds     = (string)dataRow["vending_ids"];

                    bool sub = (string)dataRow["subscriber"] == "1";
                    bool stackable = (string)dataRow["can_stack"] == "1";
                    bool allowRecycle = (string)dataRow["allow_recycle"] == "1";
                    bool allowTrade = (string)dataRow["allow_trade"] == "1";
                    bool allowMarketplaceSell = (string)dataRow["allow_marketplace_sell"] == "1";
                    bool allowGift = (string)dataRow["allow_gift"] == "1";
                    bool allowInventoryStack = (string)dataRow["allow_inventory_stack"] == "1";
                    bool canWalk = false, canSit = false, stackMultiple = false;

                    ushort x = ushort.MinValue, y = ushort.MinValue;

                    double stackHeight;

                    Interaction typeFromString = InteractionTypes.GetTypeFromString((string)dataRow["interaction_type"]);

                    if (stackHeightStr.Contains(';'))
                    {
                        heights       = stackHeightStr.Split(';').Select(heightStr => double.Parse(heightStr, CultureInfo.InvariantCulture)).ToList();
                        stackHeight   = heights[0];
                        stackMultiple = true;
                    }
                    else
                    {
                        stackHeight = double.Parse(stackHeightStr, CultureInfo.InvariantCulture);
                    }

                    if (name == "landscape" || name == "floor" || name == "wallpaper")
                    {
                        sprite = FurnitureDataManager.WallItems[name].Id;
                        x      = 1;
                        y      = 1;
                    }
                    else if (type == 's' && FurnitureDataManager.FloorItems.ContainsKey(name))
                    {
                        sprite     = FurnitureDataManager.FloorItems[name].Id;
                        publicName = FurnitureDataManager.FloorItems[name].Name;
                        x          = FurnitureDataManager.FloorItems[name].X;
                        y          = FurnitureDataManager.FloorItems[name].Y;
                        canWalk    = FurnitureDataManager.FloorItems[name].CanWalk;
                        canSit     = FurnitureDataManager.FloorItems[name].CanSit;
                    }
                    else if (type == 'i' && FurnitureDataManager.WallItems.ContainsKey(name))
                    {
                        sprite     = FurnitureDataManager.WallItems[name].Id;
                        publicName = FurnitureDataManager.WallItems[name].Name;
                    }
                    else if (name.StartsWith("a0 pet", StringComparison.InvariantCulture))
                    {
                        x          = 1;
                        y          = 1;
                        publicName = name;
                    }
                    else if (type != 'e' && type != 'h' && type != 'r' && type != 'b')
                    {
                        continue;
                    }

                    if (name.StartsWith("present_gen"))
                    {
                        GiftWrapper.AddOld(sprite);
                    }
                    else if (name.StartsWith("present_wrap*"))
                    {
                        GiftWrapper.Add(sprite);
                    }

                    // If Can Walk
                    if (InteractionTypes.AreFamiliar(GlobalInteractions.Gate, typeFromString) || (typeFromString == Interaction.BanzaiPyramid) || name.StartsWith("hole"))
                    {
                        canWalk = false;
                    }

                    // Add Item
                    Item value = new Item(id, sprite, publicName, name, type, x, y, stackHeight, stackable, canWalk,
                                          canSit, allowRecycle, allowTrade, allowMarketplaceSell, allowGift, allowInventoryStack,
                                          typeFromString, modes, vendingIds, sub, effect, stackMultiple,
                                          heights?.ToArray(), flatId);

                    _items.Add(id, value);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    Console.ReadKey();
                    Writer.WriteLine($"Could not load item #{Convert.ToUInt32(dataRow[0])}, please verify the data is okay.", "Yupi.Items", ConsoleColor.DarkRed);
                }
            }
        }