GameCommon.GameControlsManager.InitInternal C# (CSharp) Method

InitInternal() private method

private InitInternal ( ) : bool
return bool
        bool InitInternal()
        {
            //register config settings
            EngineApp.Instance.Config.RegisterClassParameters( typeof( GameControlsManager ) );

            //create items
            {
                int controlKeyCount = 0;
                {
                    foreach( object value in Enum.GetValues( typeof( GameControlKeys ) ) )
                    {
                        GameControlKeys controlKey = (GameControlKeys)value;
                        if( (int)controlKey >= controlKeyCount )
                            controlKeyCount = (int)controlKey + 1;
                    }
                }

                items = new GameControlItem[ controlKeyCount ];
                for( int n = 0; n < controlKeyCount; n++ )
                {
                    if( !Enum.IsDefined( typeof( GameControlKeys ), n ) )
                    {
                        Log.Fatal( "GameControlsManager: Init: Invalid \"GameControlKeys\" enumeration." );
                        return false;
                    }
                    GameControlKeys controlKey = (GameControlKeys)n;
                    items[ n ] = new GameControlItem( controlKey );
                }
            }

            //itemsControlKeysDictionary
            {
                itemsControlKeysDictionary = new Dictionary<GameControlKeys, GameControlItem>();
                foreach( GameControlItem item in items )
                    itemsControlKeysDictionary.Add( item.ControlKey, item );
            }

            return true;
        }

Usage Example

Example #1
0
        ///////////////////////////////////////////

        /// <summary>
        /// Initialization the class.
        /// </summary>
        /// <returns><b>true</b> if the object successfully initialized; otherwise, <b>false</b>.</returns>
        public static bool Init()
        {
            if (instance != null)
            {
                Log.Fatal("GameControlsManager class is already initialized.");
            }

            instance = new GameControlsManager();
            bool ret = instance.InitInternal();

            if (!ret)
            {
                Shutdown();
            }
            return(ret);
        }
All Usage Examples Of GameCommon.GameControlsManager::InitInternal