示例#1
0
        private void AddGem_Hit(object sender, EventArgs e)
        {
            try
            {
                if (Parent.Machine.Core.Actions.CurrentSelection != 0 && Parent.Machine.Core.WorldFilter[Parent.Machine.Core.Actions.CurrentSelection] != null)
                {
                    WorldObject worldObject = Parent.Machine.Core.WorldFilter[Parent.Machine.Core.Actions.CurrentSelection];
                    if (worldObject.ObjectClass.Equals(ObjectClass.Gem))
                    {
                        if (!string.IsNullOrEmpty(GemKeyword.Text))
                        {
                            if (!string.IsNullOrEmpty(GemHeading.Text))
                            {
                                GemSetting gemSetting = new GemSetting
                                {
                                    Name    = Parent.Machine.Core.WorldFilter[Parent.Machine.Core.Actions.CurrentSelection].Name,
                                    Keyword = GemKeyword.Text,
                                    Heading = double.Parse(GemHeading.Text)
                                };

                                if (Parent.Machine.Utility.BotSettings.GemSettings.Contains(gemSetting))
                                {
                                    for (int i = 0; i < Parent.Machine.Utility.BotSettings.GemSettings.Count; i++)
                                    {
                                        if (Parent.Machine.Utility.BotSettings.GemSettings[i].Equals(gemSetting))
                                        {
                                            Parent.Machine.Utility.BotSettings.GemSettings[i] = gemSetting;
                                        }
                                    }

                                    Gems.ClearRows();
                                    GetGems();
                                }
                                else
                                {
                                    Parent.Machine.Utility.BotSettings.GemSettings.Add(gemSetting);

                                    HudList.HudListRowAccessor row = Gems.AddRow();
                                    using (HudStaticText text = new HudStaticText())
                                    {
                                        text.Text = Parent.Machine.Core.WorldFilter[Parent.Machine.Core.Actions.CurrentSelection].Name;
                                        row[0]    = text;
                                    }

                                    using (HudStaticText text = new HudStaticText())
                                    {
                                        text.Text = GemKeyword.Text;
                                        row[1]    = text;
                                    }
                                    using (HudStaticText text = new HudStaticText())
                                    {
                                        text.Text = GemHeading.Text;
                                        row[2]    = text;
                                    }
                                }

                                Parent.Machine.Utility.SaveBotSettings();

                                GemKeyword.Text = "";
                                GemHeading.Text = "";
                            }
                            else
                            {
                                Debug.ToChat("Please enter a heading.");
                            }
                        }
                        else
                        {
                            Debug.ToChat("Please enter a keyword.");
                        }
                    }
                    else
                    {
                        Debug.ToChat("That is not recognized as a gem. Please select a portal gem.");
                    }
                }
                else
                {
                    Debug.ToChat("Please select a portal gem.");
                }
            }
            catch (Exception ex)
            {
                Debug.LogException(ex);
            }
        }