示例#1
0
            protected override void OnTarget(Mobile from, object target)
            {
                if (target is SiegeMachine)
                {
                    SiegeMachine st = target as SiegeMachine;

                    if (st == m_Tower)
                    {
                        m_Tower.Open = false;

                        from.SendMessage("This tower will no longer accept design pieces.");
                        return;
                    }
                }
                else if (target is SiegeMachineComponent)
                {
                    SiegeMachineComponent comp = target as SiegeMachineComponent;
                    Point3D offset;
                    int     x = 0, y = 0, z = 0;

                    if (m_Tower.Contains(comp))
                    {
                        m_Tower.RemoveTowerPart(comp);
                    }

                    x = (comp.X - m_Tower.X);
                    y = (comp.Y - m_Tower.Y);
                    z = (comp.Z - m_Tower.Z);

                    offset = new Point3D(x, y, z);

                    comp.Tower = m_Tower;
                    m_Tower.AddTowerPart(comp, offset);

                    from.SendMessage("The component has been added to the tower design. Select another, or press Esc to cancel.");
                    from.Target = new InternalTarget(m_Tower);
                }
                else
                {
                    from.SendMessage("You can only insert items of type \'SiegeMachineComponent\' into the tower design.");
                    from.Target = new InternalTarget(m_Tower);
                }
            }