//to check collisions of contained by wall private bool CheckRoom(ScreenModel CheckArg) { bool Test = false; for(int cntr=0; cntr<CheckArg.ListOfWalls.Count; cntr++) { if (this.CollisionType == ObjectTypes.Box) { if (this.MovingBox.Intersects(CheckArg.ListOfWalls[cntr]) == PlaneIntersectionType.Intersecting) Test = true; //if result is true, break loop early, saves time if (Test) break; } if (this.CollisionType == ObjectTypes.Sphere) { Test = this.CheckBoundingSpheres(CheckArg.ListOfWalls[cntr]); if (Test) break; } //oddly enough, two planes can't intersect each other...no intersect() overload /* if (this.CollisionType == ObjectTypes.Plane) { for (int cntr2 = 0; cntr2 < CheckArg.ListOfWalls.Count; cntr2++) { if (this.ListOfWalls[cntr].Intersects(CheckArg.ListOfWalls[cntr2]) == PlaneIntersectionType.Intersecting) { this.ListOfWalls[cntr].Intersects( Test = true; } if (Test) break; } if (Test) break; }*/ } return(Test); }
//uses a series of checks to determine the best method to call for checking collisions, based on the collision type selected public bool CheckCollision(ScreenModel CheckArg) { bool Test = false; if (CheckArg.CollisionType == ObjectTypes.Box) { if (this.CollisionType == ObjectTypes.Box) { Test = this.MovingBox.Intersects(CheckArg.MovingBox); } if (this.CollisionType == ObjectTypes.Sphere) { Test = this.CheckBoundingSpheres(CheckArg.MovingBox); } } else if(CheckArg.CollisionType == ObjectTypes.Sphere) { if (this.CollisionType == ObjectTypes.Box) { Test = this.MovingBox.Intersects(CheckArg.GetBoundingSpheres()); } if (this.CollisionType == ObjectTypes.Sphere) { Test = this.CheckBoundingSpheres(CheckArg.GetBoundingSpheres()); } } else if (CheckArg.CollisionType == ObjectTypes.Room) { Test = this.CheckRoom(CheckArg); } return (Test); }