コード例 #1
0
            protected override void OnTarget(Mobile from, object targeted)
            {
                Item iBattery = targeted as Item;

                if (iBattery is RobotItem)
                {
                    RobotItem xBattery = (RobotItem)iBattery;

                    int myCharges = xBattery.m_Charges;

                    if (!iBattery.IsChildOf(from.Backpack))
                    {
                        from.SendMessage("You can only use this battery on robots in your pack.");
                    }
                    else if (myCharges < 100)
                    {
                        xBattery.m_Charges = xBattery.m_Charges + 1;

                        if (xBattery.m_Charges > 100)
                        {
                            xBattery.m_Charges = 100;
                        }

                        from.SendMessage("You charge your robot with the battery.");
                        from.RevealingAction();
                        from.PlaySound(0x559);

                        xBattery.InvalidateProperties();

                        m_Battery.Delete();
                    }
                    else
                    {
                        from.SendMessage("That robot is already fully charged.");
                    }
                }
                else
                {
                    from.SendMessage("You don't think that will really do anything.");
                }
            }