コード例 #1
0
        public static void ImportAllVFX(string sourceDir, string particlePattern, string beamPattern)
        {
            string[] dirs = Directory.GetDirectories(sourceDir + "Beam");
            foreach (string dir in dirs)
            {
                string fileName   = Path.GetFileNameWithoutExtension(dir);
                string asset_name = fileName;
                using (BeamSheet sheet = BeamSheet.Import(dir + "/"))
                {
                    using (FileStream stream = File.OpenWrite(String.Format(beamPattern, asset_name)))
                    {
                        using (BinaryWriter writer = new BinaryWriter(stream))
                            sheet.Save(writer);
                    }
                }
            }
            dirs = Directory.GetFiles(sourceDir + "Particle", "*.png");
            foreach (string dir in dirs)
            {
                string   fileName   = Path.GetFileNameWithoutExtension(dir);
                string[] components = fileName.Split('.');
                string   asset_name = components[0];

                using (DirSheet sheet = DirSheet.Import(dir))
                {
                    using (FileStream stream = File.OpenWrite(String.Format(particlePattern, asset_name)))
                    {
                        using (BinaryWriter writer = new BinaryWriter(stream))
                            sheet.Save(writer);
                    }
                }
            }
        }
コード例 #2
0
        public static void ImportAllItems(string sourceDir, string destPattern)
        {
            try
            {
                DiagManager.Instance.LoadMsg = "Importing Items.";

                string[] dirs = Directory.GetDirectories(sourceDir);
                foreach (string dir in dirs)
                {
                    string fileName = Path.GetFileNameWithoutExtension(dir);
                    int    index    = Int32.Parse(fileName);
                    using (DirSheet sheet = DirSheet.Import(dir + "/None.png"))
                    {
                        using (FileStream stream = File.OpenWrite(String.Format(destPattern, index)))
                        {
                            using (BinaryWriter writer = new BinaryWriter(stream))
                                sheet.Save(writer);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                DiagManager.Instance.LogError(new Exception("Error importing Items\n", ex));
            }
        }
コード例 #3
0
ファイル: Hitbox.cs プロジェクト: Parakoopa/RogueEssence
        public override Loc GetDrawSize()
        {
            DirSheet sheet = getAnimSheet();

            if (sheet == null)
            {
                return(new Loc());
            }
            return(new Loc(sheet.TileWidth, sheet.TileHeight));
        }
コード例 #4
0
ファイル: Hitbox.cs プロジェクト: Parakoopa/RogueEssence
        public override Loc GetDrawLoc(Loc offset)
        {
            DirSheet sheet = getAnimSheet();

            if (sheet == null)
            {
                return(MapLoc - offset);
            }
            return(new Loc(MapLoc.X + GraphicsManager.TileSize / 2 - sheet.TileWidth / 2,
                           MapLoc.Y + GraphicsManager.TileSize / 2 - sheet.TileHeight / 2) - offset);
        }
コード例 #5
0
        public Loc GetDrawSize()
        {
            TileData entry = DataManager.Instance.GetTile(ID);

            if (!Revealed)
            {
                entry = DataManager.Instance.GetTile(0);
            }
            DirSheet sheet = GraphicsManager.GetObject(entry.Anim.AnimIndex);

            return(new Loc(sheet.TileWidth, sheet.TileHeight));
        }
コード例 #6
0
ファイル: Hitbox.cs プロジェクト: Parakoopa/RogueEssence
        public override void Draw(SpriteBatch spriteBatch, Loc offset)
        {
            DirSheet sheet = getAnimSheet();

            if (sheet == null)
            {
                return;
            }
            //draw the anim associated with this attack (aka, the projectile itself)
            Loc start = GetDrawLoc(offset);

            sheet.DrawDir(spriteBatch, start.ToVector2(), Anim.GetCurrentFrame(time, sheet.TotalFrames), DirExt.AddAngles(Dir, Anim.AnimDir));
        }
コード例 #7
0
        public Loc GetDrawLoc(Loc offset)
        {
            TileData entry = DataManager.Instance.GetTile(ID);

            if (!Revealed)
            {
                entry = DataManager.Instance.GetTile(0);
            }
            DirSheet sheet = GraphicsManager.GetObject(entry.Anim.AnimIndex);

            return(new Loc(MapLoc.X + GraphicsManager.TileSize / 2 - sheet.TileWidth / 2,
                           MapLoc.Y + GraphicsManager.TileSize / 2 - sheet.TileHeight / 2) - offset);
        }
コード例 #8
0
        public override void Draw(SpriteBatch spriteBatch, Loc offset)
        {
            DirSheet sheet = getAnimSheet();

            if (sheet == null)
            {
                return;
            }
            //draw the anim associated with this attack (aka, the arcing projectile itself)
            Loc start = GetDrawLoc(offset);

            sheet.DrawDir(spriteBatch, new Vector2(start.X, start.Y - LocHeight), Anim.GetCurrentFrame(time, sheet.TotalFrames), Anim.GetDrawDir(User.CharDir));
        }
コード例 #9
0
        public void Draw(SpriteBatch spriteBatch, Loc offset)
        {
            Loc      drawLoc = GetDrawLoc(offset);
            TileData entry   = DataManager.Instance.GetTile(ID);

            if (!Revealed) //draw texture
            {
                entry = DataManager.Instance.GetTile(0);
            }

            if (entry.Anim.AnimIndex != "")
            {
                DirSheet sheet = GraphicsManager.GetObject(entry.Anim.AnimIndex);
                sheet.DrawDir(spriteBatch, drawLoc.ToVector2(), entry.Anim.GetCurrentFrame(GraphicsManager.TotalFrameTick, sheet.TotalFrames), entry.Anim.GetDrawDir(Dir8.None), Color.White * ((Owner == TileOwner.Player) ? 0.70f : 1f));
            }
        }
コード例 #10
0
ファイル: Hitbox.cs プロジェクト: Parakoopa/RogueEssence
        private DirSheet getAnimSheet()
        {
            DirSheet sheet = null;

            if (Anim.AnimIndex == "")
            {
                if (ItemAnim < 0)
                {
                    return(null);
                }
                sheet = GraphicsManager.GetItem(ItemAnim);
            }
            else
            {
                sheet = GraphicsManager.GetAttackSheet(Anim.AnimIndex);
            }
            return(sheet);
        }
コード例 #11
0
        /// <summary>
        /// Bakes all multi-directional spritesheets specified in the directory.
        /// </summary>
        /// <param name="sourceDir">Parent directory of the input files.</param>
        /// <param name="cachePattern">Pattern expression to save the output files as.</param>
        public static void ImportAllDirs(string sourceDir, string cachePattern)
        {
            string[] dirs = Directory.GetFiles(sourceDir, "*.png");
            foreach (string dir in dirs)
            {
                string   fileName   = Path.GetFileNameWithoutExtension(dir);
                string[] components = fileName.Split('.');
                int      index      = Int32.Parse(components[1]);

                using (DirSheet sheet = DirSheet.Import(dir))
                {
                    using (FileStream stream = File.OpenWrite(String.Format(cachePattern, index)))
                    {
                        using (BinaryWriter writer = new BinaryWriter(stream))
                            sheet.Save(writer);
                    }
                }
            }
        }
コード例 #12
0
        public void DrawBG(SpriteBatch spriteBatch)
        {
            if (BGAnim.AnimIndex != "")
            {
                DirSheet sheet = GraphicsManager.GetBackground(BGAnim.AnimIndex);

                Loc diff = BGMovement * (int)FrameTick.TickToFrames(GraphicsManager.TotalFrameTick) / 60;
                if (sheet.Width == 1 && sheet.Height == 1)
                {
                    sheet.DrawTile(spriteBatch, new Rectangle(0, 0, GraphicsManager.ScreenWidth, GraphicsManager.ScreenHeight), 0, 0, Color.White);
                }
                else
                {
                    for (int x = diff.X % sheet.TileWidth - sheet.TileWidth; x < GraphicsManager.ScreenWidth; x += sheet.TileWidth)
                    {
                        for (int y = diff.Y % sheet.TileHeight - sheet.TileHeight; y < GraphicsManager.ScreenHeight; y += sheet.TileHeight)
                        {
                            sheet.DrawDir(spriteBatch, new Vector2(x, y), BGAnim.GetCurrentFrame(GraphicsManager.TotalFrameTick, sheet.TotalFrames), BGAnim.AnimDir, Color.White);
                        }
                    }
                }
            }
        }
コード例 #13
0
        protected override void PostDraw(SpriteBatch spriteBatch)
        {
            Matrix matrix = Matrix.CreateScale(new Vector3(drawScale, drawScale, 1));

            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, matrix);

            if (AutoTileInProgress != null)
            {
                for (int jj = viewTileRect.Y; jj < viewTileRect.End.Y; jj++)
                {
                    for (int ii = viewTileRect.X; ii < viewTileRect.End.X; ii++)
                    {
                        Loc testLoc = new Loc(ii, jj);
                        if (Collision.InBounds(ZoneManager.Instance.CurrentMap.Width, ZoneManager.Instance.CurrentMap.Height, testLoc) &&
                            AutoTileInProgress.IncludesLoc(testLoc))
                        {
                            AutoTile brush = AutoTileInProgress.GetBrush(testLoc);
                            if (brush.IsEmpty())
                            {
                                GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, Color.Black);
                            }
                            else
                            {
                                brush.Draw(spriteBatch, new Loc(ii * GraphicsManager.TileSize, jj * GraphicsManager.TileSize) - ViewRect.Start);
                            }
                        }
                    }
                }
            }

            //draw the blocks

            for (int jj = viewTileRect.Y; jj < viewTileRect.End.Y; jj++)
            {
                for (int ii = viewTileRect.X; ii < viewTileRect.End.X; ii++)
                {
                    Loc testLoc = new Loc(ii, jj);
                    if (Collision.InBounds(ZoneManager.Instance.CurrentMap.Width, ZoneManager.Instance.CurrentMap.Height, testLoc))
                    {
                        TerrainTile tile = ZoneManager.Instance.CurrentMap.Tiles[ii][jj].Data;
                        if (TerrainInProgress != null && TerrainInProgress.IncludesLoc(testLoc))
                        {
                            tile = TerrainInProgress.GetBrush(testLoc);
                            if (tile.TileTex.IsEmpty())
                            {
                                GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, Color.Black);
                            }
                            else
                            {
                                tile.TileTex.Draw(spriteBatch, new Loc(ii * GraphicsManager.TileSize, jj * GraphicsManager.TileSize) - ViewRect.Start);
                            }
                        }

                        if (ShowTerrain)
                        {
                            TerrainData data  = tile.GetData();
                            Color       color = Color.Transparent;
                            switch (data.BlockType)
                            {
                            case TerrainData.Mobility.Block:
                                color = Color.Red;
                                break;

                            case TerrainData.Mobility.Water:
                                color = Color.Blue;
                                break;

                            case TerrainData.Mobility.Lava:
                                color = Color.Orange;
                                break;

                            case TerrainData.Mobility.Abyss:
                                color = Color.Black;
                                break;

                            case TerrainData.Mobility.Impassable:
                                color = Color.White;
                                break;
                            }
                            if (color != Color.Transparent)
                            {
                                GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, color * 0.5f);
                            }
                        }
                    }
                }
            }
            if (ShowEntrances)
            {
                foreach (LocRay8 entrance in ZoneManager.Instance.CurrentMap.EntryPoints)
                {
                    Color showColor = Color.OrangeRed;
                    GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(entrance.Loc.X * GraphicsManager.TileSize - ViewRect.X, entrance.Loc.Y * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, showColor * 0.75f);
                }
            }

            if (TileInProgress != null)
            {
                for (int jj = viewTileRect.Y; jj < viewTileRect.End.Y; jj++)
                {
                    for (int ii = viewTileRect.X; ii < viewTileRect.End.X; ii++)
                    {
                        Loc testLoc = new Loc(ii, jj);
                        if (Collision.InBounds(ZoneManager.Instance.CurrentMap.Width, ZoneManager.Instance.CurrentMap.Height, testLoc) &&
                            TileInProgress.IncludesLoc(testLoc))
                        {
                            EffectTile tile = TileInProgress.GetBrush(testLoc);
                            if (tile.ID < 0)
                            {
                                GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, Color.Black);
                            }
                            else
                            {
                                TileData entry = DataManager.Instance.GetTile(tile.ID);
                                if (entry.Anim.AnimIndex != "")
                                {
                                    DirSheet sheet   = GraphicsManager.GetObject(entry.Anim.AnimIndex);
                                    Loc      drawLoc = new Loc(ii * GraphicsManager.TileSize, jj * GraphicsManager.TileSize) - ViewRect.Start + new Loc(GraphicsManager.TileSize / 2) - new Loc(sheet.Width, sheet.Height) / 2;
                                    sheet.DrawDir(spriteBatch, drawLoc.ToVector2(), entry.Anim.GetCurrentFrame(GraphicsManager.TotalFrameTick, sheet.TotalFrames),
                                                  entry.Anim.GetDrawDir(Dir8.None), Color.White);
                                }
                                else
                                {
                                    GraphicsManager.Pixel.Draw(spriteBatch, new Rectangle(ii * GraphicsManager.TileSize - ViewRect.X, jj * GraphicsManager.TileSize - ViewRect.Y, GraphicsManager.TileSize, GraphicsManager.TileSize), null, Color.White);
                                }
                            }
                        }
                    }
                }
            }

            spriteBatch.End();
        }