Inheritance: MonoBehaviour
Esempio n. 1
0
        public void CreateMap(ViewEntity entity, IRenderState renderState, int index, Dictionary <Enums.EntityType, Matrix4x4[]> transforms, Dictionary <Enums.EntityType, int> instanceCounts, Dictionary <Enums.EntityType, ITexture2D> textures, Dictionary <Enums.EntityType, ITexture2D> normalMaps, Dictionary <Enums.EntityType, ITexture2D> heightMaps, Dictionary <Enums.EntityType, Vector4> intensityMap, List <Enums.EntityType> disableBackFaceCulling, List <LightSource> lightSources, ITransformation camera, float time)
        {
            _entity = entity;
            _camera = camera;

            Vector3 position = new Vector3(entity.Transform.M41, entity.Transform.M42,
                                           entity.Transform.M43);

            transforms[entity.Type][index] = transforms[entity.Type][transforms[entity.Type].Length - 1];
            instanceCounts[entity.Type]--;

            _deferred.UpdateTransforms(transforms);

            for (int i = 0; i < 6; i++)
            {
                _positions[i].Location = position;
                _deferred.Draw(renderState, _cameras[i], instanceCounts, textures, normalMaps, heightMaps, intensityMap, disableBackFaceCulling, time);
                _shadowMapping.Draw(renderState, _cameras[i], instanceCounts, _deferred.Depth, lightSources[0].Direction, disableBackFaceCulling, _deferred.Position, _deferred.Normal);
                _lighting.Draw(_cameras[i], _deferred.Color, _deferred.Normal, _deferred.Position, _shadowMapping.Output, _deferred.IntensityMap, lightSources);
                _lighting.Draw(_cameras[i], _deferred.Color, _deferred.Normal, _deferred.Position, _shadowMapping.Output, _deferred.IntensityMap, lightSources);
                _skybox.Draw(_cameras[i], 2);
                _add.Draw(_skybox.Output, _lighting.Output);

                _mapSurfaces[i].Activate();
                TextureDrawer.Draw(_add.Output);
                _mapSurfaces[i].Deactivate();
            }

            transforms[entity.Type][index] = entity.Transform;
            instanceCounts[entity.Type]++;

            for (int i = 0; i < 6; i++)
            {
                _bloom[i].Draw(_mapSurfaces[i].Texture);
            }

            _cubeFbo.Activate();
            for (int i = 0; i < 6; i++)
            {
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.TextureCubeMapPositiveX + i, _cubeFbo.Texture.ID, 0);
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                TextureDrawer.Draw(_bloom[i].Output);
            }
            _cubeFbo.Deactivate();

            _cubeFbo.Texture.Activate();
            GL.GenerateMipmap(GenerateMipmapTarget.TextureCubeMap);
            _cubeFbo.Texture.Deactivate();
        }
Esempio n. 2
0
        private void CreateMap(IReadOnlyList <ITexture2D> textures)
        {
            _cubeFbo.Activate();
            for (int i = 0; i < 6; i++)
            {
                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.TextureCubeMapPositiveX + i, _cubeFbo.Texture.ID, 0);
                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                TextureDrawer.Draw(textures[i]);
            }
            _cubeFbo.Deactivate();

            _cubeFbo.Texture.Activate();
            GL.GenerateMipmap(GenerateMipmapTarget.TextureCubeMap);
            _cubeFbo.Texture.Deactivate();
        }
Esempio n. 3
0
        public void Render(List <ViewEntity> entities, float time, ITransformation camera)
        {
            UpdateInstancing(entities);

            var arrTrans = new Dictionary <Enums.EntityType, Matrix4x4[]>();

            foreach (var transform in _transforms)
            {
                arrTrans.Add(transform.Key, transform.Value.ToArray());
            }

            _renderInstanceGroup.UpdateGeometry(arrTrans);

            _deferred.Draw(_renderState, camera, _instanceCounts, _textures, _normalMaps, _heightMaps, _intensities, _disableBackFaceCulling, time);

            _directShadowMap.Draw(_renderState, camera, _instanceCounts, _deferred.Depth, _lights[0].Direction, _disableBackFaceCulling, _deferred.Position, _deferred.Normal);
            _blurredShadowMap.Draw(_directShadowMap.Output);

            _environmentMap.CreateMap(entities[2], _renderState, 0, arrTrans, _instanceCounts, _textures, _normalMaps, _heightMaps, _intensities, _disableBackFaceCulling, _lights, camera, time);
            _environmentMap.Draw(_renderState, _deferred.Depth);
            _addEnvMap.Draw(_deferred.Color, _environmentMap.Output, 0.5f);

            _lighting.Draw(camera, _addEnvMap.Output, _deferred.Normal, _deferred.Position, _blurredShadowMap.Output, _deferred.IntensityMap, _lights);

            //_addProjectileColor.Draw(_deferred.ProjectileDepth, _deferred.Depth, _deferred.ProjectileColor, _lighting.Output, _deferred.ProjectileColor, _lighting.Output, _deferred.ProjectileColor, _lighting.Output, _deferred.ProjectileColor, _lighting.Output);

            _sphereCut.Draw(camera, _lighting.Output, _deferred.Depth);

            _skybox.Draw(camera);
            _addSkybox.Draw(_skybox.Output, _sphereCut.Output);

            if (Bloom)
            {
                _bloom.Draw(_addSkybox.Output);
                _ssaoWithBlur.Draw(_deferred.Depth, _bloom.Output);
            }
            else
            {
                _ssaoWithBlur.Draw(_deferred.Depth, _addSkybox.Output);
            }


            TextureDrawer.Draw(_ssaoWithBlur.Output);
        }
Esempio n. 4
0
        } //check whatever is plugged in to create input settings

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            ElementCollection.ReadDocument(XDocument.Load("Content/Xml/Registry.xml"));
            SpriteSheetCollection.LoadFromElementCollection(Content);

            cursorTex = SpriteSheetCollection.GetTex("static", "PlaceholderSheet", "cursor");
            icons     = SpriteSheetCollection.GetTex("idle", "buttons", "question");
            meterTex  = new TextureDrawer(Content.Load <Texture2D>("Placeholder/meter"));
            cloudTex  = new TextureDrawer(Content.Load <Texture2D>("Sprites/clouds"));

            dd = TextureDrawer.FromHorizontalStrip(Content.Load <Texture2D>("Placeholder/Daytime"), 39);
            mm = TextureDrawer.FromHorizontalStrip(Content.Load <Texture2D>("Placeholder/MM"), 39);

            LoadBGs();
            CreateUI();

            SoundManager.AddSong(Content.Load <Song>("Audio/PrototypeMusic3"), "game");
            //SoundManager.AddSong(Content.Load<Song>("Audio/tinymusic"), "game");
            SoundManager.AddSong(Content.Load <Song>("Audio/MenuTrack"), "main");


            SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/build"), "build");
            SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/church_victory"), "win");
            SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/loss"), "lose");
            SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/sacrifice"), "sacrifice");
            SoundManager.AddEffect(Content.Load <SoundEffect>("Audio/delevel"), "destroy");

            gameBg      = SpriteSheetCollection.GetTex("bg", "gameBgs", "bg");
            clouds      = SpriteSheetCollection.GetTex("clouds", "gameBgs", "bg");
            mountains   = SpriteSheetCollection.GetTex("fg", "gameBgs", "bg");
            aendingAnim = SpriteSheetCollection.GetTex("bg", "endingSheet", "bg");
            gded        = SpriteSheetCollection.GetTex("bg", "churchEndingSheet", "bg");

            SoundManager.PlaySong("main");

            ParticleSystem.AcquireTxture(SpriteSheetCollection.GetTex("smoke", "smoke", "smoke"));

            CreateNewGame();
        }
Esempio n. 5
0
        public override void LoadContent()
        {
            base.LoadContent();

            Sprite buttonSprite = Resources.GetSprite("button_idle");

            Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, Resources.GetSprite("button_over"), Resources.GetSprite("button_pressed") };
            font  = Manager.Game.Content.Load <SpriteFont>("Fonts/Hud");
            panel = new Panel(this, new Rectangle(0, 0, Manager.Width, Manager.Height), buttonSprite);

            listControl = new SearchableList(this, new Rectangle(0, 0, 300, 400), buttonSprite, buttonSpriteTab, font)
            {
                Pading = 5
            };
            panel.AddControl("listControl", listControl);
            UpdateDatas();

            submitButton = new Button(this, new Rectangle(0, 405, 100, 20), buttonSpriteTab)
            {
                Text = "Submit"
            };
            panel.AddControl("submitButton", submitButton);
            addButton = new Button(this, new Rectangle(120, 405, 100, 20), buttonSpriteTab)
            {
                Text = "Add"
            };
            panel.AddControl("addButton", addButton);
            removeButton = new Button(this, new Rectangle(240, 405, 100, 20), buttonSpriteTab)
            {
                Text = "Remove"
            };
            panel.AddControl("removeButton", removeButton);
            textureDrawer = new TextureDrawer(this, new Rectangle(305, 0, 200, 200), null);
            panel.AddControl("textureDrawer", textureDrawer);
            panel.Pading = 10;

            Resize(Manager.Game.Viewport.Width, Manager.Game.Viewport.Height);
        }
Esempio n. 6
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //LOAD XML
            ElementCollection.ReadDocument(XDocument.Load("Content/XML/Items.xml"));
            ElementCollection.ReadDocument(XDocument.Load("Content/XML/MiscEntities.xml"));
            ElementCollection.ReadDocument(XDocument.Load("Content/XML/Pickups.xml"));
            ElementCollection.ReadDocument(XDocument.Load("Content/XML/Spritesheets.xml"));

            SpriteSheetCollection.ReadDocument(XDocument.Load("Content/XML/Spritesheets.xml"), Content);

            SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit1"), "hit1");
            SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit2"), "hit2");
            SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit3"), "hit3");
            SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit4"), "hit4");
            SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit5"), "hit5");
            SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit6"), "hit6");
            SoundManager.AddEffect(Content.Load <SoundEffect>("SFX/hit7"), "hit7");

            SoundManager.AddSong(Content.Load <Song>("Music/dungeonrun"), "gamesong");
            SoundManager.AddSong(Content.Load <Song>("Music/menusong"), "menusong");
            SoundManager.PlaySong("menusong");

            RecipeBook.ReadDocument(XDocument.Load("Content/XML/Recipes.xml"));
            //LOAD TEXTURES
            ParticleSystem.AcquireTxture(SpriteSheetCollection.GetTex("appear", "slotappears", "slot"));
            ParticleSystem.AcquireTxture(SpriteSheetCollection.GetTex("stars", "miscsheet1", "particle"));
            scoretex = SpriteSheetCollection.GetTex("score", "score", "button");
            //LOAD SOUND

            //LOAD ENTITIES

            //LOAD UR MOM
            SetupUISystems();

            //END - SETUP THE GAME!
            SetupGame();
        }
Esempio n. 7
0
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Button button = new Button("goToGame", new Rectangle(119, 196, 162, 48), new TextureDrawer(Content.Load <Texture2D>("button")));

            UIs = new UISystem[] { new UISystem(new List <Button>(1)
                {
                    button
                }, "Menu"), new UISystem(SetupGameButtons(), "Game") };
            currentUI = UIs[0];
            //LOAD ALL XML
            ElementCollection.ReadDocument(XDocument.Load("Content/Entities.xml"));
            ElementCollection.ReadDocument(XDocument.Load("Content/TurretSheet.xml"));
            XElement e = ElementCollection.GetSpritesheetRef("turrets");

            SpriteSheetCollection.LoadSheet(ElementCollection.GetSpritesheetRef("turrets"), Content);

            FontDrawer drawer = new FontDrawer();

            TextureDrawer[] letters = GetLettersFromSource();
            drawer.fonts.Add(new DrawerCollection(letters, "aaa"));
            handler = new TextHandler(drawer, virtualDims);

            SoundManager.AddEffect(Content.Load <SoundEffect>("classic_hurt"), "shoot");
            SoundManager.AddSong(Content.Load <Song>("ld41tracktest2"), "song");

            ChangeToQueue(0);

            //LOAD MAP AND ENTS
            gameMap = new Map(
                new Vector2[] {
                new Vector2(150, 0),
                new Vector2(153, 142),
                new Vector2(222, 142),
                new Vector2(222, 190),
                new Vector2(108, 190),
                new Vector2(108, 104),
                new Vector2(-30, 104)
            },
                new TextureDrawer(Content.Load <Texture2D>("envtest3")),
                new FRectangle[] {
                new FRectangle(0, 0, 141, 81),
                new FRectangle(119, 82, 26, 58),
                new FRectangle(135, 144, 78, 23),
                new FRectangle(162, 0, 79, 123),
                new FRectangle(230, 123, 9, 67),
                new FRectangle(102, 191, 138, 49),
                new FRectangle(0, 104, 100, 138)
            });

            availableTurrets = new List <Entity>();
            availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("machinegun 1"), new Vector2(24, 16), Content, ebuilder, false));
            availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("sniper 1"), new Vector2(24, 16), Content, ebuilder, false));
            availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("artillery 1"), new Vector2(24, 16), Content, ebuilder, false));
            availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("ring"), new Vector2(24, 16), Content, ebuilder, false));

            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("machinegun 2"), new Vector2(24, 16), Content, ebuilder, false));
            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("sniper 2"), new Vector2(24, 16), Content, ebuilder, false));
            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("artillery 2"), new Vector2(24, 16), Content, ebuilder, false));

            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("machinegun 3"), new Vector2(24, 16), Content, ebuilder, false));
            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("sniper 3"), new Vector2(24, 16), Content, ebuilder, false));
            //availableTurrets.Add(Assembler.GetEnt(ElementCollection.GetEntRef("artillery 3"), new Vector2(24, 16), Content, ebuilder, false));
            status = new TextureDrawer(Content.Load <Texture2D>("statusbar"));

            cursor        = new TextureDrawer(Content.Load <Texture2D>("cursor"), new TextureFrame(new Rectangle(0, 0, 8, 8), new Point(4, 4)));
            transitiontex = new TextureDrawer(Content.Load <Texture2D>("loading"));
            menutex       = new TextureDrawer(Content.Load <Texture2D>("start"));
            dedtex        = new TextureDrawer(Content.Load <Texture2D>("gameover"));
            textframe     = new TextureDrawer(Content.Load <Texture2D>("ui2"));
            loader        = new TextureDrawer(Content.Load <Texture2D>("loadanim"), new TextureFrame[] {
                new TextureFrame(new Rectangle(0, 0, 162, 48), Point.Zero),
                new TextureFrame(new Rectangle(0, 48, 162, 48), Point.Zero),
                new TextureFrame(new Rectangle(0, 96, 162, 48), Point.Zero),
                new TextureFrame(new Rectangle(0, 144, 162, 48), Point.Zero)
            });
        }
Esempio n. 8
0
 /// <summary>
 /// Resize the stack in a non-destructive way
 /// </summary>
 /// <param name="newSize">The new size of the stack</param>
 public void resize(int newSize)
 {
     if (newSize > size_)
     {
         int nextSize = (newSize > size_ * 2) ? newSize : size_ * 2;
         TextureDrawer[] tempStack = new TextureDrawer[nextSize];
         for (int i = 0; i <= top_; i++)
         {
             tempStack[i] = stack_[i];
         }
         stack_ = tempStack;
         size_ = nextSize;
         initializeStack();
     }
 }
Esempio n. 9
0
 protected void initializeStack()
 {
     for (int i = top_ + 1; i < size_; i++)
     {
         stack_[i] = new TextureDrawer();
     }
 }
Esempio n. 10
0
        public void DrawTexture(int id, int time, float x, float y, float width, float height, float rotation, float rotationCenterX, float rotationCenterY)
        {
            TextureDrawer drawer = new TextureDrawer(id, time, x, y, width, height, rotation, rotationCenterX, rotationCenterY);

            Game.RawFrameRender += drawer.Draw;
        }
Esempio n. 11
0
 public Event(string text_, string[] outcomeIfYes_, string[] outcomeIfNo_, string[] outcomeIfIgnored_, int scrollSpeed_, TextureDrawer tex_ = null)
 {
     text             = text_;
     outcomeIfYes     = outcomeIfYes_;
     outcomeIfNo      = outcomeIfNo_;
     outcomeIfIgnored = outcomeIfIgnored_;
     scrollSpeed      = scrollSpeed_;
     tex = tex_;
 }
Esempio n. 12
0
        public override void LoadContent()
        {
            base.LoadContent();

            Sprite buttonSprite = Resources.GetSprite("button_idle");

            Sprite[] buttonSpriteTab = new Sprite[] { buttonSprite, Resources.GetSprite("button_over"), Resources.GetSprite("button_pressed") };
            font  = Manager.Game.Content.Load <SpriteFont>("Fonts/Hud");
            panel = new Panel(this, new Rectangle(0, 0, Manager.Width, Manager.Height), buttonSprite);

            spriteLib = new SearchableList(this, new Rectangle(0, 0, 200, 400), buttonSprite, buttonSpriteTab, font)
            {
                Pading = 5
            };
            panel.AddControl("spriteLib", spriteLib);
            foreach (KeyValuePair <string, Sprite> pair in Resources.Sprites)
            {
                spriteLib.AddToList(pair.Key);
            }

            spriteSelected = new SearchableList(this, new Rectangle(400, 0, 200, 300), buttonSprite, buttonSpriteTab, font)
            {
                Pading = 5
            };
            panel.AddControl("spriteSelected", spriteSelected);

            textureDrawerLib = new TextureDrawer(this, new Rectangle(200, 0, 200, 200), null);
            panel.AddControl("textureDrawerLib", textureDrawerLib);

            textureDrawerSelected = new TextureDrawer(this, new Rectangle(600, 0, 200, 200), null);
            panel.AddControl("textureDrawerSelected", textureDrawerSelected);

            submitButton = new Button(this, new Rectangle(0, 410, 100, 20), buttonSpriteTab)
            {
                Text = "Submit"
            };
            panel.AddControl("submitButton", submitButton);

            addAnimationButton = new Button(this, new Rectangle(350, 410, 100, 20), buttonSpriteTab)
            {
                Text = "Add Animation"
            };
            panel.AddControl("addSpriteButton", addAnimationButton);

            toLeftButton = new Button(this, new Rectangle(285, 255, 30, 30), buttonSpriteTab)
            {
                Text = " <-"
            };
            panel.AddControl("toLeftButton", toLeftButton);

            toRightButton = new Button(this, new Rectangle(285, 220, 30, 30), buttonSpriteTab)
            {
                Text = " ->"
            };
            panel.AddControl("toRightButton", toRightButton);

            toUpButton = new Button(this, new Rectangle(340, 220, 30, 30), buttonSpriteTab)
            {
                Text = "Up"
            };
            panel.AddControl("toUpButton", toUpButton);

            toDownButton = new Button(this, new Rectangle(340, 255, 30, 30), buttonSpriteTab)
            {
                Text = "Down"
            };
            panel.AddControl("toDownButton", toDownButton);

            frameTimeLabel = new TextBlock(this, new Vector2(400, 305), "FrameTime :");
            panel.AddControl("frameTimeLabel", frameTimeLabel);

            frameTimeTextBox = new TextBox(this, new Rectangle(520, 305, 80, 20), buttonSpriteTab);
            panel.AddControl("frameTimeText", frameTimeTextBox);

            panel.AddControl("effectButtonLabel", new TextBlock(this, new Vector2(400, 325), "Effect :"));
            effectButton = new ListButton(this, new Rectangle(470, 325, 130, 20), buttonSprite, new List <string>()
            {
                "None", "FlipVertically", "FlipHorizontally", "FlipBoth"
            });
            panel.AddControl("effectButton", effectButton);

            addSpriteText = new TextBox(this, new Rectangle(210, 410, 140, 20), buttonSpriteTab);
            panel.AddControl("addSpriteText", addSpriteText);

            panel.Pading = 10;
            Resize(Manager.Game.Viewport.Width, Manager.Game.Viewport.Height);
        }
Esempio n. 13
0
 public Map(Vector2[] points_, TextureDrawer ground_, FRectangle[] buildableAreas_)
 {
     points         = points_;
     ground         = ground_;
     buildableAreas = buildableAreas_;
 }