Пример #1
0
        /// <summary>
        /// Runs the game.
        /// </summary>
        public void Run()
        {
            foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
            {
                //Grabs the components from the Assembly
                if (typeof(IComponent).IsAssignableFrom(type) && type != typeof(IComponent))
                {
                    ECSManager.AddComponent(type);
                }
                //Grabs the Systems from the Assembly
                else if (type.IsSubclassOf(typeof(System)))
                {
                    ECSManager.AddSystem(type);
                }
            }

            window = new RenderWindow(new VideoMode(1024, 768), "New Window");

            SceneManager.LoadStaticScene();

            if (gameOptions.ForceLimit)
            {
                window.SetFramerateLimit(60);
            }

            window.Closed += WindowClosed;

            RunLoop();
        }
Пример #2
0
 public virtual void Update(GameTime gameTime)
 {
     foreach (Entity entity in entities)
     {
         for (int i = 0; i < entity.components.Count; i++)
         {
             ECSManager.SetEntityComponent(entity.entityID, entity.components[i]);
         }
     }
 }
Пример #3
0
        /// <summary>
        /// Place all entity and system initialization here.
        /// </summary>
        protected virtual void Initialize()
        {
            foreach (GameExtension extension in extensions)
            {
                extension.Intitialize();

                foreach (Type systemType in extension.systems)
                {
                    ECSManager.AddSystem(systemType);
                }

                foreach (Type componentType in extension.components)
                {
                    ECSManager.AddComponent(componentType);
                }
            }

            InputManager.Initialize(window);
            ECSManager.Initialize();
        }
Пример #4
0
 /// <summary>
 /// The draw method that loops through each system and draws them.
 /// </summary>
 /// <param name="renderWindow">The window to draw them in.</param>
 protected virtual void Draw(RenderWindow renderWindow)
 {
     ECSManager.Draw(renderWindow);
     SceneManager.Draw(window);
 }
Пример #5
0
 /// <summary>
 /// The update method that runs through all the systems and updates them.
 /// </summary>
 /// <param name="gameTime">The time tool to get various variables</param>
 protected virtual void Update(GameTime gameTime)
 {
     Coroutine.Update(gameTime);
     ECSManager.Update(gameTime);
     SceneManager.Update(gameTime);
 }