public static BaseDoorTrap CreateTrapByType(DoorTrapType type, Mobile owner, int uses)
        {
            BaseDoorTrap trap = null;

            switch (type)
            {
            case DoorTrapType.Arrow:
                trap = new DoorArrowTrap(owner, uses);
                break;

            case DoorTrapType.Dart:
                trap = new DoorDartTrap(owner, uses);
                break;

            case DoorTrapType.Explosion:
                trap = new DoorExplosionTrap(owner);
                break;

            case DoorTrapType.Guillotine:
                trap = new DoorGuillotineTrap(owner);
                break;

            case DoorTrapType.Poison:
                trap = new DoorPoisonTrap(owner, uses);
                break;
            }

            return(trap);
        }
        public virtual bool Install(Mobile m, BaseDoor door, out string message)
        {
            if (door.CanInstallTrap(m))
            {
                if (door.HasTrap() && this.TrapType == door.TrapType && door.DoorTrap.Refillable)
                {
                    door.DoorTrap.Recharge(this.InitialUses);
                    message = "A trap of the same type was already installed on this door, so you refill its ammunition.";
                    return(true);
                }

                if (door.AttachTrap(BaseDoorTrap.CreateTrapByType(_trapType, _owner, _initialUses)))
                {
                    message = "You successfully install the trap.";
                    return(true);
                }

                if (door.HasTrap() && this.TrapType != door.TrapType)
                {
                    message = "This door already appears to be trapped.";
                    return(false);
                }
            }

            message = "You fail to install the trap.";
            return(false);
        }
Example #3
0
        public virtual bool AttachTrap(BaseDoorTrap trap)
        {
            if (HasTrap() || trap == null)
                return false;

            _trap = trap;
            _trapType = trap.TrapType;

            trap.Active = true;
            trap.Door = this;

            return true;
        }
Example #4
0
 public virtual void RemoveTrap()
 {
     _trap = null;
     _trapType = DoorTrapType.None;
 }