Example #1
0
        public SwapGiveMenu(int defaultChoice, int openSpaces, OnMultiChoice chooseSlots)
        {
            action       = chooseSlots;
            AllowedGoods = new List <int>();

            int[] itemPresence = new int[DataManager.Instance.DataIndices[DataManager.DataType.Item].Count];
            for (int ii = 0; ii < itemPresence.Length; ii++)
            {
                itemPresence[ii] += DataManager.Instance.Save.ActiveTeam.Storage[ii];
            }

            for (int ii = 0; ii < DataManager.Instance.Save.ActiveTeam.GetInvCount(); ii++)
            {
                itemPresence[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)
                {
                    itemPresence[activeChar.EquippedItem.ID]++;
                }
            }

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

            for (int ii = 0; ii < itemPresence.Length; ii++)
            {
                int index = ii;
                if (itemPresence[index] > 0)
                {
                    ItemEntrySummary itemEntry = DataManager.Instance.DataIndices[DataManager.DataType.Item].Entries[ii] as ItemEntrySummary;

                    if (itemEntry.ContainsState <MaterialState>())
                    {
                        AllowedGoods.Add(index);

                        MenuText menuText  = new MenuText(DataManager.Instance.GetItem(ii).GetIconName(), new Loc(2, 1));
                        MenuText menuCount = new MenuText("(" + itemPresence[index] + ")", new Loc(ItemMenu.ITEM_MENU_WIDTH - 8 * 4, 1), DirV.Up, DirH.Right, Color.White);
                        flatChoices.Add(new MenuElementChoice(() => { }, true, menuText, menuCount));
                    }
                }
            }
            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)));

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

            Initialize(new Loc(16, 16), ItemMenu.ITEM_MENU_WIDTH, Text.FormatKey("MENU_SHOP_TITLE"), inv.ToArray(), startChoice, startPage, SLOTS_PER_PAGE, false, new IntRange(openSpaces));
        }
Example #2
0
        public override List <MapItem> GenerateItems(BaseMapGenContext map, SpawnList <MapItem> specialItems)
        {
            int            itemCount = Amount.Pick(map.Rand);
            List <MapItem> spawners  = new List <MapItem>();

            SpawnList <MapItem> subList = new SpawnList <MapItem>();

            if (UseSpecialItems)
            {
                for (int ii = 0; ii < specialItems.Count; ii++)
                {
                    MapItem spawn = specialItems.GetSpawn(ii);
                    if (!spawn.IsMoney)
                    {
                        ItemEntrySummary itemEntry = DataManager.Instance.DataIndices[DataManager.DataType.Item].Entries[spawn.Value] as ItemEntrySummary;

                        if (itemEntry.UsageType == UseType)
                        {
                            subList.Add(spawn, specialItems.GetSpawnRate(ii));
                        }
                    }
                }
            }

            if (UseMapItems)
            {
                foreach (string key in map.ItemSpawns.Spawns.GetKeys())
                {
                    SpawnList <InvItem> spawns = map.ItemSpawns.Spawns.GetSpawn(key);
                    for (int ii = 0; ii < spawns.Count; ii++)
                    {
                        //TODO: spawn rate is somewhat distorted here
                        InvItem          spawn     = spawns.GetSpawn(ii);
                        ItemEntrySummary itemEntry = DataManager.Instance.DataIndices[DataManager.DataType.Item].Entries[spawn.ID] as ItemEntrySummary;
                        if (itemEntry.UsageType == UseType)
                        {
                            subList.Add(new MapItem(spawn), spawns.GetSpawnRate(ii));
                        }
                    }
                }
            }

            if (subList.Count == 0)
            {
                return(spawners);
            }

            for (int ii = 0; ii < itemCount; ii++)
            {
                spawners.Add(subList.Pick(map.Rand));
            }

            return(spawners);
        }
Example #3
0
 private bool updatePresence(int index, bool[] itemPresence)
 {
     if (!itemPresence[index])
     {
         itemPresence[index] = true;
         ItemEntrySummary itemEntry = DataManager.Instance.DataIndices[DataManager.DataType.Item].Entries[index] as ItemEntrySummary;
         if (itemEntry.ContainsState <MaterialState>())
         {
             return(true);
         }
     }
     return(false);
 }
Example #4
0
        private void updatePresence(int index)
        {
            if (!itemPresence[index])
            {
                itemPresence[index] = true;
                ItemEntrySummary itemEntry = DataManager.Instance.DataIndices[DataManager.DataType.Item].Entries[index] as ItemEntrySummary;

                if (itemEntry.ContainsState <MaterialState>())
                {
                    presenceCount++;
                    tradePresence[index] = true;
                }
            }
        }
        public TradeItemMenu(int defaultChoice)
        {
            int menuWidth = 152;

            AllowedGoods = new List <int>();

            int[] itemPresence = new int[DataManager.Instance.DataIndices[DataManager.DataType.Item].Count];
            for (int ii = 0; ii < itemPresence.Length; ii++)
            {
                itemPresence[ii] += DataManager.Instance.Save.ActiveTeam.Storage[ii];
            }

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

            for (int ii = 0; ii < itemPresence.Length; ii++)
            {
                int index = ii;
                if (itemPresence[index] > 0)
                {
                    ItemEntrySummary itemEntry = DataManager.Instance.DataIndices[DataManager.DataType.Item].Entries[index] as ItemEntrySummary;
                    if (itemEntry.ContainsState <MaterialState>())
                    {
                        AllowedGoods.Add(index);
                        int slot = flatChoices.Count;

                        MenuText menuText  = new MenuText(DataManager.Instance.GetItem(ii).GetIconName(), new Loc(2, 1));
                        MenuText menuCount = new MenuText("(" + itemPresence[index] + ")", new Loc(menuWidth - 8 * 4, 1), DirV.Up, DirH.Right, Color.White);
                        flatChoices.Add(new MenuElementChoice(() => { choose(slot); }, true, menuText, menuCount));
                    }
                }
            }

            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);


            Initialize(new Loc(0, 16 + LINE_SPACE + GraphicsManager.MenuBG.TileHeight * 2), menuWidth, Text.FormatKey("MENU_STORAGE_TITLE"), inv.ToArray(), startChoice, startPage, SLOTS_PER_PAGE, false, 8);

            theirInfo = new OfferItemsMenu(new Rect(GraphicsManager.ScreenWidth - 0 - menuWidth, 16 + LINE_SPACE + GraphicsManager.MenuBG.TileHeight * 2, Bounds.Width, Bounds.Height), null);

            yourTitle = new SummaryMenu(Rect.FromPoints(new Loc(Bounds.Start.X, Bounds.Start.Y - LINE_SPACE - GraphicsManager.MenuBG.TileHeight * 2), new Loc(Bounds.End.X, Bounds.Start.Y)));
            MenuText yourText = new MenuText(DataManager.Instance.Save.ActiveTeam.GetDisplayName(),
                                             new Loc((yourTitle.Bounds.X + yourTitle.Bounds.End.X) / 2, yourTitle.Bounds.Y + GraphicsManager.MenuBG.TileHeight), DirH.None);

            yourText.Color = TextTan;
            yourTitle.Elements.Add(yourText);

            yourSummary = new SummaryMenu(Rect.FromPoints(new Loc(Bounds.Start.X, Bounds.End.Y),
                                                          new Loc(Bounds.End.X, Bounds.End.Y + LINE_SPACE + GraphicsManager.MenuBG.TileHeight * 2)));
            yourStatus = new MenuText("",
                                      new Loc((yourSummary.Bounds.X + yourSummary.Bounds.End.X) / 2, yourSummary.Bounds.Y + GraphicsManager.MenuBG.TileHeight), DirH.None);
            yourStatus.Color = TextTan;
            yourSummary.Elements.Add(yourStatus);



            theirTitle = new SummaryMenu(Rect.FromPoints(new Loc(theirInfo.Bounds.Start.X, theirInfo.Bounds.Start.Y - LINE_SPACE - GraphicsManager.MenuBG.TileHeight * 2), new Loc(theirInfo.Bounds.End.X, theirInfo.Bounds.Start.Y)));
            MenuText theirText = new MenuText("",
                                              new Loc((theirTitle.Bounds.X + theirTitle.Bounds.End.X) / 2, theirTitle.Bounds.Y + GraphicsManager.MenuBG.TileHeight), DirH.None);

            theirText.Color = TextTan;
            theirTitle.Elements.Add(theirText);

            theirSummary = new SummaryMenu(Rect.FromPoints(new Loc(theirInfo.Bounds.Start.X, theirInfo.Bounds.End.Y),
                                                           new Loc(theirInfo.Bounds.End.X, theirInfo.Bounds.End.Y + LINE_SPACE + GraphicsManager.MenuBG.TileHeight * 2)));
            theirStatus = new MenuText("",
                                       new Loc((theirSummary.Bounds.X + theirSummary.Bounds.End.X) / 2, theirSummary.Bounds.Y + GraphicsManager.MenuBG.TileHeight), DirH.None);
            theirStatus.Color = TextTan;
            theirSummary.Elements.Add(theirStatus);

            theirText.SetText(NetworkManager.Instance.Activity.TargetInfo.Data.TeamName);

            CurrentState = ExchangeState.Selecting;
        }