void Update()
{
if (isMoving){
this.transform.Translate(Vector3.right * this.linearSpeed * Mathf.Cos(Mathf.Deg2Rad *this.angle) * Time.deltaTime);
this.transform.Translate(Vector3.up * this.linearSpeed * Mathf.Sin(Mathf.Deg2Rad *this.angle) * Time.deltaTime);
if (this.motionDelegate != null){
if (!this.motionDelegate(this.transform.position)){
// revert position
this.transform.Translate(Vector3.left * this.linearSpeed * Mathf.Cos(Mathf.Deg2Rad *this.angle) * Time.deltaTime);
this.transform.Translate(Vector3.down * this.linearSpeed * Mathf.Sin(Mathf.Deg2Rad *this.angle) * Time.deltaTime);
this.isMoving = false;
if (collisionDelegate != null)
{
collisionDelegate(this.gameObject);
}
}
else
{
this.updateDirection();
}
}
}
}