Example #1
0
        public bool CheckCollision(tileClass obj) //checks collision
        {
            int PosXAy = obj.TileX;

            int PosYAy = obj.TileY;

            Obj = new Rectangle(PosXAy, PosYAy, 50, 50);

            coli = Rectangle.Intersect(itemFrame, Obj);

            if (!coli.IsEmpty)
            {
                colState = true;
            }

            return(colState);
        }
Example #2
0
        /// <summary>
        /// This method should build a basic level for now
        /// </summary>
        private void textTile()
        {
            int XX = 0;

            int YY = 0;

            tileClass t1;

            rects.Clear();

            try
            {
                level = new StreamReader("Content/levelText.txt");

                string line = null;

                int count = File.ReadLines("Content/levelText.txt").Count();

                YY = GraphicsDevice.Viewport.Height - (count * 50);

                while ((line = level.ReadLine()) != null)
                {
                    XX = 0;

                    int length = line.Length;

                    for (int i = 0; i < length; i++)
                    {
                        //int tileRNG = rng.Next(1, 4);

                        if (line[i] == 'A')
                        {
                            t1 = new tileClass(XX, YY, 50, 50, tileA);

                            rects.Add(t1);
                        }
                        if (line[i] == 'B')
                        {
                            if (spawnCount == 1)
                            {
                                enemy1 = new Character(XX, YY, 100, 100, 1, 1, 1);
                            }
                            else if (spawnCount == 2)
                            {
                                enemy2 = new Character(XX, YY, 100, 100, 1, 1, 1);
                            }

                            spawnCount++;
                        }
                        if (line[i] == 'C')
                        {
                        }

                        XX += 50;
                    }

                    YY += 50;
                }

                level.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("File is icompatible; Loop may not work");
                Console.WriteLine(e.Message);
            }
        }
Example #3
0
        private void textTile()
        {
            int XX = 0;

            int YY = 0;

            tileClass t1;
            tileClass t2;
            tileClass t3;

            rects.Clear();

            try
            {
                level = new StreamReader("Content/levelText.txt");

                string line = null;

                int count = File.ReadLines("Content/levelText.txt").Count();

                YY = GraphicsDevice.Viewport.Height - (count * 50);

                while ((line = level.ReadLine()) != null)
                {
                    XX = 0;

                    int length = line.Length;

                    for (int i = 0; i < length; i++)
                    {
                        //int tileRNG = rng.Next(1, 4);

                        if (line[i] == 'A')
                        {
                            t1 = new tileClass(XX, YY, 50, 50, tileA);

                            rects.Add(t1);
                        }
                        if (line[i] == 'B')
                        {
                            t2 = new tileClass(XX, YY, 50, 50, tileB);

                            rects.Add(t2);
                        }
                        if (line[i] == 'C')
                        {
                            t3 = new tileClass(XX, YY, 50, 50, tileC);

                            rects.Add(t3);
                        }

                        XX += 50;
                    }

                    YY += 50;
                }

                level.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("File is icompatible; Loop may be absolute s***e");
                Console.WriteLine(e.Message);
            }
        }
Example #4
0
        private void textTile()
        {
            int XX = 0;

            int YY = 0;

            tileClass t1;
            tileClass t2;
            tileClass t3;

            rects.Clear();

            try
            {
                StreamReader level = new StreamReader("levelText.txt");

                String line = null;

                while ((line = level.ReadLine()) != null)
                {
                    int length = line.Length;

                    while ((line = level.ReadLine()) != null)
                    {
                        XX = 0;

                        for (int i = 0; i <= length; i++)
                        {
                            //int tileRNG = rng.Next(1, 4);

                            if (line[i] == 'A')
                            {
                                t1 = new tileClass(XX, YY, 50, 50, tileA);

                                rects.Add(t1);
                            }
                            if (line[i] == 'B')
                            {
                                t2 = new tileClass(XX, YY, 50, 50, tileB);

                                rects.Add(t2);
                            }
                            if (line[i] == 'C')
                            {
                                t3 = new tileClass(XX, YY, 50, 50, tileC);

                                rects.Add(t3);
                            }

                            if (i == length)
                            {
                                YY += 50;
                            }

                            XX += 50;
                        }
                    }
                }

                level.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("File is icompatible; Loop may be absolute s***e");
                Console.WriteLine(e.Message);
            }
        }