Esempio n. 1
0
        //Столкновени верхней грани с обьектами
        private bool IsCollideUp(List <BBox> items)
        {
            bool res  = false;
            BBox self = GetBounds();

            self.Y     += self.Height;
            self.Height = 1;
            for (int i = 0; i < items.Count; i++)
            {
                if (self.Intersects(items[i]))
                {
                    res = true;
                    break;
                }
            }
            return(res);
        }
Esempio n. 2
0
        public List <BBox> GetBounds()
        {
            List <BBox> items = new List <BBox>();

            for (int i = 0; i < passField.GetLength(1); i++)
            {
                for (int j = 0; j < passField.GetLength(0); j++)
                {
                    if (passField[j, i] != 0)
                    {
                        int   di  = field.GetLength(1) - i - 1;
                        float x   = j * H;
                        float y   = di * H;
                        BBox  box = new BBox(x, y, H, H, ObjectType.Level, 0);
                        items.Add(box);
                    }
                }
            }
            return(items);
        }
Esempio n. 3
0
        //Общие столкновения
        private bool IsCollide(List <BoundingBox> items)
        {
            bool        res  = false;
            BoundingBox self = new BoundingBox(_pos.X, MainGame.Height - _pos.Y, _texture.Width - _texture.Height,
                                               _texture.Height, ObjectType.Bullet, _id);

            for (int i = 0; i < items.Count; i++)
            {
                if (self.Intersects(items[i]))
                {
                    if (items[i].type == ObjectType.Person)
                    {
                        Memory.PersonsId.Add(items[i].id);
                    }
                    res = true;
                    break;
                }
            }
            return(res);
        }
Esempio n. 4
0
        //Воздействие силы тяжести
        private bool IsFlyUp(List <BBox> items)
        {
            bool res  = false;
            BBox self = GetBounds();

            self.Height = 1;
            self.Y     -= 1;
            for (int i = 0; i < items.Count; i++)
            {
                if (self.Intersects(items[i]))
                {
                    res = true;
                    break;
                }
            }
            if (self.Y < 0)
            {
                res = true;
            }
            return(!res);
        }
Esempio n. 5
0
        //Общие столкновения
        private bool IsCollide(List <BBox> items)
        {
            bool res  = false;
            BBox self = GetBounds();

            for (int i = 0; i < items.Count; i++)
            {
                if (self.Intersects(items[i]))
                {
                    res = true;
                    break;
                }
            }
            if (position.X + GetBounds().Width >= MainGame.LevelWidth)
            {
                res = true;
            }
            if (position.X < 0 || position.Y < 0)
            {
                res = true;
            }
            return(res);
        }
Esempio n. 6
0
        //Возврат границы текстуры
        public BBox GetBounds()
        {
            BBox box = new BBox(pos.X, pos.Y, texture.Width, texture.Height, ObjectType.Level, 0);

            return(box);
        }
Esempio n. 7
0
        //Возврат границы спрайта
        public BBox GetBounds()
        {
            BBox bnd = new BBox(pos.X, pos.Y, minWidth, rect.Height, ObjectType.Person, 0);

            return(bnd);
        }