// Checks if this Ball collided with another. public bool CollidedWith(Ball otherBall) { float collisionDist = this.size + otherBall.size; float dist = Vector3.Distance(this.pos, otherBall.pos); if (dist > collisionDist) { return false; } return true; }
public override void Collide(Ball otherBall) { if (this.size < otherBall.size) { // move somewhere else this.pos = game.landscape.getStartPoint(); // reduce size and decrease score Grow(-otherBall.size); game.score -= (int)(otherBall.size * game.scoreMultiplier); } else if (this.size >= otherBall.size) { // move other ball somewhere else otherBall.pos = game.landscape.getStartPoint(); // grow and increase score Grow(otherBall.size); game.score += (int)(otherBall.size * game.scoreMultiplier); } }
public override void Collide(Ball otherBall) { if (this.size == otherBall.size) { return; } if (this.size < otherBall.size) { // move somewhere else this.pos = game.landscape.getStartPoint(); } if (this.size > otherBall.size) { return; } }
public abstract void Collide(Ball otherBall);