예제 #1
0
        public void CreateLevel()
        {
            currentLevel++;
            if (currentLevel > 3)
                currentLevel = 1;
            blocks = new List<Block>();
            string[] s = File.ReadAllLines("content/levels/level" + currentLevel + ".txt");

            levelLength = blcSize * s[0].Length - 400;
            int x = 0;
            int y = 0;
            foreach (string str in s)
            {
                foreach (char c in str)
                {
                    Rectangle rect = new Rectangle(x, y, blcSize, blcSize);
                    if (c == 'X')
                    {

                        Block block = new Block(rect, blockTexture1);
                        blocks.Add(block);
                    }
                    if (c == 'Y')
                    {
                        Block block = new Block(rect, blockTexture2);
                        blocks.Add(block);
                    }
                    x += blcSize;
                }
                x = 0;
                y += blcSize;
            }

            //Пробую итемы
            items = new List<Item>();
            string[] s1 = File.ReadAllLines("content/levels/level" + currentLevel + ".txt");

            x = 0;
            y = 0;
            foreach (string str in s)
            {
                foreach (char c in str)
                {
                    Rectangle rect = new Rectangle(x, y, blcSize, blcSize);
                    if (c == 'F')
                    {
                        Item graal = new Item(rect, finishTexture);
                        items.Add(graal);
                    }
                    if (c == 'C')
                    {
                        Item graal = new Item(rect, coinTexture);
                        items.Add(graal);
                    }
                    x += blcSize;
                }
                x = 0;
                y += blcSize;
            }
        }
예제 #2
0
        public void CreateLevel()
        {
            currentLevel++;
            if (currentLevel > 3)
                currentLevel = 1;
            blocks = new List<Block>();
            string[] s = File.ReadAllLines("content/levels/level" + currentLevel + ".txt");

            levelLength = 40 * s[0].Length;
            int x = 0;
            int y = 0;
            foreach (string str in s)
            {
                foreach (char c in str)
                {
                    Rectangle rect = new Rectangle(x, y, 40, 40);
                    if (c == 'X')
                    {

                        Block block = new Block(rect, blockTexture1);
                        blocks.Add(block);
                    }
                    if (c == 'Y')
                    {
                        Block block = new Block(rect, blockTexture2);
                        blocks.Add(block);
                    }
                    x += 40;
                }
                x = 0;
                y += 40;
            }
        }
예제 #3
0
 public void DestroyBlock(Rectangle rect)
 {
     Block block = new Block(rect, blockTexture1);
     Rectangle place = rect;
     foreach (Block bl in blocks)
     {
         if (bl.rect==rect)
         {
             //blocks.RemoveAt(blocksPlaces);
         }
     }
 }