예제 #1
0
        /// <summary>
        /// Creates a Screenlet, which is an Entity that contains a screenComp (RenderBuffer) to
        /// which graphics can be rendered.
        /// </summary>
        /// <returns></returns>
        public static Entity CreateScreenlet(EntityWorld world, int width, int height)
        {
            var sc = new ScreenComp(true, width, height);
            var e  = world.CreateEntity();

            e.AddComponent(sc);
            e.AddComponent(new DrawComp());
            e.Refresh();
            return(e);
        }
예제 #2
0
 protected override void Draw(GameTime gameTime)
 {
     // loop all active channels and draw them.
     foreach (Channel c in ChannelMgr.Channels)
     {
         if (!c.IsActive || !c.IsVisible)
         {
             continue;
         }
         DrawScreen = c.Screen.GetComponent <ScreenComp>();
         c.World.Draw();
     }
     base.Draw(gameTime);
 }
예제 #3
0
 /// <summary>
 /// create new spritelet that renders the contents of a screenlet
 /// </summary>
 /// <param name="screen">the screenlet to render as a sprite</param>
 public SpriteComp(ScreenComp screen)
 {
     this.screen = screen;
     this.texture = screen.RenderTarget;
     InitTextures();
 }
예제 #4
0
        protected override void Initialize()
        {
            // make root world and build to it
            RootWorld = new EntityWorld();
            RootWorld.InitializeAll(true);
            TTFactory.BuildTo(RootWorld);

            // make root screen and build to it
            RootScreen = new ScreenComp(false, 0, 0);
            TTFactory.BuildTo(RootScreen);

            // make the MainChannel and build to it
            MainChannel = TTFactory.CreateChannel(Color.CornflowerBlue);
            MainChannelScreen = MainChannel.GetComponent<WorldComp>().Screen;
            TTFactory.BuildTo(MainChannel);

            // the TTMusicEngine
            if (IsAudio)
            {
                AudioEngine = MusicEngine.GetInstance();
                AudioEngine.AudioPath = "Content";
                if (!AudioEngine.Initialize())
                    throw new Exception(AudioEngine.StatusMsg);
            }

            base.Initialize();
        }
예제 #5
0
 /// <summary>
 /// Create new DrawComp
 /// </summary>
 /// <param name="drawScreen">ScreenComp that the Entity will be drawn to, or null to use the channel's
 /// default.</param>
 public DrawComp(ScreenComp drawScreen = null)
 {
     this.DrawScreen = drawScreen;
 }
예제 #6
0
 /// <summary>
 /// Create a Spritelet with texture based on the contents of a Screen
 /// </summary>
 /// <returns></returns>
 public static Entity CreateSpritelet(ScreenComp screen)
 {
     Entity e = CreateDrawlet();
     var spriteComp = new SpriteComp(screen);
     e.AddComponent(spriteComp);
     e.Refresh();
     return e;
 }
예제 #7
0
 /// <summary>
 /// Creates a Screenlet, an Entity that has a ScreenComp to 
 /// which graphics can be rendered. 
 /// </summary>
 /// <param name="backgroundColor">Background color of the Screenlet</param>
 /// <param name="hasRenderBuffer">if true, Screenlet will have its own render buffer</param>
 /// <param name="height">Screenlet height, if not given uses default backbuffer height</param>
 /// <param name="width">Screenlet width, if not given uses default backbuffer width</param>
 /// <returns>Newly created Entity with a ScreenComp.</returns>
 public static Entity CreateScreenlet(Color backgroundColor, bool hasRenderBuffer = false,
                                 int width = 0, int height = 0)
 {
     var sc = new ScreenComp(hasRenderBuffer, width, height);
     sc.BackgroundColor = backgroundColor;
     var e = CreateEntity();
     e.AddComponent(sc);
     e.AddComponent(new DrawComp(BuildScreen));
     e.Refresh();
     return e;
 }
예제 #8
0
        /// <summary>
        /// Creates an FX Screenlet that renders a layer with shader Effect to the current active BuildScreen
        /// </summary>
        /// <returns></returns>
        public static Entity CreateFxScreenlet(String effectFile)
        {
            var fx = _game.Content.Load<Effect>(effectFile);
            var sc = new ScreenComp(BuildScreen.RenderTarget); // renders to the existing screen buffer
            sc.SpriteBatch.effect = fx; // set the effect in SprBatch

            var e = CreateEntity();
            e.AddComponent(sc);
            //e.AddComponent(new DrawComp(sc));
            e.Refresh();
            return e;
        }
예제 #9
0
        /// <summary>
        /// Creates a new Channel, which is an Entity with inside it a separate EntityWorld containing a dedicated ScreenComp to
        /// which that World renders, which can be then shown as a sprite. Parameters are same as for CreateScreenlet() above.
        /// In summary: A World inside a Sprite.
        /// </summary>
        /// <param name="backgroundColor"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        public static Entity CreateChannel(Color backgroundColor,
                                        int width = 0, int height = 0)
        {
            var wc = new WorldComp(); // create world

            // create a screenlet Entity within the Channel's (sub) world
            Entity screenlet = wc.World.CreateEntity();
            var sc = new ScreenComp (true, width, height);
            wc.Screen = sc;				// store the Screen as part of the World
            sc.BackgroundColor = backgroundColor;
            screenlet.AddComponent (sc);
            screenlet.Refresh ();

            // create the channel Entity, based on Spritelet
            var e = CreateSpritelet(sc);

            // make this spritelet into a Channel by adding the World
            e.AddComponent(wc);
            e.Refresh();
            return e;
        }
예제 #10
0
 /// <summary>
 /// Switch factory's building output to given Channel, World or Screen
 /// </summary>
 /// <param name="e">an Entity which may contain a WorldComp, a ScreenComp, or both. In case of both,
 /// the Entity is a Channel.</param>
 public static void BuildTo(Entity e)
 {
     if (e.HasComponent<WorldComp>())
     {
         var wc = e.GetComponent<WorldComp>();
         BuildWorld = wc.World;
         if (wc.Screen != null)
             BuildScreen = wc.Screen;
     }
     if (e.HasComponent<ScreenComp>())
         BuildScreen = e.GetComponent<ScreenComp>();
 }
예제 #11
0
 public static void BuildTo(ScreenComp screen)
 {
     BuildScreen = screen;
 }
예제 #12
0
 public Channel(EntityWorld world, ScreenComp screen)
 {
     this.World = world;
     this.Screen = screen;
 }