コード例 #1
0
ファイル: ProjectExportEGL.cs プロジェクト: farlei/libEGL
        private void CreateFile(ProjectExportEGLRegion map)
        {
            for (j = 0; j < map.layers.Length; j++)
            {
                ProjectExportEGLLayer lyrs = map.layers[j];
                using (StreamWriter fs = new StreamWriter(path_export + "\\" + FormatName(map.name) + "_" + FormatName(lyrs.name) + ".txt"))
                {
                    fs.Write(map.map_w);
                    fs.Write(" ");
                    fs.WriteLine(map.map_h);
                    fs.Write(map.tile_w);
                    fs.Write(" ");
                    fs.WriteLine(map.tile_h);

                    Dictionary<int, int> troca_code = new Dictionary<int,int>();
                    for (int k = 0; k < lyrs.idx_img.Count; k++)
                    {
                        if (!troca_code.ContainsKey(lyrs.idx_img[k]))
                        {
                            troca_code.Add(lyrs.idx_img[k], k);
                            fs.WriteLine(k + " " + path_image + name_image + lyrs.idx_img[k] + ".png");
                        }
                    }

                    fs.WriteLine("*");

                    int p;
                    for (int k = 0; k < lyrs.matrix.GetLength(1); k++)
                    {
                        for (int u = 0; u < lyrs.matrix.GetLength(0); u++)
                        {
                            if (troca_code.ContainsKey(lyrs.matrix[u, k]))
                            {
                                p = troca_code[lyrs.matrix[u, k]];
                            }
                            else
                            {
                                p = lyrs.matrix[u, k];
                            }
                            if ((u + 1) == lyrs.matrix.GetLength(0))
                            {
                                fs.WriteLine(p);
                            }
                            else
                            {
                                fs.Write(p);
                                fs.Write(" ");
                            }

                        }
                    }

                    fs.WriteLine("*");
                    for (int k = 0; k < lyrs.walks.GetLength(1); k++)
                    {
                        for (int u = 0; u < lyrs.walks.GetLength(0); u++)
                        {
                            if ((u + 1) == lyrs.walks.GetLength(0))
                            {
                                fs.WriteLine(lyrs.walks[u, k]);
                            }
                            else
                            {
                                fs.Write(lyrs.walks[u, k]);
                                fs.Write(" ");
                            }
                        }
                    }

                    fs.WriteLine("*");
                    for (int k = 0; k < lyrs.events.GetLength(1); k++)
                    {
                        for (int u = 0; u < lyrs.events.GetLength(0); u++)
                        {
                            if ((u + 1) == lyrs.events.GetLength(0))
                            {
                                fs.WriteLine(lyrs.events[u, k]);
                            }
                            else
                            {
                                fs.Write(lyrs.events[u, k]);
                                fs.Write(" ");
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: ProjectExportEGL.cs プロジェクト: robsonmwoc/libEGL
        private void CreateFile(ProjectExportEGLRegion map)
        {
            for (j = 0; j < map.layers.Length; j++)
            {
                ProjectExportEGLLayer lyrs = map.layers[j];
                using (StreamWriter fs = new StreamWriter(path_export + "\\" + FormatName(map.name) + "_" + FormatName(lyrs.name) + ".txt"))
                {
                    fs.Write(map.map_w);
                    fs.Write(" ");
                    fs.WriteLine(map.map_h);
                    fs.Write(map.tile_w);
                    fs.Write(" ");
                    fs.WriteLine(map.tile_h);

                    Dictionary <int, int> troca_code = new Dictionary <int, int>();
                    for (int k = 0; k < lyrs.idx_img.Count; k++)
                    {
                        if (!troca_code.ContainsKey(lyrs.idx_img[k]))
                        {
                            troca_code.Add(lyrs.idx_img[k], k);
                            fs.WriteLine(k + " " + path_image + name_image + lyrs.idx_img[k] + ".png");
                        }
                    }

                    fs.WriteLine("*");

                    int p;
                    for (int k = 0; k < lyrs.matrix.GetLength(1); k++)
                    {
                        for (int u = 0; u < lyrs.matrix.GetLength(0); u++)
                        {
                            if (troca_code.ContainsKey(lyrs.matrix[u, k]))
                            {
                                p = troca_code[lyrs.matrix[u, k]];
                            }
                            else
                            {
                                p = lyrs.matrix[u, k];
                            }
                            if ((u + 1) == lyrs.matrix.GetLength(0))
                            {
                                fs.WriteLine(p);
                            }
                            else
                            {
                                fs.Write(p);
                                fs.Write(" ");
                            }
                        }
                    }

                    fs.WriteLine("*");
                    for (int k = 0; k < lyrs.walks.GetLength(1); k++)
                    {
                        for (int u = 0; u < lyrs.walks.GetLength(0); u++)
                        {
                            if ((u + 1) == lyrs.walks.GetLength(0))
                            {
                                fs.WriteLine(lyrs.walks[u, k]);
                            }
                            else
                            {
                                fs.Write(lyrs.walks[u, k]);
                                fs.Write(" ");
                            }
                        }
                    }

                    fs.WriteLine("*");
                    for (int k = 0; k < lyrs.events.GetLength(1); k++)
                    {
                        for (int u = 0; u < lyrs.events.GetLength(0); u++)
                        {
                            if ((u + 1) == lyrs.events.GetLength(0))
                            {
                                fs.WriteLine(lyrs.events[u, k]);
                            }
                            else
                            {
                                fs.Write(lyrs.events[u, k]);
                                fs.Write(" ");
                            }
                        }
                    }
                }
            }
        }