当前位置: 首页>>代码示例>>C#>>正文


C# WoWPoint.DistanceSqr方法代码示例

本文整理汇总了C#中WoWPoint.DistanceSqr方法的典型用法代码示例。如果您正苦于以下问题:C# WoWPoint.DistanceSqr方法的具体用法?C# WoWPoint.DistanceSqr怎么用?C# WoWPoint.DistanceSqr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WoWPoint的用法示例。


在下文中一共展示了WoWPoint.DistanceSqr方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateBehavior

        protected override Composite CreateBehavior()
        {
            return _root ?? (_root = new PrioritySelector(
                // if not in a turret than move to one and interact with it
                new Decorator(ret => !InVehicle,
                    new Sequence(ctx => GetMustang(), // set Turret as context
                        new DecoratorContinue(ctx => ctx != null && ((WoWUnit)ctx).DistanceSqr > 5 * 5,
                            new Action(ctx =>
                                           {
                                               Navigator.MoveTo(((WoWUnit)ctx).Location);
                                               TreeRoot.StatusText = "Moving To Mustang";
                                           })),
                        new DecoratorContinue(ctx => ctx != null && ((WoWUnit)ctx).DistanceSqr <= 5 * 5,
                            new Action(ctx =>
                                           {
                                               Logging.Write("Interacting with Mustang");
                                               if (Me.Mounted)
                                                   Mount.Dismount();
                                               ((WoWUnit)ctx).Interact();
                                           })))),
                // Find the nearest spider and if none exist then move to thier spawn location
                    new Decorator(ret => _currentTarget == null || !_currentTarget.IsValid || !_currentTarget.IsAlive,
                            new Action(ctx =>
                                           {
                                               _currentTarget = ObjectManager.GetObjectsOfType<WoWUnit>()
                                                   .Where(
                                                       u =>
                                                       u.IsAlive && !_blackList.Contains(u.Guid) && u.Entry == 44284).
                                                   OrderBy(u => u.DistanceSqr).FirstOrDefault();
                                               if (_currentTarget == null)
                                               {
                                                   Navigator.MoveTo(_spiderLocation);
                                                   Logging.Write("No spiders found. Moving to spawn point");
                                               }
                                               else
                                               {
                                                   _movetoPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation,
                                                                                                   _currentTarget.
                                                                                                       Location, -5);
                                                   Logging.Write("Locked on a new target. Distance {0}", _currentTarget.Distance);
                                               }
                                           })),

                            new Sequence(
                                new Action(ctx => TreeRoot.StatusText = "Scaring spider towards lumber mill"),
                                new Action(ctx =>
                                               { // blacklist spider if it doesn't move
                                                   if (DateTime.Now - _stuckTimeStamp > TimeSpan.FromSeconds(6))
                                                   {
                                                       _stuckTimeStamp = DateTime.Now;
                                                       if (_movetoPoint.DistanceSqr(_lastMovetoPoint) < 3 * 3)
                                                       {
                                                           Logging.Write("Blacklisting spider");
                                                           _blackList.Add(_currentTarget.Guid);
                                                           _currentTarget = null;
                                                           return RunStatus.Failure;
                                                       }
                                                       _lastMovetoPoint = _movetoPoint;
                                                   }
                                                   return RunStatus.Success;
                                               }),
                                new Action(ctx =>
                                                {
                                                    // update movepoint
                                                    _movetoPoint =
                                                        WoWMathHelper.CalculatePointFrom(_lumberMillLocation,
                                                                                        _currentTarget.
                                                                                            Location, -7);
                                                    if (_movetoPoint.DistanceSqr(Me.Location) >8 * 8)
                                                    {
                                                        Navigator.MoveTo(_movetoPoint);
                                                        return RunStatus.Running;
                                                    }
                                                    return RunStatus.Success;
                                                }),
                                new WaitContinue(2, ret => !Me.IsMoving, new ActionAlwaysSucceed()),
                                new Action(ctx =>
                                               {
                                                   using (new FrameLock())
                                                   {
                                                       Me.SetFacing(_lumberMillLocation);
                                                       WoWMovement.Move(WoWMovement.MovementDirection.ForwardBackMovement);
                                                       WoWMovement.MoveStop(WoWMovement.MovementDirection.ForwardBackMovement);
                                                       //Lua.DoString("CastSpellByID(83605)");
                                                   }
                                               }),
                            new WaitContinue(TimeSpan.FromMilliseconds(200), ret => false, new ActionAlwaysSucceed()),
                             new Action(ctx => Lua.DoString("CastSpellByID(83605)"))

                /*
                              new Action(ctx =>
                               {
                                   var unit = ctx as WoWUnit;
                                   if (unit != null && unit.IsValid && unit.IsAlive)
                                   {
                                       // move to a point that places the spider between player and lumber mill
                                       var movetoPoint = WoWMathHelper.CalculatePointFrom(_lumberMillLocation, unit.Location, -5);
                                       // blacklist spider if its not moving
                                       if (DateTime.Now - _stuckTimeStamp > TimeSpan.FromSeconds(6))
                                       {
//.........这里部分代码省略.........
开发者ID:swypemaster,项目名称:saintsorsinners,代码行数:101,代码来源:ThisMeansWAR.cs


注:本文中的WoWPoint.DistanceSqr方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。