Esempio n. 1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(new Color(0.2f, 0.2f, 0.1f, 1.0f));
            MFLayer.OnLayerDraw();
            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }
Esempio n. 2
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);
            Env.OnInit(Content, spriteBatch, graphics);
            MFScene.CreateScene <MFMainGameScene>();
            MFScene.GetScene <MFMainGameScene>().Init();
            MFLayer.OnInit();
            MFMainGameControl.getInst.Init();

            // TODO: use this.Content to load your game content here
        }
Esempio n. 3
0
 private void OnEntityDestroyed(object sender, EntityArgs args)
 {
     if (entitySpriteDict.ContainsKey(args.entity))
     {
         MFSprite        sp    = entitySpriteDict[args.entity];
         MFMainGameLayer layer = MFLayer.GetLayer <MFMainGameLayer>();
         if (layer != null)
         {
             layer.RemoveSprite(sp);
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            if (Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }
            Env.OnPreUpdate(gameTime);

            MFScene.GetScene <MFMainGameScene>().Update();
            MFMainGameControl.getInst.Update();
            MFLayer.OnLayerUpdate();

            Env.OnPostUpdate();
            base.Update(gameTime);
        }
Esempio n. 5
0
        private void OnGameState(object sender, GameStateEventArgs args)
        {
            MFGUILayer guiLayer = MFLayer.GetLayer <MFGUILayer>();

            if (guiLayer != null)
            {
                if (args.state == MainGameState.GameOver)
                {
                    guiLayer.Show();
                }
                else if (args.state == MainGameState.Running)
                {
                    guiLayer.Hide();
                }
            }
        }
Esempio n. 6
0
        private void OnEntitySpawned(object sender, EntityArgs args)
        {
            MFQuadSprite    sp    = new MFQuadSprite();
            MFMainGameLayer layer = MFLayer.GetLayer <MFMainGameLayer>();

            if (args.entity is MFBullet)
            {
                sp.texName = "bullet";
            }
            else
            {
                sp.texName = "ship";
            }
            if (layer != null)
            {
                layer.AddSprite(sp);
            }
            this.entitySpriteDict[args.entity] = sp;
        }