public HealerAddEditHealRule(HealRule healRule) { InitializeComponent(); if (healRule != null) { this._healRule = healRule; btnAdd.Visibility = System.Windows.Visibility.Hidden; btnSave.Visibility = System.Windows.Visibility.Visible; FillFields(); } }
public void Execute(HealRule rule) { HealState = HealerState.ExecuteRule; bool IsSpell = (Spells.Instance.FindSpell(rule.Item.Name) != null) ? true : false; if (IsSpell) { if (!new Cooldown().CanCast(rule.Item.Name)) return; if (HotkeysGame.FindSpell(rule.Item.Name) != 0) { InputControl.UseHot(HotkeysGame.FindSpell(rule.Item.Name)); } Thread.Sleep(new Random().Next(rule.DL_MIN,rule.DL_MAX)); } else { int itemID = (Items.FindByName(rule.Item.Name).ItemID); if (HotkeysGame.FindItem(itemID) != 0) { InputControl.UseHot(HotkeysGame.FindItem(itemID)); } Thread.Sleep(new Random().Next(rule.DL_MIN, rule.DL_MAX)); } }
private void btnSave_Click(object sender, RoutedEventArgs e) { if (ValidiateFields()) { Healer.Instance.HealRules.Remove(_healRule); HealRule newrule = new HealRule(); newrule.Item = (HealItem)cbHealItem.SelectedItem; newrule.HP_MIN = Convert.ToInt32(txHPrangeMin.Text); newrule.HP_MAX = Convert.ToInt32(txHPrangeMax.Text); newrule.MP_MIN = Convert.ToInt32(txMPrangeMin.Text); newrule.MP_MAX = Convert.ToInt32(txMPrangeMax.Text); newrule.DL_MIN = Convert.ToInt32(txDelayMin.Text); newrule.DL_MAX = Convert.ToInt32(txDelayMax.Text); newrule.lifetime = Convert.ToInt32(txLifeTime.Text); newrule.priority = Convert.ToInt32(txPriority.Text); if (rbHPexa.IsChecked == true) newrule.HPRange = HealerRangeType.Exact; else newrule.HPRange = HealerRangeType.Percent; if (rbMPexa.IsChecked == true) newrule.MPRange = HealerRangeType.Exact; else newrule.MPRange = HealerRangeType.Percent; foreach (HealerAdditionalCondition condition in cbAddCondition.Items) newrule.Additionals.Add(condition); Healer.Instance.HealRules.Add(newrule); this.Hide(); } }
public bool Match(HealRule rule) { HealState = HealerState.CheckingRule; if (rule.Additionals != null) { List<HealerAdditionalCondition> conditions = new List<HealerAdditionalCondition>(); conditions = rule.Additionals.Where(c => c.Active).ToList(); if (conditions.Count > 0) { foreach (HealerAdditionalCondition condition in conditions) { if (!MatchCondition(condition)) return false; } } } bool matchhp = false; bool matchmp = false; switch (rule.HPRange) { case HealerRangeType.Exact: matchhp = (Player.Health > rule.HP_MIN && Player.Health < rule.HP_MAX) ? true : false; break; case HealerRangeType.Percent: matchhp = (Player.HealthPercent > rule.HP_MIN && Player.HealthPercent < rule.HP_MAX) ? true : false; break; } switch (rule.MPRange) { case HealerRangeType.Exact: matchmp = (Player.Mana > rule.MP_MIN && Player.Mana < rule.MP_MAX) ? true : false; break; case HealerRangeType.Percent: matchmp = (Player.ManaPercent > rule.MP_MIN && Player.ManaPercent < rule.MP_MAX) ? true : false; break; } return (matchhp && matchmp); }