コード例 #1
0
        public void TestCutStringLevel()
        {
            string[] x = new[]
            { "1", "2", "3", "4", "5", "6", "7", "8", "9", "1", "2", "3", "4",
              "5", "6", "7", "8", "9", "1", "2", "3", "4", "5", null };

            Assert.AreEqual(
                Opener.CutStringLevel(
                    "/Users/Muse/Desktop/su19-mikaelMuseFrederik/SU19-exercises/" +
                    "TestSpaceTaxi/Levels/123.txt"),
                x);
        }
コード例 #2
0
ファイル: CustomerInfo.cs プロジェクト: montymse/SpaceTaxi
        public static Tuple <float, float> PickupPosition(string filename)
        {
            Tuple <int, int> x = Pick(filename);

            string[]             map      = Opener.CutStringLevel(filename);
            char                 d        = map[x.Item2][x.Item1];
            int                  xaxispos = (x.Item1 + map[x.Item2].IndexOf(d)) / 2;
            float                xpos     = ((float)1 / map[0].Length) * xaxispos;
            float                ypos     = 1f - x.Item2 * ((float)1 / (map.Length - 1));
            Tuple <float, float> z        = new Tuple <float, float>(xpos, ypos);

            return(z);
        }
コード例 #3
0
ファイル: CustomerInfo.cs プロジェクト: montymse/SpaceTaxi
        private static Tuple <int, int> Pick(string filename)
        {
            Tuple <int, int> x = new Tuple <int, int>(0, 0);

            string[] file = Opener.CutStringLevel(filename);
            for (int i = 0; i < file.Length - 1; i++)
            {
                for (int j = 0; j < file[i].Length; j++)
                {
                    {
                        if (file[i][j] ==
                            CustomerInfo.SplitCustomerInfo(filename)[3].ToCharArray()[0])
                        {
                            x = new Tuple <int, int>(j, i);
                        }
                    }
                }
            }

            return(x);
        }
コード例 #4
0
ファイル: Platforms.cs プロジェクト: montymse/SpaceTaxi
        /// <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);
        }