Пример #1
0
        public static int VerticalCollisionIndex(MovingObjects moving, List <GameObject> objects)
        {
            List <MatrixCoordinates> profile = moving.GetCollisionProfile();

            List <MatrixCoordinates> verticalProfile = new List <MatrixCoordinates>();

            foreach (var coord in profile)
            {
                verticalProfile.Add(new MatrixCoordinates(coord.Row + moving.Speed.Row, coord.Col));
            }

            int collisionIndex = GetCollisionIndex(moving, objects, verticalProfile);

            return(collisionIndex);
        }
Пример #2
0
        public static int VerticalCollisionIndex(MovingObjects moving, List<GameObject> objects)
        {
            List<MatrixCoordinates> profile = moving.GetCollisionProfile();

            List<MatrixCoordinates> verticalProfile = new List<MatrixCoordinates>();

            foreach (var coord in profile)
            {
                verticalProfile.Add(new MatrixCoordinates(coord.Row + moving.Speed.Row, coord.Col));
            }

            int collisionIndex = GetCollisionIndex(moving, objects, verticalProfile);

            return collisionIndex;
        }
Пример #3
0
        private static int GetCollisionIndex(MovingObjects moving, ICollection <GameObject> objects, List <MatrixCoordinates> movingProfile)
        {
            int collisionIndex = 0;

            foreach (var obj in objects)
            {
                if (moving.CanCollideWith(obj.GetCollisionGroupString()) || obj.CanCollideWith(moving.GetCollisionGroupString()))
                {
                    List <MatrixCoordinates> objProfile = obj.GetCollisionProfile();

                    if (ProfilesIntersect(movingProfile, objProfile))
                    {
                        return(collisionIndex);
                    }
                }

                collisionIndex++;
            }

            return(-1);
        }
Пример #4
0
        private static int GetCollisionIndex(MovingObjects moving, ICollection<GameObject> objects, List<MatrixCoordinates> movingProfile)
        {
            int collisionIndex = 0;

            foreach (var obj in objects)
            {
                if (moving.CanCollideWith(obj.GetCollisionGroupString()) || obj.CanCollideWith(moving.GetCollisionGroupString()))
                {
                    List<MatrixCoordinates> objProfile = obj.GetCollisionProfile();

                    if (ProfilesIntersect(movingProfile, objProfile))
                    {
                        return collisionIndex;
                    }
                }

                collisionIndex++;
            }

            return -1;
        }
Пример #5
0
 private void AddMovingObject(MovingObjects obj)
 {
     this.movingObjects.Add(obj);
     this.allObjects.Add(obj);
 }
Пример #6
0
 private void AddMovingObject(MovingObjects obj)
 {
     this.movingObjects.Add(obj);
     this.allObjects.Add(obj);
 }