public void Update(ContentManager Content, Map map, Camera camera)
 {
     //Position = Viewportposition - (Position wenn am Ende am Maprand * Positionsfaktor abhängig von Viewportposition/letzte Mapposition)
     position.X = camera.viewport.X - ((size.X - camera.viewport.Width) * (camera.viewport.X / (map.size.X - camera.viewport.Width)));
     position.Y = camera.viewport.Y - ((size.Y - camera.viewport.Height) * (camera.viewport.Y / (map.size.Y - camera.viewport.Height))) + additionalHeight;
     //TextureManager(Content, camera);
 }
        public void Update(Map karte, GameTime gameTime, Camera camera)
        {
            luaTop = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "Top"]);
            luaBottom = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "Bottom"]);
            luaAmount = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "Amount"]);
            luaChaos = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "Chaos"]);
            luaType = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "Type"]);
            luaWind = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "Wind"]);
            luaSizeMin = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "SizeMin"]);
            luaSizeMax = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "SizeMax"]);
            size.X = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "Width"]);
            size.Y = Convert.ToInt32((double)Game1.luaInstance["cloudPlane" + number.ToString() + "Height"]);

            position.X = camera.viewport.X - ((size.X - camera.viewport.Width) * (camera.viewport.X / (karte.size.X - camera.viewport.Width)));
            position.Y = camera.viewport.Y - ((size.Y - camera.viewport.Height) * (camera.viewport.Y / (karte.size.Y - camera.viewport.Height)));

            //Spawntimer
            if (Game1.time.TotalMilliseconds > spawnTimer + ((100000 - (float)luaAmount) * ((100 - (float)luaChaos) / 100)))
            {
                spawnTimer = Game1.time.TotalMilliseconds;
                SpawnCloud(karte, camera);
            }

            //Wolken updaten
            for (int i = 0; i < clouds.Count(); i++)
            {
                Cloud cloud = clouds.ElementAt(i);
                cloud.Update(luaWind);
                if (cloud.position.X < -cloud.cuttexture.Width)
                {
                    clouds.Remove(cloud);
                }
            }
        }
 public void Draw(GameTime gameTime, Camera camera)
 {
     //Wird im Hauptgame ausgeführt und malt den Spieler mit der entsprechenden Animation
     if (start)
     {
         spine.Draw(gameTime, camera, position);
     }
 }
        public void UpdateDraw(int state, SpriteBatch spriteBatch, GameTime gameTime, Camera camera)
        {
            //----------------------------------------------------------------------
            //----------------------------------------Update
            //----------------------------------------------------------------------
            camera.UpdateTransformation(Game1.graphics);

            //----------------------------------------------------------------------
            //----------------------------------------Draw
            //----------------------------------------------------------------------
            //--------------------Draw to renderBackground--------------------
            Game1.graphics.GraphicsDevice.SetRenderTarget(renderBackground);
            Game1.graphics.GraphicsDevice.Clear(Color.Transparent);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.viewportTransform);
                spriteBatch.Draw(bg_texture, Vector2.Zero, Color.White);
                spriteBatch.Draw(logo_texture, Vector2.Zero, Color.White);
            spriteBatch.End();

            //--------------------Draw to renderTiles--------------------
            Game1.graphics.GraphicsDevice.SetRenderTarget(renderTiles);
            Game1.graphics.GraphicsDevice.Clear(Color.Transparent);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.viewportTransform);
                for (int i = 0; i <= state; i++)
                {
                    spriteBatch.Draw(tile[i], new Vector2(1920 / 2 - tile[0].Width / 2, 1080 - tile[0].Height - 10), Color.White);
                }
            spriteBatch.End();

            //--------------------Draw to renderScreen--------------------
            Game1.graphics.GraphicsDevice.SetRenderTarget(renderScreen);
            Game1.graphics.GraphicsDevice.Clear(Color.Transparent);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
                spriteBatch.Draw(renderBackground, Vector2.Zero, Color.White);
                spriteBatch.Draw(renderTiles, Vector2.Zero, Color.White);
                spriteBatch.Draw(overlay_texture, Vector2.Zero, Color.White);
            spriteBatch.End();

            //--------------------Draw to Screen--------------------
            Game1.graphics.GraphicsDevice.SetRenderTarget(null);
            Game1.graphics.GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.screenTransform);
                spriteBatch.Draw(renderScreen, Vector2.Zero, Color.White);
            spriteBatch.End();
            if (Game1.input.screenshot && Game1.CanTakeScreenshots)
                Game1.TakeScreenshot(renderScreen);
        }
 public void TextureManager(ContentManager Content, Camera camera)
 {
     //Lade Textur, einmal ausgeführt
     for (int i = 0; i < tilesCount; i++)
     {
         if (camera.viewport.X + camera.viewport.Width >= position.X + (i * 3840) && camera.viewport.X <= position.X + (i * 3840) + texture[i].Width)
         {
             if (texture[i].IsDisposed)
             {
                 texture[i] = Content.Load<Texture2D>("sprites/Level_" + Game1.level + "/Planes/" + textureName + "_" + (i + 1));
             }
         }
         else if (!texture[i].IsDisposed)
         {
             texture[i].Dispose();
         }
     }
 }
 public void Load(ContentManager Content)
 {
     camera = new Camera();
     character.Load(Content, Game1.graphics, "bonepuker", 1.5f, 0.5f);
     renderScreen = new RenderTarget2D(Game1.graphics.GraphicsDevice, 1920, 1080);
     renderSpine = new RenderTarget2D(Game1.graphics.GraphicsDevice, 1920, 1080);
     renderMenu = new RenderTarget2D(Game1.graphics.GraphicsDevice, 1920, 1080);
     renderTitle = new RenderTarget2D(Game1.graphics.GraphicsDevice, 1920, 1080);
     bg_texture = Content.Load<Texture2D>("sprites/menu/background");
     logo_texture = Content.Load<Texture2D>("sprites/menu/logo");
     credit_texture = Content.Load<Texture2D>("sprites/menu/credits");
     overlay_texture = Content.Load<Texture2D>("sprites/menu/overlay");
     controls_texture = Content.Load<Texture2D>("sprites/menu/controls");
     gameover_texture = Content.Load<Texture2D>("sprites/menu/gameover");
     levelend_texture = Content.Load<Texture2D>("sprites/menu/levelend");
     mainMenu = new SubMenu(3, "main", new Vector2(-650, 100), 150);
     mainMenu.Load(Content);
         mainMenu.buttons.Add(new Button("start", new Rectangle(0, 0, 150, 175), 4));
         mainMenu.buttons.Add(new Button("options", new Rectangle(0, 175, 150, 215), 4));
         mainMenu.buttons.Add(new Button("exit", new Rectangle(0, 390, 150, 250), 4));
         startMenu = new SubMenu(3, "start", new Vector2(-300, 160), 180);
     startMenu.Load(Content);
     startMenu.buttons.Add(new Button("continue", new Rectangle(0, 0, 140, 150), 3));
     startMenu.buttons.Add(new Button("newgame", new Rectangle(0, 150, 140, 140), 3));
     startMenu.buttons.Add(new Button("newgame", new Rectangle(0, 290, 140, 110), 3));
         optionMenu = new SubMenu(4, "option", new Vector2(-300, 160), 160);
     optionMenu.Load(Content);
     optionMenu.buttons.Add(new Button("fullscreen", new Rectangle(0, 0, 122, 95), 3));
     optionMenu.buttons.Add(new Button("stretch", new Rectangle(0, 95, 122, 110), 3));
     optionMenu.buttons.Add(new Button("sound", new Rectangle(0, 207, 122, 135), 3));
     optionMenu.buttons.Add(new Button("exit", new Rectangle(0, 346, 122, 90), 3));
     mainMenu.visible = true;
     Sound.Load(Content);
     Cutscene.Load(Content);
     if (Game1.sound && startScreen)
     {
         Sound.startMusicInstance.Play();
     }
     if (startScreen)
     {
         Cutscene.Play("start");
     }
 }
 public void Load(ContentManager Content, string textureName, Map karte, Camera camera)
 {
     cloudTexture = Content.Load<Texture2D>("sprites/Level_1/Planes/" + textureName);
     spawnTimer = 0;
     for (int i = 0; i <= size.X / luaWind; i++)
     {
         if (spawnTimer > (((100000 - (float)luaAmount) * ((100 - (float)luaChaos) / 100)) / 30))
         {
             spawnTimer = 0;
             SpawnCloud(karte, camera);
         }
         //Wolken updaten
         for (int t = 0; t < clouds.Count(); t++)
         {
             Cloud cloud = clouds.ElementAt(t);
             cloud.Update(luaWind);
             if (cloud.position.X < -cloud.cuttexture.Width)
             {
                 clouds.Remove(cloud);
             }
         }
         spawnTimer++;
     }
 }
 public virtual void Draw(SpriteBatch spriteBatch, GameTime gameTime, Camera camera)
 {
     spine.Draw(gameTime, camera, position);
 }
 public void Draw(GameTime gameTime, Camera camera)
 {
     spine.Draw(gameTime, camera, position);
 }
 public void Draw(GameTime gameTime, Camera camera)
 {
     spine.Draw(gameTime, camera, new Vector2(spine.skeleton.x, spine.skeleton.y));
 }
예제 #11
0
 public void Draw(SpriteBatch spriteBatch,GameTime gameTime,Camera camera, Color color)
 {
     for (int i = 0; i < blocks.Count(); ++i)
     { 
         Block block = blocks.ElementAt(i);
         if (Game1.debug)
             spriteBatch.Draw(mapTexture, block.position, block.cuttexture, color, 0, Vector2.Zero, 1, SpriteEffects.None, 1.0f);
     }
     for (int i = 0; i < items.Count(); ++i)
     { 
         Item item = items.ElementAt(i);
         spriteBatch.Draw(itemTexture, item.position, item.cuttexture, color, 0, Vector2.Zero, 1, SpriteEffects.None, 0.9f);
     }
     for (int i = 0; i < triggers.Count(); ++i)
     {
         Trigger trigger = triggers.ElementAt(i);
         Vector2 tvector = trigger.position;
         tvector.X -= 40;
         tvector.Y += 20;
         if (trigger.typ == 2)
         {
             Vector2 dvector = trigger.wallposition;
             if (Game1.level == 3)
             {
                 if (trigger.doorframe < 10)
                 {
                     dvector.Y += 100;
                     dvector.X -= 50;
                     spriteBatch.Draw(doorTexture, dvector, new Rectangle(0, 0, 106, 409), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                 }
                 else if (trigger.doorframe >= 10&&trigger.doorframe < 20)
                 {
                     dvector.Y += 90;
                     dvector.X -= 320;
                     spriteBatch.Draw(doorTexture, dvector, new Rectangle(106, 0, 376, 409), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                 }
                 else
                 {
                     dvector.Y += 120;
                     dvector.X -= 370;
                     spriteBatch.Draw(doorTexture, dvector, new Rectangle(484, 0, 416, 409), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                 }
             }
             else if (Game1.level == 4)
             {
                 if (i == 0)
                 {
                     if (trigger.doorframe < 10)
                     {
                         dvector.Y -= 500;
                         dvector.X -= 50;
                         spriteBatch.Draw(doorTexture, dvector, new Rectangle(0, 0, 106, 540), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                     }
                     else if (trigger.doorframe >= 10 && trigger.doorframe < 20)
                     {
                         dvector.Y -= 500;
                         dvector.X -= 320;
                         spriteBatch.Draw(doorTexture, dvector, new Rectangle(106, 0, 376, 540), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                     }
                     else
                     {
                         dvector.Y -= 500;
                         dvector.X -= 370;
                         spriteBatch.Draw(doorTexture, dvector, new Rectangle(484, 0, 416, 540), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                     }
                 }
                 else if (i == 1)
                 {
                     if (trigger.doorframe < 10)
                     {
                         dvector.Y -= 500;
                         dvector.X -= 100;
                         spriteBatch.Draw(doorTexture, dvector, new Rectangle(896, 0, 896 + 251, 540), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                     }
                     else if (trigger.doorframe >= 10 && trigger.doorframe < 20)
                     {
                         dvector.Y -= 490;
                         dvector.X -= 480;
                         spriteBatch.Draw(doorTexture, dvector, new Rectangle(896 + 251, 0, 896 + 580, 540), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                     }
                     else
                     {
                         dvector.Y -= 470;
                         dvector.X -= 570;
                         spriteBatch.Draw(doorTexture, dvector, new Rectangle(896 + 831, 0, 896 + 647, 540), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
                     }
                 }
             }
         }
         if (trigger.active)
         {
             spriteBatch.Draw(triggerTexture, tvector, new Rectangle(147, 0, 147, 60), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
             if (trigger.typ == 1)
                 spriteBatch.Draw(wallTexture, trigger.wallposition, new Rectangle(0, 0, 48, trigger.wallY), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
         }
         else
             spriteBatch.Draw(triggerTexture, tvector, new Rectangle(0, 0, 147, 60), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
     }
     for (int i = 0; i < objects.Count(); ++i)
     {
         Obj obj = objects.ElementAt(i);
         if (obj.type == 1)
             spriteBatch.Draw(objectTexture, obj.position, new Rectangle(0, 0, 96, 96), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
         else if (obj.type == 2)
             spriteBatch.Draw(objectTexture, obj.position, new Rectangle(96, 0, 96, 96), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
         else if (obj.type == 3)
         {  
             if(obj.stone)
                 spriteBatch.Draw(objectTexture, obj.position, new Rectangle(96 * 2, 0, 96, 96), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
             else
                 spriteBatch.Draw(objectTexture, obj.position, new Rectangle(96 * 3, 0, 96, 96), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
         }
         else if (obj.type == 4)
             spriteBatch.Draw(objectTexture, obj.position, new Rectangle(93*3, 0, 144, 96), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
     }
     for (int i = 0; i < mblocks.Count(); ++i)
     {
         MovingBlock mblock = mblocks.ElementAt(i);
         spriteBatch.Draw(bewegendTexture, new Vector2(mblock.cbox.X,mblock.cbox.Y-24),color);
     }
     for (int i = 0; i < breakblocks.Count(); ++i)
     {
         Breakable breakblock = breakblocks.ElementAt(i);
         if (Game1.level == 3)
         {
             if (breakblock.id == 0)
             {
                 spriteBatch.Draw(breakTexture, new Vector2(breakblock.cbox.X - 127, breakblock.cbox.Y - 20), new Rectangle(0, 0, 332, 372), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
             }
             else if (breakblock.id == 1 )
             {
                 spriteBatch.Draw(breakTexture, new Vector2(breakblock.cbox.X - 70, breakblock.cbox.Y-27), new Rectangle(332 * 1, 0, 332, 372), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
             }
             else if (breakblock.id == 2)
             {
                 spriteBatch.Draw(breakTexture, new Vector2(breakblock.cbox.X - 10, breakblock.cbox.Y-24), new Rectangle(332 * 2, 0, 332, 372), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
             }
             else if (breakblock.id == 3)
             {
                 spriteBatch.Draw(breakTexture, new Vector2(breakblock.cbox.X - 20, breakblock.cbox.Y-65), new Rectangle(332 * 3, 0, 332, 372), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
             }
         }
         else if (Game1.level == 4)
         {
             if (breakblock.id == 0)
             {
                 spriteBatch.Draw(breakTexture, new Vector2(breakblock.cbox.X - 60, breakblock.cbox.Y - 35), new Rectangle(0, 0, 389, 377), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
             }
             else if (breakblock.id == 1)
             {
                 spriteBatch.Draw(breakTexture, new Vector2(breakblock.cbox.X - 315, breakblock.cbox.Y - 35), new Rectangle(389, 0, 389, 377), color, 0, Vector2.Zero, 1, SpriteEffects.None, 0f);
             }
         }
     }
 }
 public void Draw(GameTime gameTime, Camera camera,Vector2 position)
 {
     //Player -> Drawposition
     skeleton.X = position.X - camera.viewport.X;
     skeleton.Y = position.Y - camera.viewport.Y;
     //----------Spine----------
     animationState.Update(gameTime.ElapsedGameTime.Milliseconds / 1000f);
     animationState.Apply(skeleton);
     skeleton.UpdateWorldTransform();
     skeletonRenderer.Begin();
     skeletonRenderer.Draw(skeleton);
     skeletonRenderer.End();
     //Player -> Worldposition
     skeleton.X = position.X;
     skeleton.Y = position.Y;
 }
 public void Draw(SpriteBatch spriteBatch, GameTime gameTime, Camera camera)
 {
     spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, null, camera.viewportTransform);
     for (int i = 0; i < buttons.Count(); ++i)
     {
         Button button = buttons.ElementAt(i);
         button.Draw(spriteBatch, new Vector2((Game1.resolution.X / 2) + offset.X, (Game1.resolution.Y / 2) - (((optionCount - 1) * optionSpace) / 2) + (i * optionSpace) + offset.Y), button_texture); 
     }
     spriteBatch.End();
 }
 public void SpawnCloud(Map karte, Camera camera)
 {
     //Entscheiden ob Wolke gespawned werden soll
     testSpawn = randomNumber.Next(0, 100);
     if (testSpawn >= luaChaos)
     {
         //Wolkentyp bestimmen
         testType = randomNumber.Next(0, 10);
         int type = 1;
         if (testType < luaType)
         {
             type = 2;
         }
         //Wolkenposition bestimmen
         testPosition = randomNumber.Next(0, 100);
         int spawnPosition = ((int)((luaBottom - luaTop) * ((float)testPosition / 100))) + luaTop;
         //Wolke erstellen
         testSize = randomNumber.Next(luaSizeMin, luaSizeMax);
         clouds.Add(new Cloud(type, new Vector2(size.X, spawnPosition), (float)testSize / 100));
     }
 }