// @TODO see if this system can be improved or changed

        /// <summary>
        ///
        /// </summary>
        /// <param name="gameTime"></param>
        /// <param name="spriteBatch"></param>
        public void draw(GameTime gameTime, SpriteBatch spriteBatch)
        {
            List <int> ents = ComponentManager.Instance.GetAllEntitiesWithComponentType <FPSCounterComponent>();

            if (ents != null)
            {
                foreach (var ent in ents)
                {
                    FPSCounterComponent fps = ComponentManager.Instance.GetEntityComponent <FPSCounterComponent>(ent);

                    float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;


                    fps.framecount++;
                    timeSinceLastUpdate += elapsed;
                    if (timeSinceLastUpdate > 1)
                    {
                        fps.frameCounter = fps.framecount / timeSinceLastUpdate;

                        game.Window.Title = "FPS: " + fps.frameCounter;

                        fps.framecount       = 0;
                        timeSinceLastUpdate -= 1;
                    }
                }
            }
        }
Beispiel #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()
        {
            CollisionDetectionSystem det = new CollisionDetectionSystem();
            CollisionSystem          col = new CollisionSystem();

            det.Subscribe(col);
            SystemManager.Instance.AddSystem(new ScrollingBackgroundSystem(instance.GraphicsDevice, instance.GetContent <Texture2D>("Pic/gamebackground")));
            SystemManager.Instance.AddSystem(new ChangeCubesSystem());
            SystemManager.Instance.AddSystem(col);
            SystemManager.Instance.AddSystem(new HUDSystem());
            HealthSystem healtSystem = new HealthSystem();

            healtSystem.initialize();
            SystemManager.Instance.AddSystem(healtSystem);
            SystemManager.Instance.AddSystem(det);
            SystemManager.Instance.AddSystem(new MovementSystem());
            SystemManager.Instance.AddSystem(new BallOfSpikesSystem());
            SystemManager.Instance.AddSystem(new SpawnPowerUpSystem(10));
            SystemManager.Instance.AddSystem(new AISystem());
            SystemManager.Instance.AddSystem(new DrawTTLSystem("Fonts/TestFont"));

            FPSCounterComponent fps = new FPSCounterComponent();
            int ids = ComponentManager.Instance.CreateID();

            ComponentManager.Instance.AddComponentToEntity(ids, fps);

            StartUpScreenScene stateOne = new StartUpScreenScene(10000);

            SceneSystem.Instance.setCurrentScene(stateOne);


            base.Initialize();
        }
Beispiel #3
0
        public void Init()
        {
            view = A.Fake <FPSCounterComponent.IFPSCounterComponentView>();
            A.CallTo(() => view.getSizeFromString(A <string> .Ignored)).Returns(textSize);

            graphicConf       = new GraphicConfiguration();
            graphicConf.Width = 100;

            presenter = new FPSCounterComponent(view, graphicConf);
            presenter.Update(new GameTime()); // update first time as this is counted as a second, so the fps are now 1.
        }
Beispiel #4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            // TODO: use this.Content to load your game content here
            baseFont = Content.Load <SpriteFont>("baseFont");

            SceneManager = new SceneManager(this, spriteBatch, new Point(NormalWidth, NormalHeight), SceneTitle.Level);
            FPSCounterComponent fps = new FPSCounterComponent(this, spriteBatch, baseFont);

            Components.Add(SceneManager);
            Components.Add(fps);
        }
Beispiel #5
0
        public GameCore(int width = 0, int height = 0, bool debugActive = false, bool disabledExit = false)
        {
            _width        = width;
            _height       = height;
            DebugActive   = debugActive;
            _disabledExit = disabledExit;

            _graphics             = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";

            if (DebugActive)
            {
                _fpsCounterComponent = new FPSCounterComponent(this);
                Components.Add(_fpsCounterComponent);
                Components.Add(new DebugComponent(this));
            }
        }
Beispiel #6
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // TODO: use this.Content to load your game content here
            #region FPS
            spriteFont = Content.Load <SpriteFont>("FPS");
            fps        = new FPSCounterComponent(this, spriteBatch, spriteFont);
            Components.Add(fps);
            #endregion

            GlobalValues.InitializeGlobalValues(new PrimitiveBatch(GraphicsDevice), new Vector2(this.GraphicsDevice.Viewport.Width / 2, this.GraphicsDevice.Viewport.Height / 2));

            #region Sounds
            List <SoundEffect> landerSounds = new List <SoundEffect>();
            landerSounds.Add(Content.Load <SoundEffect>("Explosion"));
            landerSounds.Add(Content.Load <SoundEffect>("RocketBooster"));
            landerSounds.Add(Content.Load <SoundEffect>("Landing"));
            Sound.SetSounds(landerSounds);
            #endregion
        }
Beispiel #7
0
        public UnknownProjectGame(Camera cam, GraphicConfiguration graficConf, ComponentCollection collection, FPSCounterComponent fpsComponent, DesertMapComponent map)
        {
            this.collection = collection;
            this.graficConf = graficConf;
            graphics        = new GraphicsDeviceManager(this);
            this.graphics.PreferredBackBufferWidth  = 1280;
            this.graphics.PreferredBackBufferHeight = 720;

            IsFixedTimeStep = false;
            graphics.SynchronizeWithVerticalRetrace = false;
            Content.RootDirectory = "Content";
            collection.Add(fpsComponent);
            collection.Add(map);
            this.cam = cam;
        }