public Vector2 CollisionCheck(int ID)
{
Vector2 status = new Vector2(0, 0);
Vector2 Detection = new Vector2(0,0);
int SubjectNum = FindSprite(ID);
//Loop until check all objects in the Map
for (int i = 0; i < size; i++)
if (i != SubjectNum && InGame[i] && 202 != ID)
{
//Return if the Vector filled with value before start Checking
if (status.X != 0 && status.Y != 0)
return status;
Boundary = false;
Detection = CollisionDetect(SubjectNum, i);
//Collision Detected
if (Detection != new Vector2(0, 0))
{
//No boundaryCollision included
if (!Boundary)
{
//Collide with emeny means LOSE
//ID indicate Enemy, Subject has to be Character
if (200 <= IDList[i] && IDList[i] < 300 && (ID == 0 || ID == 1))
PlayerState = CharacterStatus.Lose;
//Collide with Zelda means WIN
//ID1 is Princess
else if (1 == IDList[i] && ID == 0)
PlayerState = CharacterStatus.Save;
//Collide with Exit to Next means go to next level
else if (501 == IDList[i] && ID == 0 )
PlayerState = CharacterStatus.Next;
}
//Enemies can ignore boundary
if (!(Boundary && 200 <= ID && ID < 300))
{
//Normaly only one vector returned, so put each on status
if (Detection.X != 0)
status.X = Detection.X;
if (Detection.Y != 0)
status.Y = Detection.Y;
}
}
}
return status;
}