예제 #1
0
파일: Level.cs 프로젝트: DittoDog12/GMTB-v3
        /// <summary>
        /// Initialises the level, sets up Manager references
        /// Then Resumes the level if not already run
        /// </summary>
        /// <param name="_sl"> Reference to the Service Locator </param>
        public virtual void Initialise(IServiceLocator _sl)
        {
            mServiceLocator    = _sl;
            mEntityManager     = mServiceLocator.GetService <IEntity_Manager>();
            mSceneManager      = mServiceLocator.GetService <IScene_Manager>();
            mBackgroundManager = mServiceLocator.GetService <IBackground_Manager>();

            if (!firstRun)
            {
                Resume();
            }
        }
예제 #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // TODO: Add your initialization logic here

            base.Initialize();
            // Create Input Manager
            //mInputManager = new Input_Manager();
            // Create Service Locator and all Managers
            mServiceLocator = new ServiceLocator(Content, mContentRoot, mLevels, mMenus);



            // Retrive Managers required
            mSceneManager      = mServiceLocator.GetService <IScene_Manager>();
            mCollisionManager  = mServiceLocator.GetService <ICollision_Manager>();
            mInputManager      = mServiceLocator.GetService <IInput_Manager>();
            mAIManager         = mServiceLocator.GetService <IAI_Manager>();
            mMenuManager       = mServiceLocator.GetService <IMenu_Manager>();
            mLevelManager      = mServiceLocator.GetService <ILevel_Manager>();
            mBackgroundManager = mServiceLocator.GetService <IBackground_Manager>();

            if (mCamera != null)
            {
                mCamera.Intialize(mServiceLocator);
                mMenuManager.ConfigureCamera(mCamera);
            }

            Console.WriteLine("Max Texture Size: " + CalculateMaxTextureSize());
            // Create Content Manager, pass Monogame Content Manager and Path to Content Root
            //mContentManager = new Content_Manager(Content, mContentRoot);
            //mContentManager = mServiceLocator.GetService<IContent_Manager>();

            // Create Background Manager, pass Content Manager
            //mBackgroundManager = new Background_Manager(mContentManager);
            // Create Entity Manager, pass Content and Input Managers
            //mEntityManager = new Entity_Manager(mServiceLocator, mContentManager, mInputManager);
            // Create Scene Manager, pass Entity and Background Managers
            //mSceneManager = new Scene_Manager(mEntityManager, mBackgroundManager);
            // Create Collision Manager, pass Entity Manager and Screen Size variables
            //mCollisionMananger = new Collision_Manager(mEntityManager, new Point(graphics.GraphicsDevice.Viewport.Width, graphics.GraphicsDevice.Viewport.Height));
            // Create AI Manager, Pass the Entity Manager
            //mAIManager = new AI_Manager(mEntityManager);

            // Initialise first Level, pass Scene, Entity and Background Managers
            // mLevels[0].Initialise(mSceneManager, mEntityManager, mBackgroundManager);
            mMenuManager.InitializeMenus();
            mMenuManager.ActivateMenu("main");
            Global.GameState = Global.availGameStates.Menu;
        }
예제 #3
0
 /// <summary>
 /// Set core variables
 /// </summary>
 /// <param name="_sl">Reference to Service Locator</param>
 public void setVars(IServiceLocator _sl)
 {
     mEntityManager = _sl.GetService <IEntity_Manager>();
     mSceneManager  = _sl.GetService <IScene_Manager>();
 }