Пример #1
0
        private void OnTarget(Mobile from, object targeted)
        {
            BaseBoat ship = null;

            if (targeted is BaseBoat)
            {
                ship = (BaseBoat)targeted;
            }
            else if (targeted is TillerMan)
            {
                ship = ((TillerMan)targeted).Boat;
            }
            else if (targeted is Plank)
            {
                ship = ((Plank)targeted).Boat;
            }
            else if (targeted is Hold)
            {
                ship = ((Hold)targeted).Boat;
            }

            if (ship == null)
            {
                SayTo(from, true, "That is not a ship!");
                return;
            }
            else if (!InRange(ship.Location, 50))
            {
                SayTo(from, true, "That is too far away!");
                return;
            }

            BaseBoat.DryDockResult res = ship.CheckDryDock(from);
            switch (res)
            {
            case BaseBoat.DryDockResult.Dead:
                SayTo(from, true, "Thou art dead and cannot do that.");
                break;

            case BaseBoat.DryDockResult.Decaying:
                SayTo(from, true, "I will not dock a boat that is sinking!");
                break;

            case BaseBoat.DryDockResult.Hold:
                SayTo(from, true, "You must clear the ship's hold before you can dock it.");
                break;

            case BaseBoat.DryDockResult.Items:
                SayTo(from, true, "You must clear the ship's deck of items before docking it.");
                break;

            case BaseBoat.DryDockResult.Mobiles:
                SayTo(from, true, "You cannot dock a ship with beings on board!");
                break;

            case BaseBoat.DryDockResult.NoKey:
                SayTo(from, true, "That ship does not belong to you.");
                break;

            case BaseBoat.DryDockResult.NotAnchored:
                SayTo(from, true, "The ship is not anchored.");
                break;

            case BaseBoat.DryDockResult.Valid:
            {
                if (!from.BankBox.ConsumeTotal(typeof(Gold), 25))
                {
                    SayTo(from, true, "You do not have 25 gold in your bank account to pay for the docking of this ship.");
                    break;
                }

                BaseDockedBoat claim = ship.DockedBoat;
                if (claim == null)
                {
                    break;
                }

                StringBuilder sb = new StringBuilder("a ship claim ticket");
                if (this.Region.Name != "")
                {
                    sb.AppendFormat(" from {0}", this.Region.Name);
                }
                if (claim.ShipName != null && claim.ShipName != "")
                {
                    sb.AppendFormat(" for the {0}", claim.ShipName);
                }
                claim.Name         = sb.ToString();
                claim.DockLocation = this.Home != Point3D.Zero ? this.Home : ship.Location;

                ship.RemoveKeys(from);
                ship.Delete();

                from.AddToBackpack(claim);

                SayTo(from, true, "Here is your claim ticket.  I suggest you store it in a safe place.");
                break;
            }
            }
        }