Пример #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="strGameCommand"></param>
 /// <returns></returns>
 public void Register(GameCommandHandler gameCommandHandler)
 {
     if (gameCommandHandler.IgnoreCase == true)
     {
         m_GameCommandsIgnoreCase.Add(gameCommandHandler.GameCommand.ToLower(), gameCommandHandler);
     }
     else
     {
         m_GameCommandsInvariant.Add(gameCommandHandler.GameCommand, gameCommandHandler);
     }
 }
Пример #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strGameCommandLine"></param>
        /// <param name="netState"></param>
        /// <returns></returns>
        public bool CallGameCommand(NetState netState, string strGameCommandLine, bool bIgnoreCaseGameCommand)
        {
            if (bIgnoreCaseGameCommand == true)
            {
                if (Insensitive.StartsWith(strGameCommandLine, m_strPrefix) == false)
                {
                    return(false);
                }
            }
            else
            {
                if (strGameCommandLine.StartsWith(m_strPrefix) == false)
                {
                    return(false);
                }
            }

            int iIndexOf = strGameCommandLine.IndexOf(" ", m_strPrefix.Length);

            if (iIndexOf <= 0)
            {
                return(false);
            }

            string strGameCommand = strGameCommandLine.Substring(m_strPrefix.Length, iIndexOf - m_strPrefix.Length);

            GameCommandHandler gameCommandHandler = null;

            if (bIgnoreCaseGameCommand == true)
            {
                gameCommandHandler = m_GameCommandsIgnoreCase.GetValue(strGameCommand.ToLower());
            }
            else
            {
                gameCommandHandler = m_GameCommandsInvariant.GetValue(strGameCommand);
            }

            if (gameCommandHandler == null)
            {
                return(false);
            }

            string strGameCommandInfo = strGameCommandLine.Substring(iIndexOf + 1);

            gameCommandHandler.CallGameCommand(netState, strGameCommandInfo);

            return(true);
        }
Пример #3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="strGameCommand"></param>
        /// <param name="caseIgnore"></param>
        /// <param name="accessLevel"></param>
        /// <param name="delegateGameCommandCall"></param>
        /// <returns></returns>
        public GameCommandHandler Register(string strGameCommand, bool bIgnoreCase, AccessLevel accessLevel, DelegateGameCommandCall delegateGameCommandCall)
        {
            if (strGameCommand == null || strGameCommand == string.Empty)
            {
                throw new Exception("GameCommandManager.Register(...) - strGameCommand == null || strGameCommand == string.Empty error!");
            }

            GameCommandHandler gameCommand = null;

            if (bIgnoreCase == true)
            {
                string strIgnoreCase = strGameCommand.ToLower();

                gameCommand = m_GameCommandsIgnoreCase.GetValue(strIgnoreCase);
                if (gameCommand == null)
                {
                    gameCommand             = new GameCommandHandler();
                    gameCommand.GameCommand = strGameCommand;
                    gameCommand.IgnoreCase  = bIgnoreCase;
                    gameCommand.AccessLevel = accessLevel;

                    m_GameCommandsIgnoreCase.Add(strIgnoreCase, gameCommand);
                }
            }
            else
            {
                gameCommand = m_GameCommandsInvariant.GetValue(strGameCommand);
                if (gameCommand == null)
                {
                    gameCommand             = new GameCommandHandler();
                    gameCommand.GameCommand = strGameCommand;
                    gameCommand.IgnoreCase  = bIgnoreCase;
                    gameCommand.AccessLevel = accessLevel;

                    m_GameCommandsInvariant.Add(strGameCommand, gameCommand);
                }
            }

            if (delegateGameCommandCall != null)
            {
                gameCommand.ThreadGameCommandCall += new EventHandler <GameCommandEventArgs>(delegateGameCommandCall);
            }

            return(gameCommand);
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="strGameCommand"></param>
 /// <returns></returns>
 public void Register( GameCommandHandler gameCommandHandler )
 {
     if ( gameCommandHandler.IgnoreCase == true )
         m_GameCommandsIgnoreCase.Add( gameCommandHandler.GameCommand.ToLower(), gameCommandHandler );
     else
         m_GameCommandsInvariant.Add( gameCommandHandler.GameCommand, gameCommandHandler );
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strGameCommand"></param>
        /// <param name="caseIgnore"></param>
        /// <param name="accessLevel"></param>
        /// <param name="delegateGameCommandCall"></param>
        /// <returns></returns>
        public GameCommandHandler Register( string strGameCommand, bool bIgnoreCase, AccessLevel accessLevel, DelegateGameCommandCall delegateGameCommandCall )
        {
            if ( strGameCommand == null || strGameCommand == string.Empty )
                throw new Exception( "GameCommandManager.Register(...) - strGameCommand == null || strGameCommand == string.Empty error!" );

            GameCommandHandler gameCommand = null;
            if ( bIgnoreCase == true )
            {
                string strIgnoreCase = strGameCommand.ToLower();

                gameCommand = m_GameCommandsIgnoreCase.GetValue( strIgnoreCase );
                if ( gameCommand == null )
                {
                    gameCommand = new GameCommandHandler();
                    gameCommand.GameCommand = strGameCommand;
                    gameCommand.IgnoreCase = bIgnoreCase;
                    gameCommand.AccessLevel = accessLevel;

                    m_GameCommandsIgnoreCase.Add( strIgnoreCase, gameCommand );
                }
            }
            else
            {
                gameCommand = m_GameCommandsInvariant.GetValue( strGameCommand );
                if ( gameCommand == null )
                {
                    gameCommand = new GameCommandHandler();
                    gameCommand.GameCommand = strGameCommand;
                    gameCommand.IgnoreCase = bIgnoreCase;
                    gameCommand.AccessLevel = accessLevel;

                    m_GameCommandsInvariant.Add( strGameCommand, gameCommand );
                }
            }

            if ( delegateGameCommandCall != null )
                gameCommand.ThreadGameCommandCall += new EventHandler<GameCommandEventArgs>( delegateGameCommandCall );

            return gameCommand;
        }