Exemple #1
0
        protected override Composite CreateBehavior()
        {
            return(_root ?? (_root =
                                 new PrioritySelector(

                                     new Decorator(ret => Counter >= 1,
                                                   new Action(ret => _isDone = true)),

                                     new PrioritySelector(

                                         new Decorator(ret => !MovedToTarget,
                                                       new Action(delegate
            {
                // using Styx.Logic.BehaviorTree;
                TreeRoot.GoalText = "Ship Behavior: Running";
                TreeRoot.StatusText = "Moving To Dock";

                if (DockLocation.Distance(me.Location) > 3)
                {
                    Navigator.MoveTo(DockLocation);
                }
                else
                {
                    MovedToTarget = true;
                    return RunStatus.Success;
                }

                return RunStatus.Running;
            })
                                                       ),

                                         new Decorator(ret => MovedToTarget,
                                                       new Action(delegate
            {
                objectList = ObjectManager.GetObjectsOfType <WoWGameObject>()
                             .Where(u => u.Entry == ObjectID)
                             .OrderBy(u => u.Distance).ToList();


                TreeRoot.StatusText = "Waiting For Ship";

                foreach (WoWGameObject value in objectList)
                {
                    Tripper.Tools.Math.Matrix m = value.GetWorldMatrix();

                    WoWPoint matrixLocation = new WoWPoint(m.M41, m.M42, m.M43);

                    //Logging.Write("" + matrixLocation.X + " " + matrixLocation.Y + " " + matrixLocation.Z);

                    if (GetOffLocation.Distance(me.Location) < 3)
                    {
                        _isDone = true;
                        return RunStatus.Success;
                    }

                    if (matrixLocation.Distance(me.Location) < 20 && !MovedOnShip)
                    {
                        TreeRoot.StatusText = "Moving Onto Ship";
                        Thread.Sleep(3000);
                        WoWMovement.ClickToMove(GetOnLocation);
                        MovedOnShip = true;
                    }
                    else if (MovedOnShip)
                    {
                        TreeRoot.StatusText = "On Ship, Waiting";
                        if (ShipStandLocation.X > 0)
                        {
                            WoWMovement.ClickToMove(ShipStandLocation);
                        }
                        if (matrixLocation.Distance(EndLocation) < 20)
                        {
                            TreeRoot.StatusText = "Moving Off Ship";
                            Thread.Sleep(3000);
                            WoWMovement.ClickToMove(GetOffLocation);
                            MovedOnShip = true;
                        }
                    }

                    return RunStatus.Success;
                }

                return RunStatus.Running;
            })
                                                       ),

                                         new Action(ret => Logging.Write(""))
                                         )
                                     )));
        }