Exemple #1
0
            DODGroup FindGroup(string group, int iRarity)
            {
                // first find the group
                DODGroup match = null;

                try
                {
                    for (int ix = 0; ix < RareFactory.DODGroup.Count; ix++)
                    {
                        DODGroup dg = RareFactory.DODGroup[ix] as DODGroup;
                        if (dg.Name.ToLower() == group.ToLower() && dg.Rarity == (short)iRarity)
                        {
                            match = dg;
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHelper.LogException(ex);
                    Console.WriteLine(ex.Message);
                }

                return(match);
            }
            public override void OnResponse(Mobile from, string text)
            {
                if (text.ToLower() == "y")
                {
                    // Delete all the DOD instances first
                    DODGroup dg = (DODGroup)RareFactory.DODGroup[m_idg];

                    for (int i = 0; i < dg.DODInst.Count; i++)
                    {
                        string sName = "";

                        if (dg.DODInst[i] is DODInstance)
                        {
                            sName = ((DODInstance)dg.DODInst[i]).Name;
                        }

                        from.SendMessage("Deleting rare '{0}'...", sName);

                        for (int inst = 0; inst < RareFactory.DODInst.Count; inst++)
                        {
                            if (((DODInstance)RareFactory.DODInst[inst]) == dg.DODInst[i])
                            {                               // There should never be more than one of these right?
                                RareFactory.DODInst.RemoveAt(inst);
                                break;
                            }
                        }
                    }

                    from.SendMessage("Deleting group '{0}'", dg.Name);
                    RareFactory.DODGroup.RemoveAt(m_idg);

                    from.SendMessage("Rare group deletion complete.");
                    if (RareFactory.ViewingDODGroupIndex > 0)
                    {
                        RareFactory.ViewingDODGroupIndex -= 1;
                    }
                }
                else
                {
                    from.SendMessage("Rare group deletion cancelled.");
                }

                RareFactory.ReloadViews(from);
            }
        public void GenerateGroups()
        {
            // Add group button always exists
            AddButton(gx + 63, gy + 300, 0xFA8, 0xFAA, 1, GumpButtonType.Reply, 0);

            // Next group
            AddButton(gx + 103, gy + 300, 0xFA5, 0xFA7, 2, GumpButtonType.Reply, 0);

            // Prev group
            AddButton(gx + 23, gy + 300, 0xFAE, 0xFB0, 3, GumpButtonType.Reply, 0);


            if (RareFactory.DODGroup.Count == 0)
            {
                AddLabel(gx + 16, gy + 50, 1152, "No groups defined");
                return;
            }

            // On construction we work out the groups
            // available and create the buttons to handle
            // them dynamically

            int startidx = curPage * 5;

            for (int i = startidx; (i < startidx + 5) && (i < RareFactory.DODGroup.Count); i++)
            {
                DODGroup dg = (DODGroup)RareFactory.DODGroup[i];

                int ypos = ((i - startidx) * 30) + 170;

                // View group
                AddButton(gx + 13, ypos, 0xFAB, 0xFAD, (i * 2) + 4, GumpButtonType.Reply, 0);
                // Del group
                AddButton(gx + 43, ypos, 0xFB1, 0xFB3, (i * 2) + 5, GumpButtonType.Reply, 0);
                // Group name
                AddLabel(gx + 78, ypos, 1152, dg.Name);
            }
        }
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch ((RFButtons)info.ButtonID)
            {
            case RFButtons.AddRareButton:
            {
                // Make sure a group has been defined (if one has, one will be
                // selected by default - group 0)
                if (RareFactory.DODGroup.Count == 0)
                {
                    from.SendMessage("You must define a Dynamic Object Definition Group before adding rares.");
                    break;
                }

                from.SendMessage("Select the item you wish to use as a template for this rare...");
                from.Target = new RareTarget();
                break;
            }

            case RFButtons.DelRareButton:
            {
                if (RareFactory.ViewingDODGroup.DODInst.Count == 0)
                {
                    from.SendMessage("There are no rares to delete!");
                    break;
                }

                from.SendMessage("Are you sure you wish to delete this rare? (y/n)");
                from.Prompt = new DelConfirmPrompt(from);
                break;
            }


            case RFButtons.NextRareButton:
            {
                if (RareFactory.DODGroup.Count == 0)
                {
                    from.SendMessage("No rares defined!");
                    break;
                }

                // The .ViewingDODIndex references the relative index
                // within this particular DODGroup

                DODGroup dg = (DODGroup)RareFactory.DODGroup[RareFactory.ViewingDODGroupIndex];

                if ((RareFactory.ViewingDODIndex + 1) >= dg.DODInst.Count)
                {
                    from.SendMessage("Last rare in group!");
                    break;
                }
                else
                {
                    RareFactory.ViewingDODIndex++;
                    break;
                }
            }

            case RFButtons.PrevRareButton:
            {
                if (RareFactory.DODGroup.Count == 0)
                {
                    from.SendMessage("No rares defined!");
                    break;
                }

                // The .ViewingDODIndex references the relative index
                // within this particular DODGroup

                if (RareFactory.ViewingDODIndex == 0)
                {
                    from.SendMessage("First rare in group!");
                    break;
                }
                else
                {
                    RareFactory.ViewingDODIndex--;
                    break;
                }
            }

            case RFButtons.TestButton:
            {
                if (RareFactory.DODGroup.Count == 0)
                {
                    from.SendMessage("Define Dynamic Object Definition Groups and objects (rares) before attempting to generate test batches.");
                    break;
                }

                if (((DODGroup)RareFactory.DODGroup[RareFactory.ViewingDODGroupIndex]).DODInst.Count == 0)
                {
                    from.SendMessage("You must add rares to the group before attempting to generate test batches.");
                    break;
                }

                int prevCur = RareFactory.ViewingDOD.CurIndex;

                // Generates a complete set of rares as a test
                from.SendMessage("Generating example rare set...");

                for (int i = RareFactory.ViewingDOD.StartIndex; i <= RareFactory.ViewingDOD.LastIndex; i++)
                {
                    // Create a new item
                    DODInstance dodi    = RareFactory.ViewingDOD;
                    Item        newitem = RareFactory.DupeItem(dodi.RareTemplate);

                    newitem.Movable = true;
                    dodi.CurIndex   = (short)i;
                    dodi.DynamicFill(newitem);
                    from.AddToBackpack(newitem);
                }

                RareFactory.ViewingDOD.CurIndex = (short)prevCur;

                from.SendMessage("Completed. {0} rares generated and added to your backpack.",
                                 (RareFactory.ViewingDOD.LastIndex -
                                  RareFactory.ViewingDOD.StartIndex) + 1);

                break;
            }

            default:
            {
                return;
            }
            }

            RareFactory.ReloadViews(from);
        }
Exemple #5
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            Mobile from = state.Mobile;

            switch (info.ButtonID)
            {
            case 0:
            {
                // Close this gump
                return;
            }

            case 1:
            {
                // Raise rarity

                if (m_RarityLevel >= 10)
                {
                    from.SendMessage("Maximum rarity level is 10 (most unique)");
                    break;
                }

                m_RarityLevel++;

                break;
            }

            case 2:
            {
                // Lower rarity

                if (m_RarityLevel == 0)
                {
                    from.SendMessage("Minimum rarity level is 0 (most common)");
                    break;
                }

                m_RarityLevel--;

                break;
            }

            case 3:
            {
                // Make sure they've specified a name :P
                if (m_GroupName == "")
                {
                    from.SendMessage("You must specify a group name to identify this group by!");
                    break;
                }

                // Now make sure that the name doesn't already exist :)
                if (RareFactory.DODGroup.Count > 0)
                {
                    for (int i = 0; i < RareFactory.DODGroup.Count; i++)
                    {
                        DODGroup dg = (DODGroup)RareFactory.DODGroup[i];
                        if (dg.Name == m_GroupName)
                        {
                            // Don't bother with the rest of this code - they messed up!
                            from.SendMessage("DOD Group names must be unique - the name you have chosen already exists! Please try again.");
                            break;
                        }
                    }
                }

                // Accept + create
                RareFactory.DODGroup.Add(new DODGroup(m_GroupName, m_RarityLevel));

                // Update their display
                RareFactory.ReloadViews(from);

                return;
            }

            case 4:
            {
                // Cancel the whole thing
                return;
            }

            case 5:
            {
                // Set the group name
                from.SendMessage("Enter the name you wish to use to represent this group of rares :");
                from.Prompt = new GroupNamePrompt(from, this);
                return;
            }

            default:
            {
                break;
            }
            }

            Refresh(from);
        }