Ejemplo n.º 1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                if (m_Cannon == null || m_Cannon.Deleted)
                {
                    return;
                }

                var p = targeted as IPoint3D;

                if (p == null)
                {
                    return;
                }

                if (!Utility.InRange(new Point3D(p), m_Cannon.Location, 0))
                {
                    bool allow = false;

                    int x = p.X - m_Cannon.X;
                    int y = p.Y - m_Cannon.Y;

                    switch (m_Cannon.CannonDirection)
                    {
                    case CannonDirection.North:
                        if (y < 0 && Math.Abs(x) <= -y)
                        {
                            allow = true;
                        }

                        break;

                    case CannonDirection.East:
                        if (x > 0 && Math.Abs(y) <= x)
                        {
                            allow = true;
                        }

                        break;

                    case CannonDirection.South:
                        if (y > 0 && Math.Abs(x) <= y)
                        {
                            allow = true;
                        }

                        break;

                    case CannonDirection.West:
                        if (x < 0 && Math.Abs(y) <= -x)
                        {
                            allow = true;
                        }

                        break;
                    }

                    if (allow && Utility.InRange(new Point3D(p), m_Cannon.Location, 200) && from.InRange(m_Cannon, 10))
                    {
                        m_Cannon.DoFireEffect(p, from);
                    }
                    else
                    {
                        from.SendLocalizedMessage(1076203);     // Target out of range.
                    }
                }
                else
                {
                    from.SendLocalizedMessage(1076215);     // Cannon must be aimed farther away.
                }
            }