Esempio n. 1
0
 public void TestFileToString()
 {
     Assert.AreEqual(
         Opener.FileToString(
             "/Users/Muse/Desktop/su19-mikaelMuseFrederik/SU19-exercises/TestSpaceTaxi/" +
             "Levels/abc.txt"),
         "abcdefghijklmnopqrstuvwyz"
         );
 }
Esempio n. 2
0
        public void TestStringToImageList()
        {
            List <Tuple <string, string> > x = new List <Tuple <string, string> >();

            x.Add(new Tuple <string, string>("%)", " white-square.png"));
            x.Add(new Tuple <string, string>("#)", " ironstone-square.png"));
            x.Add(new Tuple <string, string>("1)", " neptune-square.png"));
            x.Add(new Tuple <string, string>("2)", " green-square.png"));
            x.Add(new Tuple <string, string>("3)", " yellow-stick.png"));
            x.Add(new Tuple <string, string>("o)", " purple-circle.png"));


            Assert.AreEqual(
                ImageList.StringToImageList(Opener.FileToString(
                                                "/Users/Muse/Desktop/su19-mikaelMuseFrederik/SU19-exercises/TestSpaceTaxi/" +
                                                "Levels/imagetest.txt")
                                            ), x);
        }
Esempio n. 3
0
        /// <summary>
        /// finds the related image file and positions of all the platforms in the given levelfile
        /// </summary>
        /// <param name="textfile">
        /// level file
        /// </param>
        /// <returns>
        /// the related image file and positions of all the platforms in the level
        /// </returns>

        public static List <Tuple <Tuple <float, float>, string> > GetPlatform(string textfile)
        {
            string[] platformNames = CollisionPlatforms.Platforms(textfile);

            string[] text =
                Opener.CutStringLevel(textfile);

            Tuple <float, float>           mapSize  = Placement.CalculateMapSize(text);
            List <Tuple <string, string> > textures =
                ImageList.StringToImageList(Opener.FileToString(
                                                textfile));
            List <Tuple <Tuple <float, float>, string> > places =
                new List <Tuple <Tuple <float, float>, string> >();

            for (int y = 0; y < text.Length - 1; y++)
            {
                for (int x = 0; x < text[y].Length; x++)
                {
                    //The condition of the if statement bellow is where
                    //Placement.FindPlacementAndImage and GetPlatform are different
                    if (platformNames.Contains(text[y][x].ToString()))
                    {
                        foreach (Tuple <string, string> item in textures)
                        {
                            if (item.Item1.Contains(text[y][x].ToString()))
                            {
                                Tuple <float, float> z = Placement.Convert(x, y, mapSize);
                                places.Add(new Tuple <Tuple <float, float>,
                                                      string>(Placement.Convert(x, y, mapSize), item.Item2));
                            }
                        }
                    }
                }
            }


            return(places);
        }