Ejemplo n.º 1
0
        /// <summary>
        /// Changes mode to the specified one and logs it on the console.
        /// </summary>
        /// <param name="modeType">The CECP mode type.</param>
        private void ChangeMode(CECPModeType modeType)
        {
            _textLogger.WriteLine($"{CECPConstants.EnginePrefix}: Mode changed to {modeType}.");

            var ficsModeFactory = new CECPModeFactory();

            _cecpMode               = ficsModeFactory.Create(modeType);
            _cecpMode.OnSendData   += CECPMode_OnSendData;
            _cecpMode.OnChangeMode += CECPMode_OnChangeMode;
        }
        /// <summary>
        /// Creates a new instance of the CECP mode specified in the parameter.
        /// </summary>
        /// <param name="type">The CECP mode.</param>
        /// <exception cref="CECPModeNotFoundException">Thrown when the factory cannot create CECP mode with the specified type (enum value not supported).</exception>
        /// <returns>The CECP mode instance.</returns>
        public CECPModeBase Create(CECPModeType type)
        {
            switch (type)
            {
            case CECPModeType.Init: return(new InitMode());

            case CECPModeType.Game: return(new GameMode());
            }

            throw new CECPModeNotFoundException();
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ChangeModeEventArgs"/> class.
 /// </summary>
 /// <param name="newModeType">The new FICS mode.</param>
 public ChangeModeEventArgs(CECPModeType newModeType)
 {
     NewModeType = newModeType;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Changes mode to the specified one.
 /// </summary>
 /// <param name="newModeType">The new CECP mode.</param>
 public void ChangeMode(CECPModeType newModeType)
 {
     OnChangeMode?.Invoke(this, new ChangeModeEventArgs(newModeType));
 }