예제 #1
0
파일: Map.cs 프로젝트: BlueBananasaurus/BP
        public void DrawWaterMask()
        {
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, transformMatrix: Camera2DGame.GetViewMatrix(), samplerState: SamplerState.PointWrap);

            for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 1); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, FunctionTileMap.GetLength(1)); y++)
            {
                for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, FunctionTileMap.GetLength(0)); x++)
                {
                    if (FunctionTileMap[x, y] == 2 && FunctionTileMap[x, y - 1] == 2)
                    {
                        Game1.SpriteBatchGlobal.Draw(Game1.tileMask, new Vector2(x * Globals.TileSize, y * Globals.TileSize));
                    }
                    if (FunctionTileMap[x, y] == 2 && FunctionTileMap[x, y - 1] != 2 && x % 2 == 0)
                    {
                        Game1.SpriteBatchGlobal.Draw(Game1.WaterAnimateLeft, new Vector2(x * Globals.TileSize, (y - 1) * Globals.TileSize));
                    }
                    if (FunctionTileMap[x, y] == 2 && FunctionTileMap[x, y - 1] != 2 && x % 2 == 1)
                    {
                        Game1.SpriteBatchGlobal.Draw(Game1.WaterAnimateRight, new Vector2(x * Globals.TileSize, (y - 1) * Globals.TileSize));
                    }
                }
            }

            Game1.SpriteBatchGlobal.End();
        }
예제 #2
0
 public void DrawNormal()
 {
     Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.LinearClamp, transformMatrix: Camera2DGame.GetViewMatrix());
     CurretnObjectControl.DrawNormal(this);
     Game1.SpriteBatchGlobal.End();
 }
예제 #3
0
 public void Draw()
 {
     Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, transformMatrix: Camera2DGame.GetViewMatrix());
     CurretnObjectControl.Draw(this);
     Game1.SpriteBatchGlobal.End();
 }
예제 #4
0
파일: Map.cs 프로젝트: BlueBananasaurus/BP
        public void DrawNormal()
        {
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.PointWrap, transformMatrix: Camera2DGame.GetViewMatrix());

            if (ShowGround == true)
            {
                Game1.SpriteBatchGlobal.Draw(Game1.Textures["tileTopNormal"], sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize + 1920, Globals.TileSize), position: new Vector2(-1920 / 2, (FunctionTileMap.GetLength(1) - 1) * Globals.TileSize));

                Game1.SpriteBatchGlobal.Draw(Game1.Textures["tileNormal"], sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize + 1920, Globals.TileSize * 20), position: new Vector2(-1920 / 2, (FunctionTileMap.GetLength(1) - 1) * Globals.TileSize + Globals.TileSize));
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                if ((dcr as DecorationStatic).IsFront == false)
                {
                    dcr.DrawNormal();
                }
            }

            if (BackgroundTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, BackgroundTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, BackgroundTileMap.GetLength(0)); x++)
                    {
                        if (Camera2DGame.Position.Y - Globals.TileSize < y * Globals.TileSize && y * Globals.TileSize < Camera2DGame.Position.Y + Globals.WinRenderSize.Y + Globals.TileSize)
                        {
                            if (Camera2DGame.Position.X - Globals.TileSize < x * Globals.TileSize && x * Globals.TileSize < Camera2DGame.Position.X + Globals.WinRenderSize.X + Globals.TileSize)
                            {
                                if (BackgroundTileMap[x, y] == 1)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 2)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 3)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 4)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 5)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 6)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["tilesNormal"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 32, 32, 32));
                                }
                            }
                        }
                    }
                }
            }

            foreach (ICrate crt in mapCrates)
            {
                crt.DrawNormal();
            }

            foreach (ITriggers trgr in mapTriggers)
            {
                trgr.DrawNormal();
            }

            foreach (IRectanglePhysics mvbl in MapMovables)
            {
                mvbl.DrawNormal();
            }

            foreach (Inpc npc in MapNpcs)
            {
                if (npc is CarryBase == false)
                {
                    npc.DrawNormal();
                }
            }

            Game1.SpriteBatchGlobal.End();

            Game1.PlayerInstance.DrawNormal();

            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.PointWrap, transformMatrix: Camera2DGame.GetViewMatrix());

            foreach (Inpc npc in MapNpcs)
            {
                if (npc is CarryBase == true)
                {
                    npc.DrawNormal();
                }
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                if ((dcr as DecorationStatic).IsFront == true)
                {
                    dcr.DrawNormal();
                }
            }

            foreach (IProjectile prjctl in MapProjectiles)
            {
                prjctl.DrawNormal();
            }
            Game1.SpriteBatchGlobal.End();

            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.NonPremultiplied, SamplerState.PointWrap, transformMatrix: Camera2DGame.GetViewMatrix());

            foreach (IParticle prtcl in mapParticles)
            {
                prtcl.DrawNormal();
            }

            Game1.SpriteBatchGlobal.End();
        }
예제 #5
0
파일: Map.cs 프로젝트: BlueBananasaurus/BP
        public void Draw()
        {
            Game1.SpriteBatchGlobal.Begin(transformMatrix: Camera2DGame.GetViewMatrix(), samplerState: SamplerState.PointWrap, sortMode: SpriteSortMode.Immediate);

            Game1.Game1Self.GraphicsDevice.Clear(Color.CornflowerBlue);

            if (ShowBoundary == true)
            {
                Game1.EffectSlide.Parameters["UV"].SetValue(new Vector2(0, _time));
                Game1.EffectSlide.CurrentTechnique.Passes[0].Apply();
                Game1.SpriteBatchGlobal.Draw(Game1.boundary, position: new Vector2(-64, 0), sourceRectangle: new Rectangle(0, 0, 64, FunctionTileMap.GetLength(1) * Globals.TileSize));
                Game1.SpriteBatchGlobal.Draw(Game1.boundary, position: new Vector2(FunctionTileMap.GetLength(0) * Globals.TileSize, 0), sourceRectangle: new Rectangle(0, 0, 64, FunctionTileMap.GetLength(1) * Globals.TileSize), effects: SpriteEffects.FlipHorizontally);
                Game1.EffectBaseColor.CurrentTechnique.Passes[0].Apply();
            }

            if (ShowGround == true)
            {
                Game1.SpriteBatchGlobal.Draw(Game1.tileTop, sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize / 2 + 1920 / 2, Globals.TileSize / 2), position: new Vector2(-1920 / 2, (FunctionTileMap.GetLength(1) - 1) * Globals.TileSize), scale: new Vector2(2));
                Game1.SpriteBatchGlobal.Draw(Game1.Tile03, sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize / 2 + 1920 / 2, Globals.TileSize * 10), position: new Vector2(-1920 / 2, (FunctionTileMap.GetLength(1) - 1) * Globals.TileSize + Globals.TileSize), scale: new Vector2(2));
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                if ((dcr as DecorationStatic).IsFront == false)
                {
                    dcr.Draw();
                }
            }

            if (BackgroundTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, BackgroundTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, BackgroundTileMap.GetLength(0)); x++)
                    {
                        if (Camera2DGame.Position.Y - Globals.TileSize < y * Globals.TileSize && y * Globals.TileSize < Camera2DGame.Position.Y + Globals.WinRenderSize.Y + Globals.TileSize)
                        {
                            if (Camera2DGame.Position.X - Globals.TileSize < x * Globals.TileSize && x * Globals.TileSize < Camera2DGame.Position.X + Globals.WinRenderSize.X + Globals.TileSize)
                            {
                                if (BackgroundTileMap[x, y] == 1)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 2)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 3)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 4)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 5)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 6)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesSand"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 32, 32, 32));
                                }
                            }
                        }
                    }
                }
            }

            if (ForegroundTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, ForegroundTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, ForegroundTileMap.GetLength(0)); x++)
                    {
                    }
                }
            }

            if (DrawFunctionMap == true)
            {
                for (int y = Math.Max((int)(Camera2DGame.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DGame.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, FunctionTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DGame.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DGame.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, FunctionTileMap.GetLength(0)); x++)
                    {
                        if (Camera2DGame.Position.Y - Globals.TileSize < y * Globals.TileSize && y * Globals.TileSize < Camera2DGame.Position.Y + Globals.WinRenderSize.Y + Globals.TileSize)
                        {
                            if (Camera2DGame.Position.X - Globals.TileSize < x * Globals.TileSize && x * Globals.TileSize < Camera2DGame.Position.X + Globals.WinRenderSize.X + Globals.TileSize)
                            {
                                if (FunctionTileMap[x, y] == 1)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.tileBack1, new Vector2(x * Globals.TileSize, y * Globals.TileSize), scale: new Vector2(2));
                                }
                                if (FunctionTileMap[x, y] == 2)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.waterTex, new Vector2(x * Globals.TileSize, y * Globals.TileSize), scale: new Vector2(2));
                                }
                            }
                        }
                    }
                }
            }

            foreach (ICrate crt in mapCrates)
            {
                crt.Draw();
            }

            foreach (ITriggers trgr in mapTriggers)
            {
                trgr.Draw();
            }

            foreach (IRectanglePhysics mvbl in MapMovables)
            {
                mvbl.Draw();
            }

            foreach (IPickable pick in mapPickables)
            {
                pick.Draw();
            }

            foreach (Inpc npc in MapNpcs)
            {
                if (npc is CarryBase == false)
                {
                    npc.Draw();
                }
            }

            Game1.SpriteBatchGlobal.End();

            Game1.PlayerInstance.Draw();

            Game1.SpriteBatchGlobal.Begin(transformMatrix: Camera2DGame.GetViewMatrix(), samplerState: SamplerState.PointWrap, sortMode: SpriteSortMode.Immediate);

            foreach (Inpc npc in MapNpcs)
            {
                if (npc is CarryBase == true)
                {
                    npc.Draw();
                }
            }

            foreach (IDecoration dcr in mapDecorations)
            {
                if ((dcr as DecorationStatic).IsFront == true)
                {
                    dcr.Draw();
                }
            }

            foreach (IEffect lght in mapLightings)
            {
                lght.Draw();
            }

            foreach (IProjectile prjctl in MapProjectiles)
            {
                prjctl.Draw();
            }

            foreach (IParticle prtcl in mapParticles)
            {
                prtcl.Draw();
            }

            Game1.SpriteBatchGlobal.End();

            Game1.SpriteBatchGlobal.Begin(samplerState: SamplerState.PointWrap, sortMode: SpriteSortMode.Immediate);
            Effects.ColorEffect(new Vector4(1f, 1f, 1f, _transparency));
            Game1.SpriteBatchGlobal.Draw(Game1.Transition, Vector2.Zero);
            Game1.EffectBaseColor.CurrentTechnique.Passes[0].Apply();
            Game1.SpriteBatchGlobal.End();
        }
예제 #6
0
        private static void DrawFinal(IMap map)
        {
            Game1.GraphicsGlobal.GraphicsDevice.SetRenderTargets(Game1.FinalScreen);
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap);
            Game1.SpriteBatchGlobal.Draw(Game1.WaterWithoutLights, Vector2.Zero);
            Game1.SpriteBatchGlobal.End();
            if (map is Map)
            {
                Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap, transformMatrix: Camera2DGame.GetViewMatrix());

                foreach (Inpc ui in (map as Map).MapNpcs)
                {
                    if (ui as IUI != null)
                    {
                        (ui as IUI).DrawUI();
                    }
                }

                Game1.SpriteBatchGlobal.End();
            }
            Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointWrap);
            if (Game1.State == GlobalState.inGame)
            {
                UIPlayer.Draw();
            }
            foreach (UIInformer info in Game1.InfoList.Reverse <UIInformer>())
            {
                info.Position = new Vector2(8, Game1.InfoList.IndexOf(info) * 32 + 8);
                info.Draw();
            }
            Game1.SpriteBatchGlobal.End();
        }
예제 #7
0
 private static void DrawLights(IMap map)
 {
     RenderTargetsSettings.SetAndClear(Game1.Lights, new Color(map.LightLevel));
     Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp, transformMatrix: Camera2DGame.GetViewMatrix());
     map.DrawLights();
     Game1.SpriteBatchGlobal.End();
     Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, BlendState.Additive, SamplerState.PointClamp);
     Game1.SpriteBatchGlobal.Draw(Game1.LightNormalHolder, Vector2.Zero);
     Game1.SpriteBatchGlobal.End();
 }