Ejemplo n.º 1
0
        /// <summary>
        /// Initialize the game: Initialize display, load resources etc.
        /// </summary>
        /// <param name="width">
        /// A <see cref="System.Int32"/>
        /// </param>
        /// <param name="height">
        /// A <see cref="System.Int32"/>
        /// </param>
        /// <param name="fullscreen">
        /// A <see cref="System.Boolean"/>
        /// </param>
        public void Initialize(int width, int height, bool fullscreen, string windowTitle)
        {
            Log.Write("Engine initializing at " + DateTime.Now);
            gameStates = new List<GameState>();

            //Create resource manager and load resources from the main resource file
            resourceManager = new ResourceManager();
            resourceManager.LoadResources("data");
            //resourceManager.LoadResourceXML(ResourceManager.MainResourceFile);

            //Create the opengl display
            display = new Display();
            display.Initialize(width, height, resourceManager, windowTitle);
            if (fullscreen)
            {
                display.Fullscreen = true;
            }

            input = new InputManager();
            audioManager = new AudioManager(resourceManager);

            timer.Start();
            SimulationSpeed = DefaultSimulationSpeed;
        }
        private void InitializeManager(int numOfChannels, int buffersPerChannel, int bytesPerBuffer, bool threadCall)
        {
            // Set the local variables to parameters
            NumOfChannels = numOfChannels;
            //BuffersPerChannel = buffersPerChannel;
            //BytesPerBuffer = bytesPerBuffer;
            needsUpdate = threadCall;
            AudioSources = new AudioSource[numOfChannels];

            // Create a new Audio channel for every channel specified in local array
            for (int i = 0; i < numOfChannels; i++)
            {
                AudioSources[i] = new AudioSource(buffersPerChannel, bytesPerBuffer);
            }
            
            Manager = this;

            // If we are looking for a threaded call, create a new thread
            if (threadCall)
            {
                // Create a new thread
                ThreadCall = new Thread(UpdateLoop);
                // Thread should be background
                ThreadCall.IsBackground = true;
                // Start the thread
                ThreadCall.Start();
            }

            else
            {
                // No thread so NULL
                ThreadCall = null;
            }
        }