/// <inheritdoc /> protected override void OnInitialize() { base.OnInitialize(); var loadingTask = Task.Run(async delegate { try { var supportedTypes = Reference.Type.Model.SupportedTypes; var possibleTargetsLoadTask = _resourceServiceModel.GetResources(new ResourceQuery { Types = supportedTypes }); TaskNotifier = new TaskNotifier(possibleTargetsLoadTask); var possibleTargets = await possibleTargetsLoadTask; var possibleTargetsVms = possibleTargets.Where(resource => Reference.Targets.All(t => t.Id != resource.Id)) .Select(possible => new ResourceInfoViewModel(possible)); await Execute.OnUIThreadAsync(delegate { PossibleTargets = possibleTargetsVms.ToArray(); SelectedTarget = PossibleTargets.FirstOrDefault(); NotifyOfPropertyChange(nameof(PossibleTargets)); }); } catch (Exception e) { await Execute.OnUIThreadAsync(() => ErrorMessage = e.Message); } }); TaskNotifier = new TaskNotifier(loadingTask); }
public static Composite SelectClosestTarget() { // Just use the leader's target if it's in range. return(new Decorator(ret => (PossibleTargets.Count > 0), new TreeSharp.Action(delegate { SetTarget(PossibleTargets.OrderBy(tar => tar.DistanceSqr).FirstOrDefault(), TargetMode.SingleTarget); }) )); }
//Gets the possible targets public void GetTargets() { //Empty Targets PossibleTargets.Clear(); //Fill Possible Targets foreach (GameObject Char in BSM.PlayerChars) { if ((BSM.ThisTurn.Action.MustBeDown == true && Char.GetComponent <BaseCharStateMachine>().Status_Down == true) || BSM.ThisTurn.Action.MustBeDown == false) { PossibleTargets.Add(Char); } } //If Free-For-All match, Fill in EnemyChars other than this one if (BSM.Refferee.MatchType == ReffSM.Type.T_THREAT || BSM.Refferee.MatchType == ReffSM.Type.F_FOURWAY) { foreach (GameObject Char in BSM.EnemyChars) { if (Char != Wrestler) { if ((BSM.ThisTurn.Action.MustBeDown == true && Char.GetComponent <BaseCharStateMachine>().Status_Down == true) || BSM.ThisTurn.Action.MustBeDown == false) { PossibleTargets.Add(Char); } } } } }
public static Composite SelectFocusTarget() { return(new Decorator(ret => PossibleTargets.Any(TargetManager.IsFocusTarget), new TreeSharp.Action(delegate { //target any focus mobs, attack the one with the least amount of health. SetTarget(PossibleTargets.OrderBy(unit => unit.CurrentHealth).First(IsFocusTarget), TargetMode.FocusTarget); }) )); }
public override void attack() { for (int i = 0; i < PossibleTargets.Count; i++) { GameObject s = PossibleTargets.ElementAt(i).Value; Ship _s = s.GetComponent <Ship>(); _s.takeDamage(this.attackdamage / 3); } }
public static Composite SelectExecuteTarget() { return(new Decorator( ret => AltarboySettings.Instance.ShadowWordDeathForExecute && !SpellManager.Spells["Shadow Word: Death"].Cooldown && PossibleTargets.Any(unit => unit.HealthPercent <= 25 && SafeToShadowWordDeath(unit)), new TreeSharp.Action( delegate { SetTarget(PossibleTargets.First(unit => unit.HealthPercent <= 25), TargetMode.ExecuteTarget); } ) )); }
public List <Shot> Play() { bool isHunting = true; Shot result; while (ShipsDestroyed != Ship.NUM_OF_SHIPS) { Display.Grid(Board); //DISPLAY PURPOSE if (isHunting) { result = Hunt(); if (result.ShotTypeId == (int)ShotType.Hit) { TargetCoords.Add(new Coordinates { X = result.X, Y = result.Y, Val = result.InitialVal.GetValueOrDefault() }); isHunting = false; } } else { result = Target(); if (result.ShotTypeId != (int)ShotType.Missed) { if (result.ShotTypeId == (int)ShotType.Hit) { TargetCoords.Add(new Coordinates { X = result.X, Y = result.Y, Val = result.InitialVal.GetValueOrDefault() }); } else if (result.ShotTypeId == (int)ShotType.Destroyed) { isHunting = true; ShipsDestroyed++; TargetDirection = DirectionTaken.Random; TargetOrientation = Orientation.Random; PossibleTargets.Clear(); TargetCoords.Clear(); } } } if (result.ShotTypeId != (int)ShotType.Duplicate) { Shots.Add(result); ShotNumber++; } } Console.WriteLine("----------------"); //Display Purpose return(Shots); }
void Update() { var hits = new List <SelfieTarget>(PossibleTargets.Where(IsInRange)); var newlyMissed = new List <SelfieTarget>(lastPoints.Except(hits)); foreach (var missed in newlyMissed) { missed.OnLeftSelfie(); } var newlyHit = new List <SelfieTarget>(hits.Except(lastPoints)); foreach (var hit in newlyHit) { hit.OnEnteredSelfie(); } lastPoints = hits; }
private Shot Target() { Shot result = null; PossibleTargets.Clear(); foreach (Coordinates crd in TargetCoords) { PossibleTargets.AddRange(GetAdjacentTargets(crd, TargetOrientation, TargetDirection)); } int randomIndex = GenerateRandom(0, PossibleTargets.Count); result = Board.Grid[PossibleTargets[randomIndex].X, PossibleTargets[randomIndex].Y].Shoot(); result.ShotId = Guid.NewGuid(); result.GameId = GameGuid; result.AIState = (int)State.Target; result.DirectionId = (int)TargetOrientation; result.X = PossibleTargets[randomIndex].X; result.Y = PossibleTargets[randomIndex].Y; result.OrientationId = (int)TargetOrientation; result.ShotNumber = ShotNumber; if (TargetOrientation == Orientation.Random && result.ShotTypeId == (int)ShotType.Hit) { TargetOrientation = FindOrientation(TargetCoords[0], PossibleTargets[randomIndex]); } else if (TargetOrientation != Orientation.Random && result.ShotTypeId == (int)ShotType.Missed) { TargetDirection = GetOppositeDirection(FindDirection(TargetOrientation, TargetCoords[0], new Coordinates { X = result.X, Y = result.Y })); } return(result); }
void Rotation() { if (!ObjectManager.Player.HasPet || ObjectManager.Pet.IsDead) { if (ObjectManager.Target.DistanceToPlayer > 11f) { ShouldMelee = false; if (Spell.IsKnown("Hunter's Mark") && !ObjectManager.Target.GotDebuff("Hunter's Mark")) { Spell.Cast("Hunter's Mark"); } if (Spell.IsKnown("Concussive Shot") && Spell.IsReady("Concussive Shot") && !ObjectManager.Player.IsInCombat) { Spell.Cast("Concussive Shot"); } if (Spell.IsKnown("Serpent Sting") && !ObjectManager.Target.GotDebuff("Serpent Sting")) { Spell.Cast("Serpent Sting"); } else if (Spell.IsKnown("Arcane Shot") && Spell.IsReady("Arcane Shot")) { Spell.Cast("Arcane Shot"); } else { Spell.StartRangedAttack(); } } else { ShouldMelee = true; if (Spell.IsKnown("Aspect of the Monkey") && !ObjectManager.Player.GotAura("Aspect of the Monkey")) { Spell.Cast("Aspect of the Monkey"); } if (Spell.IsReady("Raptor Strike")) { Spell.Cast("Raptor Strike"); } else { Spell.Attack(); } } } else { var currentTarget = ObjectManager.Target; var targettingPlayer = PossibleTargets.Where(x => x.TargetGuid == ObjectManager.Player.Guid); if (targettingPlayer.Any()) { ObjectManager.Player.SetTarget(currentTarget); if (ObjectManager.Pet.TargetGuid != targettingPlayer.FirstOrDefault().Guid) { ObjectManager.Player.SetTarget(currentTarget); ObjectManager.Player.SetTarget(targettingPlayer.FirstOrDefault()); ObjectManager.Pet.Attack(); ObjectManager.Player.SetTarget(currentTarget); } } else { ObjectManager.Pet.Attack(); } if (ObjectManager.Target.DistanceToPlayer > 11f) { ObjectManager.Player.SetTarget(currentTarget); ShouldMelee = false; if (Spell.IsKnown("Aspect of the Hawk") && !ObjectManager.Player.GotAura("Aspect of the Hawk")) { Spell.Cast("Aspect of the Hawk"); } if (Spell.IsKnown("Hunter's Mark") && !ObjectManager.Target.GotDebuff("Hunter's Mark")) { Spell.Cast("Hunter's Mark"); } if (Spell.IsKnown("Rapid Fire") && Spell.IsReady("Rapid Fire") && ObjectManager.Player.IsInCombat) { Spell.Cast("Rapid Fire"); } if (Spell.IsKnown("Intimidation") && Spell.IsReady("Intimidation")) { Spell.Cast("Intimidation"); } if (Spell.IsKnown("Bestial Wrath") && Spell.IsReady("Bestial Wrath")) { Spell.Cast("Bestial Wrath"); } if (Spell.IsKnown("Serpent Sting") && !ObjectManager.Target.GotDebuff("Serpent Sting")) { Spell.Cast("Serpent Sting"); } else if (Spell.IsKnown("Arcane Shot") && Spell.IsReady("Arcane Shot")) { Spell.Cast("Arcane Shot"); } else { Spell.StartRangedAttack(); } } else if (ObjectManager.Target.DistanceToPlayer < 11f && ObjectManager.Target.TargetGuid == ObjectManager.Player.Guid) { ObjectManager.Player.SetTarget(currentTarget); ShouldMelee = true; if (Spell.IsReady("Raptor Strike")) { Spell.Cast("Raptor Strike"); } else { Spell.Attack(); } } else { ObjectManager.Player.SetTarget(currentTarget); ShouldMelee = false; Navigation.Backup(12f); } } }