Exemple #1
0
        protected override void DrawCore(RenderContext context, RenderItemCollection renderItems, int fromIndex, int toIndex)
        {
            var graphicsDevice = context.GraphicsDevice;
            var destination    = new RectangleF(0, 0, 1, 1);

            // find the last background to display with valid texture
            BackgroundComponent background = null;

            for (var i = toIndex; i >= fromIndex; --i)
            {
                background = (BackgroundComponent)renderItems[i].DrawContext;
                if (background.Texture != null)
                {
                    break;
                }
            }

            // Abort if not valid background component
            if (background == null || background.Texture == null)
            {
                return;
            }

            var texture             = background.Texture;
            var target              = CurrentRenderFrame;
            var imageBufferMinRatio = Math.Min(texture.ViewWidth / (float)target.Width, texture.ViewHeight / (float)target.Height);
            var sourceSize          = new Vector2(target.Width * imageBufferMinRatio, target.Height * imageBufferMinRatio);
            var source              = new RectangleF((texture.ViewWidth - sourceSize.X) / 2, (texture.ViewHeight - sourceSize.Y) / 2, sourceSize.X, sourceSize.Y);

            spriteBatch.Parameters.Add(BackgroundEffectKeys.Intensity, background.Intensity);
            spriteBatch.Begin(SpriteSortMode.FrontToBack, graphicsDevice.BlendStates.Opaque, graphicsDevice.SamplerStates.LinearClamp, graphicsDevice.DepthStencilStates.None, null, backgroundEffect);
            spriteBatch.Draw(texture, destination, source, Color.White, 0, Vector2.Zero);
            spriteBatch.End();
        }
        void GenerateComponents(int entityId, Dictionary <string, string> allParameters, List <Trait> allTraits)
        {
            if (allParameters.ContainsKey("BackgroundComponent"))
            {
                var component = new BackgroundComponent(entityId, allParameters);
                AddComponent(entityId, component);
            }

            if (allParameters.ContainsKey("ForegroundComponent"))
            {
                var component = new ForegroundComponent(entityId, allParameters);
                AddComponent(entityId, component);
            }

            if (allParameters.ContainsKey("MapComponent"))
            {
                var component = new MapComponent(entityId, allParameters);
                AddComponent(entityId, component);
            }

            if (allParameters.ContainsKey("PositionComponent"))
            {
                var component = new PositionComponent(entityId, allParameters);
                AddComponent(entityId, component);
            }

            // TODO: Setup all the components here.

            foreach (Trait trait in allTraits)
            {
                AddTrait(entityId, trait);
            }
        }
Exemple #3
0
        // Create all the components that should be used by this game
        private void CreateComponents()
        {
            _menuComponent = new MenuComponent(this);
            Components.Add(_menuComponent);

            _backgroundComponent = new BackgroundComponent(this);
            Components.Add(_backgroundComponent);

            _actorComponent = new ActorComponent(this);
            Components.Add(_actorComponent);

            _collisionComponent = new CollisionComponent(this);
            Components.Add(_collisionComponent);

            _scoreComponent = new ScoreComponent(this);
            Components.Add(_scoreComponent);

            _timeComponent = new TimeComponent(this);
            Components.Add(_timeComponent);

            _speedComponent = new SpeedComponent(this);
            Components.Add(_speedComponent);

            _statusComponent = new StatusComponent(this);
            Components.Add(_statusComponent);
        }
Exemple #4
0
        public override Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent)
        {
            var name      = ComputeNewName(parent, "Background");
            var component = new BackgroundComponent();

            return(CreateEntityWithComponent(name, component));
        }
        public void setBackground(string asset, ITransition intro, ITransition revert, ITransition select, ITransition exit)
        {
            BackgroundComponent background = new BackgroundComponent(asset);

            background.setTransitions(intro, revert, select, exit);

            addComponent(background);
        }
Exemple #6
0
            /// <summary>
            /// are you sure you want to construct your own BackgroundManager? You may want to use
            /// SceneManager.GetInstance().GetBackgroundManager() instead
            /// </summary>
            /// <param name="backgroundComponent">a background component which houses the relevent UI elements</param>
            public BackgroundManager(BackgroundComponent backgroundComponent)
            {
                m_backgroundComponent = backgroundComponent;

                // assign references to the relevant UI elements
                m_imageBackground  = backgroundComponent.GetImageBackground();
                m_colourBackground = backgroundComponent.GetColourBackground();
            }
Exemple #7
0
        private void setBackground()
        {
            BackgroundComponent background = new BackgroundComponent("Menus/Standard Menu");

            background.setTransitions(new FadeComponent(15, 1), new FadeComponent(15, -1));

            addComponent(background);
        }
 void Awake()
 {
     _skyBackground    = transform.Find("SkyBackground").GetComponent <BackgroundComponent>();
     _grassBackground  = transform.Find("GrassBackground").GetComponent <BackgroundComponent>();
     _columnController = transform.Find("ColumnController").GetComponent <ColumnController>();
     _birdController   = transform.Find("BirdController").GetComponent <BirdController>();
     _loseText         = transform.Find("LoseText").GetComponent <Text>();
     _playText         = transform.Find("PlayText").GetComponent <Text>();
     _scoreText        = transform.Find("ScoreText").GetComponent <Text>();
 }
Exemple #9
0
        public int CreateEntity(string entityName, Dictionary <string, string> otherParameters)
        {
            var newEntityId = GetNewEntityId();
            Dictionary <string, string> allParameters;
            List <Trait> allTraits;

            if (otherParameters.ContainsKey("Material"))
            {
                allParameters = CombineParameterDictionaries(otherParameters,
                                                             ECSDatabase.GetComponentData(entityName, otherParameters["Material"]));
                allTraits = ECSDatabase.GetTraitData(entityName, otherParameters["Material"]);
            }
            else
            {
                allParameters = CombineParameterDictionaries(otherParameters,
                                                             ECSDatabase.GetComponentData(entityName));
                allTraits = ECSDatabase.GetTraitData(entityName);
            }

            if (allParameters.ContainsKey("BackgroundComponent"))
            {
                var component = new BackgroundComponent(newEntityId, allParameters);
                AddComponent(newEntityId, component);
            }

            if (allParameters.ContainsKey("ForegroundComponent"))
            {
                var component = new ForegroundComponent(newEntityId, allParameters);
                AddComponent(newEntityId, component);
            }

            if (allParameters.ContainsKey("MapComponent"))
            {
                var component = new MapComponent(newEntityId, allParameters);
                AddComponent(newEntityId, component);
            }

            if (allParameters.ContainsKey("PositionComponent"))
            {
                var component = new PositionComponent(newEntityId, allParameters);
                AddComponent(newEntityId, component);
            }

            // TODO: Setup all the components here.

            foreach (Trait trait in allTraits)
            {
                AddTrait(newEntityId, trait);
            }

            GameEvents.CreateEntityEvent.NewCreateEntityEvent(newEntityId);

            return(newEntityId);
        }
Exemple #10
0
        private void setBackground()
        {
            BackgroundComponent background = new BackgroundComponent("Menus/Standard Menu");

            background.setTransitions(new FadeComponent(15, 1), new FadeComponent(15, -1));

            addComponent(background);

            GraphicComponent bar = new GraphicComponent("Media Player/Media Buttons Frame", new Rectangle(52, 240, 160, 35));

            bar.setTransitions(new MoveComponent(new Vector2(-200, 0), true, 15), new MoveComponent(new Vector2(200, 0), false, 15));
            addComponent(bar);
        }
        public CharacterCreationScreen(Game game)
            : base(game)
        {
            spriteBatch = (SpriteBatch)Game.Services.GetService(typeof(SpriteBatch));
            Content = (ContentManager)Game.Services.GetService(typeof(ContentManager));

            smallFont = Content.Load<SpriteFont>(@"font\Arial_10px");
            spriteFont = Content.Load<SpriteFont>(@"font\Arial_12px");

            keyboardiput = new KeyboardInput(game, spriteFont, new Vector2(580, 175));
            bgcomp[1] = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\background2"));
            bgcomp[2] = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\character_create"));
            bgcomp[3] = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\frame2"));

            Components.Add(bgcomp[1]);
            Components.Add(bgcomp[2]);
            Components.Add(bgcomp[3]);

            for (int i = 0; i <= properties.Length -1; i++)
            {
                properties[i] = new MenuComponent(game, Content.Load<SpriteFont>(@"font\Arial_12px"));
                properties[i].StartIndex = 0;
                properties[i].Position = new Vector2(180, 140 + (i * 24));
                properties[i].HiliteColor = Color.Black;
                properties[i].Shade = false;
                properties[i].DisplaySingle = true;
                properties[i].ListDown = false;
            }

            properties[0].SetMenuItems(item0);
            properties[1].SetMenuItems(item1);
            properties[2].SetMenuItems(item2);
            properties[3].SetMenuItems(item3);
            properties[4].SetMenuItems(item4);
            properties[5].SetMenuItems(item5);

            nameboard = Content.Load<Texture2D>(@"gfx\screens\screenobjects\character_nameboard");
            propertyboard = Content.Load<Texture2D>(@"gfx\screens\screenobjects\character_properties");

            // Create player info instance
            // newPlayer = new PlayerInfo();

            // Activate Text Input Class (for PlayerName)
            // keyboardiput.Activate(newPlayer.Name.ToString());

            // Set Phase to Name
            phase = Phase.Name;

            // player sprite
            playersprite = new PlayerSprite(352, 188);
        }
        public CharacterSelectionScreen(Game game)
            : base(game)
        {
            // select Resource services
            spriteBatch = ResourceManager.GetInstance.spriteBatch;
            Content = ResourceManager.GetInstance.Content;

            // select spritefont
            playerNameFont = Content.Load<SpriteFont>(@"font\Arial_12px");

            // define components
            bgcomp1 = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\background1"));
            bgcomp2 = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\character_selection"));
            bgcomp3 = new BackgroundComponent(game, Content.Load<Texture2D>(@"gfx\background\frame2"));
            menu = new MenuComponent(game, Content.Load<SpriteFont>(@"font\Comic_Sans_18px"));

            // add components
            Components.Add(bgcomp1);
            Components.Add(bgcomp2);
            Components.Add(bgcomp3);

            // menu options
            menu.SetMenuItems(menuItems);
            menu.StartIndex = 0;
            menu.Position = new Vector2(665, 230);
            menu.NormalColor = Color.White;
            menu.HiliteColor = Color.Red;
            menu.MenuItemSpace = 25;
            menu.Rotation[2] = 0.25f;
            menu.Offset[2] = new Vector2(0, -5);
            menu.Offset[3] = new Vector2(-8, 23);
            menu.Offset[4] = new Vector2(-526, -22);
            menu.EndIndex = 3;

            // player sprite
            playersprite = new PlayerSprite(100, 123);
            player = new PlayerInfo();
            playersprite.Player = this.player;

            // player offsets
            for (int i = 0; i < 6; i++)
                this.spriteOfset[i] = playersprite.getoffset(i);

            // options
            option_board = Content.Load<Texture2D>(@"gfx\screens\screenobjects\option_board");
            screen_board = Content.Load<Texture2D>(@"gfx\screens\screenobjects\next_board");

            // slots
            slot = Content.Load<Texture2D>(@"gfx\screens\screenobjects\empty_character_slot");
        }
Exemple #13
0
        private void setBackground()
        {
            InGameComponent inGameBackground = new InGameComponent();

            addComponent(inGameBackground);


            BackgroundComponent background = new BackgroundComponent("Menus/Game Over");

            background.Position = new Vector2(36, 50);

            background.setTransitions(new ScaleComponent(new FadeComponent(15, 1), new Vector2(100, 180), 0.75f, 15, true), new MoveComponent(new Vector2(-200, 0), true, 15),
                                      new ScaleComponent(new FadeComponent(15, -1), new Vector2(100, 180), -0.75f, 15, false), new MoveComponent(new Vector2(200, 0), false, 15));

            addComponent(background);
        }
Exemple #14
0
        private void setBackground()
        {
            InGameComponent inGameBackground = new InGameComponent();

            inGameBackground.setTransitions(new DimComponent(new Vector3(100), 20, -1), new FadeComponent(15, 1),
                                            new FadeComponent(15, -1), new DimComponent(new Vector3(100), 20, 1));

            addComponent(inGameBackground);


            BackgroundComponent background = new BackgroundComponent("Menus/Pause Menu");

            background.Position = new Vector2(52, 100);

            background.setTransitions(new MoveComponent(null, new Vector2(0, 340), true, 20), new MoveComponent(null, new Vector2(200, 0), true, 15),
                                      new MoveComponent(null, new Vector2(-200, 0), false, 15), new MoveComponent(null, new Vector2(0, -340), false, 20));

            addComponent(background);
        }
        public void TestBackgroundComponent()
        {
            var testComponent1 = new BackgroundComponent(0, "DarkBrown", "NightBrown", BackgroundDisplayLayer.Tile);

            Assert.AreEqual("DarkBrown", testComponent1.BackgroundColor);
            Assert.AreEqual("NightBrown", testComponent1.FogColor);
            Assert.AreEqual(BackgroundDisplayLayer.Tile, testComponent1.BackgroundDisplayLayer);

            var paramDict = new Dictionary <string, string> {
                { "EntityName", "TestEntity" },
                { "BackgroundColor", "DarkBrown" },
                { "FogColor", "NightBrown" },
                { "BackgroundDisplayLayer", "Tile" }
            };

            var testComponent2 = new BackgroundComponent(0, paramDict);

            Assert.AreEqual("DarkBrown", testComponent2.BackgroundColor);
            Assert.AreEqual("NightBrown", testComponent2.FogColor);
            Assert.AreEqual(BackgroundDisplayLayer.Tile, testComponent2.BackgroundDisplayLayer);
        }
    void Awake()
    {
        _sceneAudio        = transform.GetComponent <AudioSource>();
        _circusBackground  = transform.Find("CircusBackground").GetComponent <BackgroundComponent>();
        _barrierController = transform.Find("BarrierController").GetComponent <BarrierController>();
        _jokerController   = transform.Find("JokerController").GetComponent <JokerController>();
        _menuObject        = transform.Find("MenuPanel").gameObject;
        _muteObject        = transform.Find("MenuPanel/MuteButton").gameObject;
        _loseObject        = transform.Find("LosePanel").gameObject;
        _scoreText         = transform.Find("LosePanel/ScoreText").GetComponent <Text>();

        _isMute = PlayerPrefs.GetInt("Mute", 0) == 1;
        if (_isMute)
        {
            _muteObject.SetActive(false);
        }
        else
        {
            _sceneAudio.mute = false;
        }
    }
Exemple #17
0
        public override async Task <Entity> CreateEntity(EntityHierarchyItemViewModel parent)
        {
            var skybox = await PickupAsset(parent.Editor.Session, new[] { typeof(SkyboxAsset) });

            if (skybox == null)
            {
                return(null);
            }
            var skyboxAsset = (SkyboxAsset)skybox.Asset;

            var name           = ComputeNewName(parent, "Skybox light");
            var lightComponent = new LightComponent {
                Type = new LightSkybox {
                    Skybox = ContentReferenceHelper.CreateReference <Skybox>(skybox)
                }
            };
            var skyboxComponent = new BackgroundComponent {
                Texture = skyboxAsset.CubeMap
            };

            return(await CreateEntityWithComponent(name, lightComponent, skyboxComponent));
        }
Exemple #18
0
        private void setBackground()
        {
            BackgroundComponent background = new BackgroundComponent("Menus/Small Menu", new Vector2(25, 210), Color.White);

            TransitionWrapper transition;

            transition = new BaseTransition(15, TransitionState.intro);
            transition = new FloatBackground(transition, new Vector2(0, 15));
            transition = new FadeBackground(transition);
            transition.setTransition(background);
            background.Intro = transition;

            transition        = new BaseTransition(15, TransitionState.selected);
            transition        = new FloatBackground(transition, new Vector2(0, -15));
            transition        = new FadeBackground(transition);
            background.Select = transition;

            transition.State = TransitionState.exit;
            background.Exit  = transition;

            addComponent(background);
        }
Exemple #19
0
 public BackgroundManager(BackgroundComponent backgroundComponent)
 {
     m_backgroundComponent = backgroundComponent;
     m_imageBackground     = backgroundComponent.GetImageBackground();
     m_colourBackground    = backgroundComponent.GetColourBackground();
 }
Exemple #20
0
        private void setBackground()
        {
            BackgroundComponent background = new BackgroundComponent("Menus/Menu Background", new Vector2(), Color.White);

            addComponent(background);
        }
Exemple #21
0
 private static void LoadContent()
 {
     _titleScreenTexture    = Game.Instance.Content.Load <Texture2D>(@"Textures\menu_background");
     _titleScreenBackground = new BackgroundComponent(_titleScreenTexture);
 }