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); }
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; }
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); }
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; }
private void AddMovingObject(MovingObjects obj) { this.movingObjects.Add(obj); this.allObjects.Add(obj); }