Exemplo n.º 1
0
        internal static void Loop()
        {
            LoadShopManager();
            LoadShops();
            shopMenu = new NativeMenu("Food Store", "FOOD STORES");
            MenuManager.Pool.Add(shopMenu);

            while (Common.InstanceRunning)
            {
                GameFiber.Yield();
                foreach (var shop in shops)
                {
                    if (Game.LocalPlayer.Character.DistanceTo(shop.Position.GeneratedVector3) < 3.5f)
                    {
                        if (!alreadySetCurrentItems)
                        {
                            currentItems = shop.Items;
                            shopMenu.Clear();

                            foreach (var item in currentItems)
                            {
                                var shopItem = new NativeItem(item.Name, "Buys the food.");
                                shopItem.Activated += (sender, selectedItem) =>
                                {
                                    if (Functions.CostMoney(item.Price))
                                    {
                                        Functions.IncreaseHungry(item.Amount);
                                    }
                                };
                                shopMenu.Add(shopItem);
                            }
                            alreadySetCurrentItems = true;
                        }

                        Game.DisplayHelp("Press ~INPUT_CONTEXT~ to open the shop menu.");
                        if (Game.IsControlPressed(0, GameControl.Context))
                        {
                            shopMenu.Visible = !shopMenu.Visible;
                        }
                        break;
                    }
                    else
                    {
                        alreadySetCurrentItems = false;
                    }
                }
            }
        }
Exemplo n.º 2
0
 private static void Clear_Activated(object sender, EventArgs e)
 {
     // Here we call the Clear function to remove all of the items
     menu.Clear();
 }