Пример #1
0
        public override void OnThink()
        {
            if (bootgespawnt == false)
            {
                Map map = this.Map;
                if (map == null)
                {
                    return;
                }
                this.Z       = 0;
                m_PirateShip = new PirateShip();
                Point3D loc     = this.Location;
                Point3D loccrew = this.Location;
                loc     = new Point3D(this.X, this.Y - 1, -5);
                loccrew = new Point3D(this.X, this.Y - 1, this.Z);
                m_PirateShip.MoveToWorld(loc, map);
                bootgespawnt = true;

                for (int i = 0; i < 5; ++i)
                {
                    Pirate m_pirate = new Pirate();
                    m_pirate.MoveToWorld(loccrew, map);
                }
            }

            base.OnThink();
            if (DateTime.Now < m_NextPickup)
            {
                return;
            }

            if (m_PirateShip == null)
            {
                return;
            }

            m_NextPickup = DateTime.Now + TimeSpan.FromSeconds(Utility.RandomMinMax(1, 2));


            feindrichtung = Direction.North;     //default nord
            foreach (Item feind in this.GetItemsInRange(200))
            {
                if (feind is BaseBoat && feind != m_PirateShip && !(feind is PirateShip))
                {
                    List <Mobile>     targets = new List <Mobile>();
                    IPooledEnumerable eable   = feind.GetMobilesInRange(16);

                    foreach (Mobile m in eable)
                    {
                        if (m is PlayerMobile)
                        {
                            targets.Add(m);
                        }
                    }
                    eable.Free();
                    if (targets.Count > 0)
                    {
                        m_feindboot   = feind as BaseBoat;
                        feindrichtung = this.GetDirectionTo(m_feindboot);
                        break;
                    }
                }
            }
            if (m_feindboot == null)
            {
                return;
            }


            if (m_PirateShip != null && m_feindboot != null)
            {
                if (m_PirateShip != null && (feindrichtung == Direction.North) && m_PirateShip.Facing != Direction.North)
                {
                    m_PirateShip.Facing = Direction.North;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.South) && m_PirateShip.Facing != Direction.South)
                {
                    m_PirateShip.Facing = Direction.South;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.East || feindrichtung == Direction.Right || feindrichtung == Direction.Down) && m_PirateShip.Facing != Direction.East)
                {
                    m_PirateShip.Facing = Direction.East;
                }
                else if (m_PirateShip != null && (feindrichtung == Direction.West || feindrichtung == Direction.Left || feindrichtung == Direction.Up) && m_PirateShip.Facing != Direction.West)
                {
                    m_PirateShip.Facing = Direction.West;
                }
                m_PirateShip.StartMove(Direction.North, true);                                              //, false); //Vollgas!

                if (m_PirateShip != null && this.InRange(m_feindboot, 10) && m_PirateShip.IsMoving == true) // In Reichweite? Stop!
                {
                    m_PirateShip.StopMove(false);
                }
            }
            else
            {
                if (m_PirateShip != null && m_PirateShip.IsMoving == true)
                {
                    m_PirateShip.StopMove(false);               //keiner da? anhalten.
                }
            }
        }