Exemple #1
0
        public static Point SmallLine(int xs, int ys, Termin termin)
        {
            Point  p = new Point();
            Random rand = new Random();
            int    len = rand.Next(50, 200);
            int    xe, ye;

            xe = termin.Real_x - 15 + rand.Next(termin.Termin_x + 30);
            ye = termin.Real_y - 15 + rand.Next(termin.Termin_y + 30);

            if (Math.Pow((xe - xs), 2) + Math.Pow((ye - ys), 2) > len * len)
            {
                if (xe == xs)
                {
                    if (ye > ys)
                    {
                        ye = ys + len;
                    }
                    else
                    {
                        ye = ys - len;
                    }
                }
                else
                {
                    int len1 = (int)Math.Sqrt(Math.Pow((xe - xs), 2) + Math.Pow((ys - ye), 2));
                    xe = xs + len * (xe - xs) / len1;
                    ye = ys - len * (ys - ye) / len1;
                }
            }
            p.X = xe;
            p.Y = ye;
            return(p);
        }
Exemple #2
0
        private void Level4()
        {
            Image img = Properties.Resources.FloorIV;

            floor  = new Floor(img, -1280, 0);
            termin = new Termin(1600, 400, 320, 400, walls, eatObjectsCreater.EatObjects);
        }
Exemple #3
0
        private void Level3()
        {
            Image img = Properties.Resources.FloorIII;

            floor  = new Floor(img, -640, 0);
            termin = new Termin(740, 100, 100, 100, walls, eatObjectsCreater.EatObjects);
        }
Exemple #4
0
        private void Level2()
        {
            Image img = Properties.Resources.FloorII;

            floor  = new Floor(img, -640, -960);
            termin = new Termin(1080, 1320, 440, 360, walls, eatObjectsCreater.EatObjects);
        }
Exemple #5
0
        private void Level1()
        {
            Image img = Properties.Resources.FloorI;

            floor  = new Floor(img, 0, 0);
            termin = new Termin(200, 400, 200, 400, walls, eatObjectsCreater.EatObjects);
        }
Exemple #6
0
        private void Level5()
        {
            Image img = Properties.Resources.FloorV;

            floor  = new Floor(img, 0, -960);
            termin = new Termin(480, 1360, 480, 400, walls, eatObjectsCreater.EatObjects);
        }
Exemple #7
0
        public Model(int game)
        {
            this.game = game;
            status    = GameStatus.Playing;
            level     = new Level(game);

            floor       = level.Floor;
            walls       = level.Walls;
            termin      = level.Termin;
            enemis      = level.Enemis;
            finish      = level.Finish;
            audioString = level.AudioString;

            target       = new Target();
            plane        = new Plane();
            enemiTargets = new List <Target>();
            tempEn       = new List <Enemi>();
            real_x       = termin.Real_x - termin.X;
            real_y       = termin.Real_y - termin.Y;
        }
Exemple #8
0
        public static bool Iscross(Enemi i, Termin termin, List <Wall> walls)
        {
            int i2x, i2y, i1x, i1y;

            i1x = Math.Min(i.X + i.Enemi_x / 2, termin.Real_x + termin.Termin_x / 2);
            i1y = Math.Min(i.Y + i.Enemi_y / 2, termin.Real_y + termin.Termin_y / 2);
            i2x = Math.Abs(i.X + i.Enemi_x / 2 - termin.Real_x - termin.Termin_x / 2);
            i2y = Math.Abs(i.Y + i.Enemi_y / 2 - termin.Real_y - termin.Termin_y / 2);
            Rectangle tr  = new Rectangle(i1x, i1y, i2x, i2y);
            bool      bol = true;

            foreach (Wall j in walls)
            {
                Rectangle t1 = new Rectangle(j.X1, j.Y1, j.X2 - j.X1, j.Y2 - j.Y1);
                if (tr.IntersectsWith(t1))
                {
                    if (LineToRectFunct(j.X1, j.Y1, j.X2, j.Y2, i1x, i1y, i1x + i2x, i1y + i2y).Count > 0)
                    {
                        bol = false;
                    }
                }
            }
            return(bol);
        }