www.pudn.com > IntroductionTo3DGameEngineDesign.rar > GameCommand.cs


using System; 
using System.Collections; 
 
namespace GameEngine 
{ 
	///  
	/// Summary description for GameCommand. 
	///  
	public delegate void CommandFunction( string sData ); 
 
	public class GameCommand  
	{ 
 
		private string          m_sCommand = null; 
		private string          m_sHelp    = null; 
		private CommandFunction m_Function = null; 
 
		public string Command { get { return m_sCommand; } } 
		public string Help { get { return m_sHelp; } } 
 
		///  
		/// Constructor 
		///  
		///  
		///  
		///  
		public GameCommand(string sCmd, string sHelp, CommandFunction pFunc ) 
		{ 
			m_sCommand = sCmd; 
			m_sHelp = sHelp; 
			m_Function = pFunc; 
		} 
 
		///  
		/// Execute the attached delegate function 
		///  
		///  
		public void Execute( string sData ) 
		{ 
			if ( m_Function != null ) 
			{ 
				m_Function(sData); 
			} 
		} 
 
	} 
}