/// <summary> /// To do: Make this part more understandable; /// Determines the screen coordinate that the destination arrow is set at /// And store the value at a local variable /// </summary> /// <param name="direction">Calculate which direction?</param> void intersection(CONSTANTS.DIRECTION direction) { screen_intersect.y = 5; switch (direction) { case CONSTANTS.DIRECTION.UP://Top float x = (destinPosition.x - thisPosition.x) * (heightCamViewBoundHalved) / (destinPosition.z - thisPosition.z) + thisPosition.x; if (x >= leftCamViewBound && x <= rightCamViewBound) { screen_intersect.x = x; screen_intersect.z = topCamViewBound; } break; case CONSTANTS.DIRECTION.RIGHT://Right float z = (destinPosition.z - thisPosition.z) * (widthCamViewBoundHalved) / (destinPosition.x - thisPosition.x) + thisPosition.z; if (z >= lowerCamViewBound && z <= topCamViewBound) { screen_intersect.x = rightCamViewBound; screen_intersect.z = z; } break; case CONSTANTS.DIRECTION.DOWN://Bottom x = (destinPosition.x - thisPosition.x) * (-heightCamViewBoundHalved) / (destinPosition.z - thisPosition.z) + thisPosition.x; if (x >= leftCamViewBound && x <= rightCamViewBound) { screen_intersect.x = x; screen_intersect.z = lowerCamViewBound; } break; case CONSTANTS.DIRECTION.LEFT://Left z = (destinPosition.z - thisPosition.z) * (-widthCamViewBoundHalved) / (destinPosition.x - thisPosition.x) + thisPosition.z; if (z >= lowerCamViewBound && z <= topCamViewBound) { screen_intersect.x = leftCamViewBound; screen_intersect.z = z; } break; } }
public void setEntranceDir(CONSTANTS.DIRECTION dir) { switch (dir) { case CONSTANTS.DIRECTION.UP: entrance_direction = 90; break; case CONSTANTS.DIRECTION.DOWN: entrance_direction = -90; break; case CONSTANTS.DIRECTION.RIGHT: entrance_direction = 180; break; case CONSTANTS.DIRECTION.LEFT: entrance_direction = 0; break; } }