public void ClearTurnChoices() { ComboPartners.Clear(); SelectedSkill = null; SelectedItem = null; SelectedWeapon = null; SelectedTargets.Clear(); MovingLocation = -1; CriticalHitRatio = 1; TargetResults.Clear(); EffectResults.Clear(); }
public void DecideMove(List <Player> players, List <Enemy> enemies) { if (!IsConscious) { return; } SelectedTargets.Clear(); SelectedSkill = Skills.Count > 0 ? Skills[RandInt(0, Skills.Count - 1)] : null; SelectedItem = null; SelectedWeapon = Weapons.Count > 0 && SelectedSkill != null && SelectedSkill.IsOffense() ? Weapons[RandInt(0, Weapons.Count - 1)] : null; SelectedTargets.Add(players[RandInt(0, players.Count - 1)]); }
// Helper function for RedirectUnconsciousTarget private void RedirectRandomScope <T>(List <T> opponents, int toReplace) where T : Battler { while (toReplace > 0) { T newTarget = RandList(opponents); if (!newTarget.IsConscious) { continue; } SelectedTargets.Add(newTarget); toReplace--; } }
/// <summary> /// Performs custom actions when the check state of an item changes</summary> /// <param name="sender">Sender control</param> /// <param name="e">Event args</param> void listView_ItemCheck(object sender, ItemCheckEventArgs e) { if (m_listView.SortingItems) { return; } if (m_listView.MultiSelect) { m_targetsLastChecked = SelectedTargets.ToList(); } else if (e.NewValue == CheckState.Checked) { m_targetsLastChecked = SelectedTargets.ToList(); } }
public override bool TryToAddTarget(object target) { if (!WaitForTarget) { if (RemainingCost != null) { if (RemainingCost.RequiredTargetCount > 0 && target is CardInstance) { CardInstance cat = target as CardInstance; RemainingCost = RemainingCost.Pay(ref cat, CardSource); if (cat == null) { return(true); } } } return(false); } if (target is CardInstance) { CardInstance ci = target as CardInstance; if (ci.BindedAction != null) { target = ci.BindedAction; } } //other target group are possible, should change foreach (Target ct in ValidTargets) { if (ct.Accept(target, CardSource)) { if (Source.Effects.AcceptTarget(target)) { SelectedTargets.Add(target); return(true); } } } Magic.AddLog("Invalid target: " + target.ToString()); return(false); }
// Helper function for RedirectUnconsciousTarget private void RedirectScopeSplash <T>(List <T> opponents, int i) where T : Battler { T newTarget = opponents[i]; SelectedTargets.Clear(); SelectedTargets.Add(newTarget); foreach (T oneTarget in opponents) { int xDist = Math.Abs(oneTarget.XPosition - newTarget.XPosition); int zDist = Math.Abs(oneTarget.ZPosition - newTarget.ZPosition); if (xDist > 1 && zDist > 1) { continue; } if (xDist != 0 || zDist != 0) { SelectedTargets.Add(newTarget); } } }
/// <summary> /// Performs custom actions when checked state of an item changes</summary> /// <param name="sender">Sender control</param> /// <param name="e">Event args</param> void listView_ItemChecked(object sender, ItemCheckedEventArgs e) { if (m_listView.SortingItems) { return; } if (m_listView.MultiSelect) { var currentSelected = SelectedTargets.ToList(); if (!m_targetsLastChecked.OrderBy(x => x.Endpoint).SequenceEqual(currentSelected.OrderBy(x => x.Endpoint))) { OnSelectedTargetsChanged(new SelectedTargetsChangedArgs(m_targetsLastChecked, SelectedTargets)); } } else { if (e.Item.Checked) { //unchek the rest foreach (ListViewItem item in m_listView.Items) { if ((item != null) && item.Checked && item != e.Item) { item.Checked = false; } } var currentSelected = SelectedTargets.ToList(); if (!m_targetsLastChecked.OrderBy(x => x.Endpoint).SequenceEqual(currentSelected.OrderBy(x => x.Endpoint))) { OnSelectedTargetsChanged(new SelectedTargetsChangedArgs(m_targetsLastChecked, SelectedTargets)); } } } }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /// -- Tool Pre-Actions -- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// public bool RedirectUnconsciousTarget <T>(List <T> opponents) where T : Battler { int i; int removed = 0; bool removedMain = false; for (i = 0; i < SelectedTargets.Count; i++) { if (SelectedTargets[i].IsConscious) { continue; } SelectedTargets.RemoveAt(i); removed++; if (i == 0) { removedMain = true; } } if (SelectedTargets.Count > 0) { return(true); } i = 0; int scope = 0; int randomActs = 0; if (SelectedSkill != null) { scope = SelectedSkill.Scope; } else if (SelectedItem != null) { scope = SelectedItem.Scope; } if (SelectedSkill != null) { randomActs = SelectedSkill.RandomActs; } else if (SelectedItem != null) { randomActs = SelectedItem.RandomActs; } switch (scope) { case 1: case 2: while (i < opponents.Count && !opponents[i].IsConscious) { i++; } if (i == opponents.Count) { return(false); } if (scope == 1 && randomActs > 0) { RedirectRandomScope(opponents, removed); } else if (scope == 2 && removedMain) { RedirectScopeSplash(opponents, i); } else { SelectedTargets.Add(opponents[i]); } break; case 3: case 4: int redirected = -1; for (i = 0; i < opponents.Count; i++) { int pos = scope == 3 ? opponents[i].XPosition : opponents[i].ZPosition; if (!opponents[i].IsConscious || redirected >= 0 && redirected != pos) { continue; } SelectedTargets.Add(opponents[i]); redirected = pos; } break; } return(true); }