public void CheckForCollisions() { //check if the bird is on the ground if (Bird.IsOnGround()) { GameOver(); } //the first pipe in pipes that has a value of true for IsCentered() (otherwise var is null value) var centeredPipe = Pipes.FirstOrDefault(p => p.IsCentered()); //if there is a pipe in the center collision zone... if (centeredPipe != null) { //true if the bottom of the bird's distance to ground is beneath the bottom of the gap minus the height of the ground bool hasCollidedWithBottom = Bird.DistanceFromGround < centeredPipe.GapBottom - 150; //true if the top of the bird's distance to the ground is greater than the top of the gap minus the ground height bool hasCollidedWithTop = Bird.DistanceFromGround + 45 > centeredPipe.GapTop - 150; if (hasCollidedWithBottom || hasCollidedWithTop) { GameOver(); } } }
private void CheckForCollisions() { if (Bird.IsOnGround()) { GameOver(); } // 1. Check for a pipe in the middle var centeredPipe = Pipes.FirstOrDefault(p => p.IsCentered()); // 2. If there is a pipe, check for collisions with: if (centeredPipe != null) { bool hasCollidedWithBottom = Bird.DistanceFromGround < centeredPipe.GapBottom - 150; bool hasCollidedWithTop = Bird.DistanceFromGround + 45 > centeredPipe.GapTop - 150; if (hasCollidedWithBottom || hasCollidedWithTop) { GameOver(); } } // 2a. Bottom pipe // 2b. Top pipe }
void CheckForCollisions() { if (Bird.IsOnGround()) { GameOver(); } var centeredPipe = Pipes.FirstOrDefault(p => p.IsCentered()); if (centeredPipe != null) { bool hasColidedWithBottom = Bird.DistanceFromGround < centeredPipe.GapBottom - 150; bool hasColidedWithTop = Bird.DistanceFromGround + 45 > centeredPipe.GapTop - 150; if (hasColidedWithBottom || hasColidedWithTop) { GameOver(); } } }
public void CheckForCollision() { //Verifico se l'oggetto ha ragiunto il terreno if (Bird.IsOnGround()) { GameOver(); } var centeredPipe = Pipes.FirstOrDefault(p => p.IsCentered()); if (centeredPipe != null) { bool hasCollidedwithBottom = Bird.DistanceFromGround < centeredPipe.GapBottom - 150; bool hasCollidedwithTop = Bird.DistanceFromGround + 45 > centeredPipe.GapTop - 150; if (hasCollidedwithBottom || hasCollidedwithTop) { GameOver(); } } }
void CheckForCollisions() { if (Bird.IsONGround()) { GameOver(); } // if pipe in thw middle var ceneterdPipe = Pipes.FirstOrDefault(p => p.IsCenterd()); // check collision with if (ceneterdPipe != null) { bool hasCollidedWithBottom = Bird.DistanceFromGround < ceneterdPipe.GapBottom - 150; bool hasCollidedWithTup = Bird.DistanceFromGround + 45 > ceneterdPipe.GapTop - 150; if (hasCollidedWithBottom || hasCollidedWithTup) { GameOver(); } } }
private PipeModel GetCenteredPipe() { return(Pipes.FirstOrDefault(p => p.IsCentered())); }