Server.Regions.GuardedRegion.MakeGuard C# (CSharp) Méthode

MakeGuard() public méthode

public MakeGuard ( Server.Mobile focus ) : void
focus Server.Mobile
Résultat void
		public override void MakeGuard( Mobile focus )
		{
			BaseGuard useGuard = null;

			foreach ( Mobile m in focus.GetMobilesInRange( 8 ) )
			{
				if ( m is BaseGuard )
				{
					BaseGuard g = (BaseGuard)m;

					if ( g.Focus == null ) // idling
					{
						useGuard = g;
						break;
					}
				}
			}

			if ( useGuard == null )
			{
				m_GuardParams[0] = focus;

				try { Activator.CreateInstance( m_GuardType, m_GuardParams ); } catch {}
			}
			else
				useGuard.Focus = focus;
		}

Usage Example

Exemple #1
0
 protected override void OnTick()
 {
     if (m_CalledOn.Alive && m_CalledOn.Region.IsPartOf(m_GuardedRegion))
     {
         if (m_Caller != null && !m_Caller.Deleted && m_Caller.InRange(m_CalledOn, 12) && m_Caller.InLOS(m_CalledOn) && m_Caller.CanSee(m_CalledOn))
         {
             m_GuardedRegion.MakeGuard(m_CalledOn);
             if (!(m_Caller is BaseGuard) && (m_Caller.BodyValue == 400 || m_Caller.BodyValue == 401))
             {
                 m_Caller.Say(1013037 + Utility.Random(16));
             }
         }
     }
 }