Esempio n. 1
0
        public void GenerateMapFunctionTrees()
        {
            MapTree   = new MapTreeHolder((int)MapBoundary.Size.X, (int)MapBoundary.Size.Y);
            WaterTree = new MapTreeHolder((int)MapBoundary.Size.X, (int)MapBoundary.Size.Y);

            for (int y = 0; y < FunctionTileMap.GetLength(1); y++)
            {
                for (int x = 0; x < FunctionTileMap.GetLength(0); x++)
                {
                    if (FunctionTileMap[x, y] == "block")
                    {
                        MapTree.AddRectangle32(new Vector2(x, y) * Globals.TileSize);
                    }
                    if (FunctionTileMap[x, y] == "water")
                    {
                        WaterTree.AddRectangle32(new Vector2(x, y) * Globals.TileSize);
                    }
                }
            }
        }
Esempio n. 2
0
        public void Draw()
        {
            //Game1.SpriteBatchGlobal.Begin(transformMatrix: Camera2DEditor.GetViewMatrix(), samplerState: SamplerState.PointWrap, sortMode: SpriteSortMode.Immediate);

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

            //if (ShowGround == true)
            //{
            //    Game1.SpriteBatch.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) * Globals.TileSize), scale: new Vector2(2));
            //    Game1.SpriteBatch.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) * Globals.TileSize + Globals.TileSize), scale: new Vector2(2));
            //}

            foreach (IDecoration dcr in mapDecorations)
            {
                dcr.Draw();
            }

            Effects.ColorEffect(new Vector4(1, 1, 1, TransparencyBackground * Convert.ToInt32(UIDrawing.Instance.BackgroundVisibility.State)));
            if (BackgroundTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DEditor.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DEditor.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, BackgroundTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DEditor.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DEditor.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, BackgroundTileMap.GetLength(0)); x++)
                    {
                        if (Camera2DEditor.Position.Y - Globals.TileSize < y * Globals.TileSize && y * Globals.TileSize < Camera2DEditor.Position.Y + Globals.WinRenderSize.Y + Globals.TileSize)
                        {
                            if (Camera2DEditor.Position.X - Globals.TileSize < x * Globals.TileSize && x * Globals.TileSize < Camera2DEditor.Position.X + Globals.WinRenderSize.X + Globals.TileSize)
                            {
                                foreach (Tile tile in Game1.Tiles)
                                {
                                    if (BackgroundTileMap[x, y] == tile.Code)
                                    {
                                        Game1.SpriteBatchGlobal.DrawAtlas(Game1.Textures[tile.TextureName], new Vector2(x * Globals.TileSize, y * Globals.TileSize), new Point(Globals.TileSize, Globals.TileSize), tile.IndexInPicture);
                                    }
                                }

                                if (y > 0)
                                {
                                    if (FunctionTileMap[x, y] == "water" && FunctionTileMap[x, y - 1] != "water")
                                    {
                                        Game1.SpriteBatchGlobal.Draw(Game1.waterTop, new Vector2(x * Globals.TileSize, y * Globals.TileSize), scale: new Vector2(2));
                                    }
                                }
                            }
                        }
                    }
                }
            }
            Effects.ResetEffectSimple();

            foreach (MechEditor entity in mapEntities)
            {
                entity.Draw();
            }

            foreach (CrateStatic 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 PlayerTurret == false)
                {
                    npc.Draw();
                }
            }

            Player?.Draw();

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

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

            foreach (ParticleSmokeTrail trl in MapTrails)
            {
                trl.Draw();
            }

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

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

            Effects.ColorEffect(new Vector4(1, 1, 1, TransparencyForeground * Convert.ToInt32(UIDrawing.Instance.ForegroundVisibility.State)));
            if (ForegroundTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DEditor.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DEditor.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, ForegroundTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DEditor.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DEditor.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, ForegroundTileMap.GetLength(0)); x++)
                    {
                        foreach (Tile tile in Game1.Tiles)
                        {
                            if (ForegroundTileMap[x, y] == tile.Code)
                            {
                                Game1.SpriteBatchGlobal.DrawAtlas(Game1.Textures[tile.TextureName], new Vector2(x * Globals.TileSize, y * Globals.TileSize), new Point(Globals.TileSize, Globals.TileSize), tile.IndexInPicture);
                            }
                        }
                    }
                }
            }
            Effects.ResetEffectSimple();

            if (FunctionTileMap != null)
            {
                for (int y = Math.Max((int)(Camera2DEditor.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DEditor.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, FunctionTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DEditor.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DEditor.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, FunctionTileMap.GetLength(0)); x++)
                    {
                        if (Camera2DEditor.Position.Y - Globals.TileSize < y * Globals.TileSize && y * Globals.TileSize < Camera2DEditor.Position.Y + Globals.WinRenderSize.Y + Globals.TileSize)
                        {
                            if (Camera2DEditor.Position.X - Globals.TileSize < x * Globals.TileSize && x * Globals.TileSize < Camera2DEditor.Position.X + Globals.WinRenderSize.X + Globals.TileSize)
                            {
                                //if (FunctionTileMap[x, y] == "obstacle")
                                //    Game1.SpriteBatchGlobal.Draw(Game1.tileBack1, new Vector2(x * Globals.TileSize, y * Globals.TileSize));
                                //if (FunctionTileMap[x, y] == "water")
                                //    Game1.SpriteBatchGlobal.Draw(Game1.waterTex, new Vector2(x * Globals.TileSize, y * Globals.TileSize));
                            }
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public void Draw()
        {
            Game1.SpriteBatchGlobal.Begin(transformMatrix: Camera2DWorld.GetViewMatrix(), samplerState: SamplerState.PointWrap, sortMode: SpriteSortMode.Immediate);

            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, 32, FunctionTileMap.GetLength(1) * Globals.TileSize / 2), scale: new Vector2(2));
                Game1.SpriteBatchGlobal.Draw(Game1.boundary, position: new Vector2(FunctionTileMap.GetLength(0) * Globals.TileSize, 0), sourceRectangle: new Rectangle(0, 0, 32, FunctionTileMap.GetLength(1) * Globals.TileSize / 2), scale: new Vector2(2), effects: SpriteEffects.FlipHorizontally);
                Game1.EffectBaseColor.CurrentTechnique.Passes[0].Apply();
            }

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

            foreach (IDecoration dcr in mapDecorations)
            {
                dcr.Draw();
            }

            foreach (City city in Cities)
            {
                city.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["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 2)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], 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["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 4)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(96, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 5)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(128, 0, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 6)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(160, 0, 32, 32));
                                }

                                if (BackgroundTileMap[x, y] == 7)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 8)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 9)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 10)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(96, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 11)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(128, 32, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 11)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(160, 32, 32, 32));
                                }

                                if (BackgroundTileMap[x, y] == 12)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 64, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 13)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 64, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 14)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 64, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 15)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(96, 64, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 16)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(128, 64, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 17)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(160, 64, 32, 32));
                                }

                                if (BackgroundTileMap[x, y] == 18)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(0, 96, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 19)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(32, 96, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 20)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(64, 96, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 21)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(96, 96, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 22)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(128, 96, 32, 32));
                                }
                                if (BackgroundTileMap[x, y] == 23)
                                {
                                    Game1.SpriteBatchGlobal.Draw(Game1.Textures["TilesWorld"], new Vector2(x * Globals.TileSize, y * Globals.TileSize), sourceRectangle: new Rectangle(160, 96, 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));
                                }
                            }
                        }
                    }
                }
            }

            Game1.SpriteBatchGlobal.End();

            Game1.PlayerWorldInstance.Draw();

            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();
        }
Esempio n. 4
0
        public void DrawWaterMask()
        {
            if (FunctionTileMap != null)
            {
                Game1.SpriteBatchGlobal.Begin(SpriteSortMode.Immediate, transformMatrix: Camera2DWorld.GetViewMatrix(), samplerState: SamplerState.PointWrap);

                Game1.SpriteBatchGlobal.Draw(Game1.tileMask, sourceRectangle: new Rectangle(0, 0, 1920 / 2, FunctionTileMap.GetLength(1) * Globals.TileSize + 1080), position: new Vector2(-1920 / 2, -1080 / 2));
                Game1.SpriteBatchGlobal.Draw(Game1.tileMask, sourceRectangle: new Rectangle(0, 0, 1920 / 2, FunctionTileMap.GetLength(1) * Globals.TileSize + 1080), position: new Vector2(FunctionTileMap.GetLength(0) * Globals.TileSize, -1080 / 2));

                Game1.SpriteBatchGlobal.Draw(Game1.tileMask, sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize, 1080 / 2), position: new Vector2(0, -1080 / 2));
                Game1.SpriteBatchGlobal.Draw(Game1.tileMask, sourceRectangle: new Rectangle(0, 0, FunctionTileMap.GetLength(0) * Globals.TileSize, 1080 / 2), position: new Vector2(0, FunctionTileMap.GetLength(1) * Globals.TileSize));

                for (int y = Math.Max((int)(Camera2DWorld.PositionPoint.Y / 32), 0); y < Math.Min((int)((Camera2DWorld.PositionPoint.Y + Globals.WinRenderSize.Y) / 32) + 1, FunctionTileMap.GetLength(1)); y++)
                {
                    for (int x = Math.Max((int)(Camera2DWorld.PositionPoint.X / 32), 0); x < Math.Min((int)((Camera2DWorld.PositionPoint.X + Globals.WinRenderSize.X) / 32) + 1, FunctionTileMap.GetLength(0)); x++)
                    {
                        if (FunctionTileMap[x, y] == 2)
                        {
                            Game1.SpriteBatchGlobal.Draw(Game1.tileMask, new Vector2(x * Globals.TileSize, y * Globals.TileSize));
                        }
                        if (FunctionTileMap[x, y] == 3)
                        {
                            Game1.SpriteBatchGlobal.Draw(Game1.tileMask, new Vector2(x * Globals.TileSize, y * Globals.TileSize + Globals.TileSize / 2), sourceRectangle: new Rectangle(0, 0, 32, 16));
                        }
                    }
                }
                Game1.SpriteBatchGlobal.End();
            }
        }
Esempio n. 5
0
        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();
        }
Esempio n. 6
0
        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();
        }
Esempio n. 7
0
        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();
        }