void updateDirection()
{
/*TODO: Piority Medium
* Warning, since we are updating after moving, there is a chance that
* we could fall outside of the border if there was not sufficent time between
* two clock ticks. Improvement: Move only until the border coordinate max, and if there is an excess,
* move the excess in the opposite direction
*
*/
if (this.transform.position.x + this.radius >= this.rightBorder || this.transform.position.x - this.radius <= this.leftBorder){
this.angle = 180.0f - this.angle;
if (this.transform.position.x + this.radius >= this.rightBorder)
this.transform.position = new Vector3(this.rightBorder - this.radius, this.transform.position.y, this.transform.position.z);
if(this.transform.position.x - this.radius <= this.leftBorder)
this.transform.position = new Vector3(this.leftBorder + this.radius, this.transform.position.y, this.transform.position.z);
}
if (this.transform.position.y + this.radius >= this.topBorder){
this.isMoving = false;
if (collisionDelegate != null){
collisionDelegate(this.gameObject);
}
}
}