Exemplo n.º 1
0
 // can kill zombies as well
 public void CollisionWithZombie(Zombie zombie)
 {
     if (this.isOnTop(zombie))
     {
         zombie.setZombieAlive(false);
     }
 }
Exemplo n.º 2
0
 // used to kill other zombies
 public void CollisionWithZombie(Zombie zombie)
 {
     if (this.isOnTop(zombie) && zombie.isZombieAlive())
     {
         zombie.setZombieAlive(false);
         eatSound.Play();
     }
 }
Exemplo n.º 3
0
        // 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);

        }
Exemplo n.º 4
0
        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;
                }
            }
        }