示例#1
0
        public ShopMenu(List <Tuple <InvItem, int> > goods, int defaultChoice, OnMultiChoice chooseSlots)
        {
            Goods  = goods;
            action = chooseSlots;

            List <MenuChoice> flatChoices = new List <MenuChoice>();

            for (int ii = 0; ii < goods.Count; ii++)
            {
                int index = ii;

                bool     canAfford = goods[index].Item2 <= DataManager.Instance.Save.ActiveTeam.Money;
                MenuText itemText  = new MenuText(goods[index].Item1.GetDisplayName(), new Loc(2, 1), canAfford ? Color.White : Color.Red);
                MenuText itemPrice = new MenuText(goods[index].Item2.ToString(), new Loc(ItemMenu.ITEM_MENU_WIDTH - 8 * 4, 1), DirV.Up, DirH.Right, Color.Lime);
                flatChoices.Add(new MenuElementChoice(() => { choose(index); }, true, itemText, itemPrice));
            }
            defaultChoice = Math.Min(defaultChoice, flatChoices.Count - 1);
            int startChoice         = defaultChoice % SLOTS_PER_PAGE;
            int startPage           = defaultChoice / SLOTS_PER_PAGE;
            List <MenuChoice[]> inv = SortIntoPages(flatChoices, SLOTS_PER_PAGE);


            summaryMenu = new ItemSummary(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                          new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8)));

            moneySummary = new MoneySummary(Rect.FromPoints(new Loc(16 + ItemMenu.ITEM_MENU_WIDTH, summaryMenu.Bounds.Top - LINE_SPACE * 2 - GraphicsManager.MenuBG.TileHeight * 2),
                                                            new Loc(GraphicsManager.ScreenWidth - 16, summaryMenu.Bounds.Top)));

            int buyLimit = DataManager.Instance.Save.ActiveTeam.GetMaxInvSlots(ZoneManager.Instance.CurrentZone) - DataManager.Instance.Save.ActiveTeam.GetInvCount();

            Initialize(new Loc(16, 16), SELL_MENU_WIDTH, Text.FormatKey("MENU_SHOP_TITLE"), inv.ToArray(), startChoice, startPage, SLOTS_PER_PAGE, false, buyLimit);
        }
示例#2
0
        public SellMenu(int defaultChoice, OnChooseSlots chooseSlots)
        {
            action = chooseSlots;

            List <MenuChoice> flatChoices = new List <MenuChoice>();

            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.Players.Count; ii++)
            {
                Character activeChar = DataManager.Instance.Save.ActiveTeam.Players[ii];
                int       index      = ii;
                if (activeChar.EquippedItem.ID > -1)
                {
                    MenuText itemText  = new MenuText((index + 1).ToString() + ": " + activeChar.EquippedItem.GetName(), new Loc(2, 1));
                    MenuText itemPrice = new MenuText(activeChar.EquippedItem.GetSellValue().ToString(), new Loc(ItemMenu.ITEM_MENU_WIDTH - 8 * 4, 1), DirV.Up, DirH.Right, Color.Lime);
                    flatChoices.Add(new MenuElementChoice(() => { choose(new InvSlot(true, index)); }, true, itemText, itemPrice));
                }
            }
            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.GetInvCount(); ii++)
            {
                int index = ii;

                MenuText itemText  = new MenuText(DataManager.Instance.Save.ActiveTeam.GetInv(index).GetName(), new Loc(2, 1));
                MenuText itemPrice = new MenuText(DataManager.Instance.Save.ActiveTeam.GetInv(index).GetSellValue().ToString(), new Loc(ItemMenu.ITEM_MENU_WIDTH - 8 * 4, 1), DirV.Up, DirH.Right, Color.Lime);
                flatChoices.Add(new MenuElementChoice(() => { choose(new InvSlot(false, index)); }, true, itemText, itemPrice));
            }
            defaultChoice = Math.Min(defaultChoice, flatChoices.Count - 1);
            int startChoice         = defaultChoice % SLOTS_PER_PAGE;
            int startPage           = defaultChoice / SLOTS_PER_PAGE;
            List <MenuChoice[]> inv = SortIntoPages(flatChoices, SLOTS_PER_PAGE);


            summaryMenu = new ItemSummary(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                          new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8)));

            moneySummary = new MoneySummary(Rect.FromPoints(new Loc(16 + SELL_MENU_WIDTH, summaryMenu.Bounds.Top - LINE_SPACE * 2 - GraphicsManager.MenuBG.TileHeight * 2),
                                                            new Loc(GraphicsManager.ScreenWidth - 16, summaryMenu.Bounds.Top)));

            Initialize(new Loc(16, 16), SELL_MENU_WIDTH, Text.FormatKey("MENU_ITEM_TITLE"), inv.ToArray(), startChoice, startPage, SLOTS_PER_PAGE, false, flatChoices.Count);
        }
示例#3
0
        public AppraiseMenu(int defaultChoice, OnChooseSlots chooseSlots)
        {
            action = chooseSlots;

            List <MenuChoice> flatChoices = new List <MenuChoice>();

            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.Players.Count; ii++)
            {
                Character activeChar = DataManager.Instance.Save.ActiveTeam.Players[ii];
                int       index      = ii;
                if (activeChar.EquippedItem.ID > -1)
                {
                    bool enabled = DataManager.Instance.GetItem(activeChar.EquippedItem.ID).UsageType == ItemData.UseType.Box;
                    flatChoices.Add(new MenuTextChoice((index + 1).ToString() + ": " + activeChar.EquippedItem.GetDisplayName(), () => { choose(new InvSlot(true, index)); }, enabled, enabled ? Color.White : Color.Red));
                }
            }
            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.GetInvCount(); ii++)
            {
                int index = ii;

                bool enabled = DataManager.Instance.GetItem(DataManager.Instance.Save.ActiveTeam.GetInv(index).ID).UsageType == ItemData.UseType.Box;
                flatChoices.Add(new MenuTextChoice(DataManager.Instance.Save.ActiveTeam.GetInv(index).GetDisplayName(), () => { choose(new InvSlot(false, index)); }, enabled, enabled ? Color.White : Color.Red));
            }
            defaultChoice = Math.Min(defaultChoice, flatChoices.Count - 1);
            int startChoice         = defaultChoice % SLOTS_PER_PAGE;
            int startPage           = defaultChoice / SLOTS_PER_PAGE;
            List <MenuChoice[]> inv = SortIntoPages(flatChoices, SLOTS_PER_PAGE);


            summaryMenu = new ItemSummary(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                          new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8)));

            moneySummary = new MoneySummary(Rect.FromPoints(new Loc(16 + ItemMenu.ITEM_MENU_WIDTH, summaryMenu.Bounds.Top - LINE_SPACE * 2 - GraphicsManager.MenuBG.TileHeight * 2),
                                                            new Loc(GraphicsManager.ScreenWidth - 16, summaryMenu.Bounds.Top)));

            Initialize(new Loc(16, 16), APPRAISE_MENU_WIDTH, Text.FormatKey("MENU_ITEM_TITLE"), inv.ToArray(), startChoice, startPage, SLOTS_PER_PAGE, false, flatChoices.Count);
        }
示例#4
0
        public SwapShopMenu(List <Tuple <int, int[]> > goods, int[] priceList, int defaultChoice, OnChooseSlot chooseSlot)
        {
            Goods        = goods;
            PriceList    = priceList;
            action       = chooseSlot;
            AllowedGoods = new List <int>();

            itemPresence  = new bool[DataManager.Instance.DataIndices[DataManager.DataType.Item].Count];
            tradePresence = new bool[DataManager.Instance.DataIndices[DataManager.DataType.Item].Count];
            for (int ii = 0; ii < itemPresence.Length; ii++)
            {
                if (DataManager.Instance.Save.ActiveTeam.Storage[ii] > 0)
                {
                    updatePresence(ii);
                }
            }
            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.GetInvCount(); ii++)
            {
                updatePresence(DataManager.Instance.Save.ActiveTeam.GetInv(ii).ID);
            }

            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.Players.Count; ii++)
            {
                Character activeChar = DataManager.Instance.Save.ActiveTeam.Players[ii];
                if (activeChar.EquippedItem.ID > -1)
                {
                    updatePresence(activeChar.EquippedItem.ID);
                }
            }

            List <MenuChoice> flatChoices = new List <MenuChoice>();

            for (int ii = 0; ii < goods.Count; ii++)
            {
                int index = ii;

                bool  canView   = false;
                bool  canTrade  = true;
                int   wildcards = 0;
                int[] reqs      = goods[ii].Item2;
                for (int jj = 0; jj < reqs.Length; jj++)
                {
                    if (reqs[jj] > -1)
                    {
                        if (!itemPresence[reqs[jj]])
                        {
                            canTrade = false;
                        }
                        else
                        {
                            canView = true;
                        }
                    }
                    else
                    {
                        wildcards++;
                        canView = true;
                    }
                }

                if (canView)
                {
                    AllowedGoods.Add(ii);
                    ItemData itemEntry = DataManager.Instance.GetItem(goods[ii].Item1);
                    if (PriceList[itemEntry.Rarity] > DataManager.Instance.Save.ActiveTeam.Money || wildcards > presenceCount)
                    {
                        canTrade = false;
                    }
                    flatChoices.Add(new MenuTextChoice(itemEntry.GetIconName(), () => { choose(index); }, canTrade, canTrade ? Color.White : Color.Red));
                }
            }
            defaultChoice = Math.Min(defaultChoice, flatChoices.Count - 1);
            int startChoice         = defaultChoice % SLOTS_PER_PAGE;
            int startPage           = defaultChoice / SLOTS_PER_PAGE;
            List <MenuChoice[]> inv = SortIntoPages(flatChoices, SLOTS_PER_PAGE);


            summaryMenu = new ItemSummary(Rect.FromPoints(new Loc(16, GraphicsManager.ScreenHeight - 8 - 4 * VERT_SPACE - GraphicsManager.MenuBG.TileHeight * 2),
                                                          new Loc(GraphicsManager.ScreenWidth - 16, GraphicsManager.ScreenHeight - 8)));

            tradeSummary = new TradeSummary(Rect.FromPoints(new Loc(16 + SWAP_MENU_WIDTH, summaryMenu.Bounds.Top - LINE_SPACE * 7 - GraphicsManager.MenuBG.TileHeight * 2),
                                                            new Loc(GraphicsManager.ScreenWidth - 16, summaryMenu.Bounds.Top)));
            moneySummary = new MoneySummary(Rect.FromPoints(new Loc(16 + SWAP_MENU_WIDTH, tradeSummary.Bounds.Top - LINE_SPACE * 2 - GraphicsManager.MenuBG.TileHeight * 2),
                                                            new Loc(GraphicsManager.ScreenWidth - 16, tradeSummary.Bounds.Top)));

            int buyLimit = DataManager.Instance.Save.ActiveTeam.GetMaxInvSlots(ZoneManager.Instance.CurrentZone) - DataManager.Instance.Save.ActiveTeam.GetInvCount();

            Initialize(new Loc(16, 16), SWAP_MENU_WIDTH, Text.FormatKey("MENU_SHOP_TITLE"), inv.ToArray(), startChoice, startPage, SLOTS_PER_PAGE);
        }