예제 #1
0
        public void LoadSheet(Game1 game)
        {
            string pathIO = Game1.content.RootDirectory.ToString() + "\\Levels";

            GameDebug.Log(pathIO);

            if (Directory.Exists(pathIO))
            {
                string[] data;

                FileStream fileStream = File.OpenRead(pathIO + "\\test.map");

                byte[] bytes = new byte[fileStream.Length];

                fileStream.Read(bytes, 0, bytes.Length);
                data = System.Text.Encoding.UTF8.GetString(bytes).Split('\n');

                if (!data[0].Contains("sheetmap"))
                {
                    throw new Exception(String.Format("Wrong Map Format"));
                }

                for (int i = 0; i < data.Length; i++)
                {
                    string match = Regex.Match(data[i], @"\[([^]]*)\]").Groups[1].Value;

                    match = match.Replace(" ", "");

                    string[] cords = match.Split(',');

                    if (cords[0].Contains("Block"))
                    {
                        Console.WriteLine("Item Found!");

                        MapItems _mapitems = new MapItems();

                    //    _mapitems.itemTile = new ItemTile(_mapitems.pos, 1f, ItemTileType.Blank);
                        _mapitems.pos = new Vector2(float.Parse(cords[1]), float.Parse(cords[2]));
                       // _mapitems.itemTile.Init(_mapitems.pos, 1f);
                      //  _mapitems.itemTile.LoadBlock();
                        _mapItemList.Add(_mapitems);

                        //GameDebug.Log((cords[3]).ToString());

                    }
                    /*     else if (cords[0].Contains("Start"))
                         {
                             GameObject.Instantiate(Startline, new Vector3(float.Parse(cords[1]), float.Parse(cords[2]), float.Parse(cords[3])), Quaternion.identity);
                         }
                         else if (cords[0].Contains("Finish"))
                         {
                             GameObject.Instantiate(Finish, new Vector3(float.Parse(cords[1]), float.Parse(cords[2]), float.Parse(cords[3])), Quaternion.identity);
                         }
                         */
                }

                // Console.WriteLine("Loaded File !");
                return;
            }
            else
            {
                // Console.WriteLine("Directory is not existing !");
                throw new Exception(String.Format("Directory is not existing !"));
            }
        }
        public static void LoadSheet(Game1 game)
        {
           // string pathIO = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "FMG_Tech\\Sheet");
           // string dirIO = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "FMG_Tech\\Sheet");
           string pathIO = Game1.content.RootDirectory.ToString() + "\\Test";

            GameDebug.Log(pathIO);

            if (Directory.Exists(pathIO))
            {
                //Exists

                string[] data;

                FileStream fileStream = File.OpenRead(pathIO + "\\test.fmgui");

                byte[] bytes = new byte[fileStream.Length];

                fileStream.Read(bytes, 0, bytes.Length);
                data = System.Text.Encoding.UTF8.GetString(bytes).Split('\n');

                if (!data[0].Contains("fmgui"))
                {
                    Console.WriteLine("Wrong format !");
                }

                for (int i = 0; i < data.Length; i++)
                {
                    string match = Regex.Match(data[i], @"\[([^]]*)\]").Groups[1].Value;

                    match = match.Replace(" ", "");

                    string[] cords = match.Split(',');

                    if (cords[0].Contains("Image"))
                    {
                        // GameObject.Instantiate(_texture2D, new Vector2(float.Parse(cords[1]), float.Parse(cords[2])));
                        Console.WriteLine("Item Found!");

                        UI _ui = new UI();
                        _ui.pos = new Vector2(float.Parse(cords[1]), float.Parse(cords[2]));
                        _ui.texture2d = game.Content.Load<Texture2D>((cords[3]));
                        _uiList.Add(_ui);

                        GameDebug.Log((cords[3]).ToString());

                    }
                    /*     else if (cords[0].Contains("Start"))
                         {
                             GameObject.Instantiate(Startline, new Vector3(float.Parse(cords[1]), float.Parse(cords[2]), float.Parse(cords[3])), Quaternion.identity);
                         }
                         else if (cords[0].Contains("Finish"))
                         {
                             GameObject.Instantiate(Finish, new Vector3(float.Parse(cords[1]), float.Parse(cords[2]), float.Parse(cords[3])), Quaternion.identity);
                         }
                         */
                }

                //  Debug.Log("loaded");
                Console.WriteLine("Loaded File !");
                return;
            }
            else
            {
                //    Debug.LogError("Directory is not existing");
                Console.WriteLine("Directory is not existing !");
            }
        }
예제 #3
0
 static void Main()
 {
     using (var game = new Game1())
         game.Run();
 }