// can kill zombies as well public void CollisionWithZombie(Zombie zombie) { if (this.isOnTop(zombie)) { zombie.setZombieAlive(false); } }
// used to kill other zombies public void CollisionWithZombie(Zombie zombie) { if (this.isOnTop(zombie) && zombie.isZombieAlive()) { zombie.setZombieAlive(false); eatSound.Play(); } }
// checks if a zombie is one square away or not public bool isZombieOneSquareAway(Zombie someZombie) { return (someZombie.X + 1 == this.X || someZombie.X - 1 == this.X || someZombie.Y + 1 == this.Y || someZombie.Y - 1 == this.Y); }
private void checkForGameOver(Zombie myZombie) { if (darwin.isOnTop(myZombie)) { gameOver = true; } if (darwin.collision) { Rectangle rightSideOfDarwin = darwin.destination; rightSideOfDarwin.X = rightSideOfDarwin.X + board.getSquareWidth(); Rectangle leftSideOfDarwin = darwin.destination; leftSideOfDarwin.X = leftSideOfDarwin.X - board.getSquareWidth(); Rectangle onTopOfDarwin = darwin.destination; onTopOfDarwin.Y = onTopOfDarwin.Y - board.getSquareLength(); Rectangle onBottomOfDarwin = darwin.destination; onBottomOfDarwin.Y = onBottomOfDarwin.Y + board.getSquareLength(); if (rightSideOfDarwin == myZombie.destination || leftSideOfDarwin == myZombie.destination || onTopOfDarwin == myZombie.destination || onBottomOfDarwin == myZombie.destination) { gameOver = true; } } }