Exemplo n.º 1
0
        /**
         * moves zombie in the direction that brain currently is
         * */
        public void moveTowardsBrain(Brain brain, Darwin darwin)
        {
            int changeX = 0;
            int changeY = 0;

            changeX = brain.X - this.X;
            changeY = brain.Y - this.Y;

            if (Math.Abs(changeX) > Math.Abs(changeY))
            {
                //move in x direction
                if (brain.X > this.X)
                {
                    //move right
                    if (isZombieInRange(this.X + 1, this.Y))
                    {
                        // checks for board position to be open
                        if (board.isGridPositionOpen(this.X + 1, this.Y) || (darwin.X==this.X+1 && darwin.Y==this.Y && !darwin.isZombie()))
                            MoveRight();
                    }
                }
                else if (brain.X < this.X)
                {
                    //move left
                    if (isZombieInRange(this.X - 1, this.Y))
                    {
                        // checks for board position to be open or occupied by brain
                        if (board.isGridPositionOpen(this.X - 1, this.Y) || (darwin.X == this.X - 1 && darwin.Y == this.Y && !darwin.isZombie()))
                            MoveLeft();
                    }
                }
            }
            else
            {
                //move in y direction
                if (brain.Y > this.Y)
                {
                    //move down
                    if (isZombieInRange(this.X, this.Y + 1))
                    {
                        // checks for board position to be open or occupied by brain
                        if (board.isGridPositionOpen(this.X, this.Y + 1) || (darwin.X==this.X && darwin.Y==this.Y+1 && !darwin.isZombie()))
                            MoveDown();
                    }
                }
                else if (brain.Y < this.Y)
                {
                    //move up
                    if (isZombieInRange(this.X, this.Y - 1))
                    {
                        // checks for board position to be open or occupied by brain
                        if (board.isGridPositionOpen(this.X, this.Y - 1) || (darwin.X == this.X && darwin.Y == this.Y-1 && !darwin.isZombie()))
                            MoveUp();
                    }
                }
            }
        }
Exemplo n.º 2
0
        // update to be used for levels with a brain in them
        public void Update(GameTime gameTime,Darwin darwin,Brain brain)
        {
            //testRun();

            if (this.isZombieAlive())
            {
                base.Update(gameTime);

                if (movecounter > ZOMBIE_MOVE_RATE)
                {
                    if (isRangeDetectionAllowed() && isBrainInRange(brain))
                    {
                        this.source.X = 64;
                        moveTowardsBrain(brain, darwin);
                    }
                    else if (isRangeDetectionAllowed() && isDarwinInRange(darwin) && !darwin.isZombie())
                    {
                        this.source.X = 64;
                        this.enemyAlert = true;
                        moveTowardsDarwin(darwin);
                    }
                    else
                    {
                        if (enemyAlert)
                        {
                            source.X = 128;
                            enemyAlertCount++;
                            if (enemyAlertCount > 2)
                            {
                                enemyAlert = false;
                                enemyAlertCount = 0;
                            }
                        }
                        else
                            this.source.X = 0;

                        this.RandomWalk();
                    }

                    movecounter = 0;
                }
                movecounter++;
            }
        }
Exemplo n.º 3
0
 /**
  *  checks whether or not brain is in the zombies range
  *  returns true if he is, false otherwise
  */
 public bool isBrainInRange(Brain brain)
 {
     if (brain.X <= maxX && brain.X >= minX && brain.Y >= minY && brain.Y <= maxY)
         return true;
     else
         return false;
 }
Exemplo n.º 4
0
        public void Update(GameTime gametime, Darwin darwin, Brain brain)
        {
            //base.Update(gametime, darwin, brain);
            if (movecounter > ZOMBIE_MOVE_RATE)
            {
                // if the zombie is not sleeping
                if (!this.isSleeping())
                {
                    if (!chasingDarwin)
                        this.goToLeaf(brokenLeaf);

                    if (this.isOnTop(brokenLeaf))
                        lookForDarwin(darwin);
                }

                movecounter = 0;
            }

            movecounter++;
        }
Exemplo n.º 5
0
        public void Initialize()
        {
            gameOverPosition.X = 320;
            gameOverPosition.Y = 130;

            device = graphics.GraphicsDevice;

            gameState = new GameState();
            gameState.setState(GameState.state.Start);
            gameStart = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight);

            board = new GameBoard(new Vector2(33, 25), new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight));
            darwin = new Darwin(board);
            firstZombie = new Zombie(10, 10, 15, 5, 15, 5, board);
            //secondZombie = new Zombie(10, 16, 15, 5, 15, 5, board);
            //thirdZombie = new Zombie(16, 10, 15, 5, 15, 5, board);

            fastZombie1 = new FastZombie(15, 15, board.getNumSquaresX(), 0, board.getNumSquaresY(), 0, board);

            this.leaves = new LinkedList<Leaf>();

            for (int i = 0; i < leafCount; i++)
            {
                this.leaves.AddLast(new Leaf(board, fastZombie1));
            }

            String zombieString = "This a zombie,\n don't near him \nas a human!!";
            zombieMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, zombieString);

            String darwinString = "This is darwin,\n move with arrows, \n z to transform, \n a for actions";
            darwinMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, darwinString);

            String switchString = "This is a switch\n face it and press A\n to see what happens!!";
            switchMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, switchString);

            String brainString = "Move the brain as a \nzombie.\n Zombie's like brains!!";
            brainMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, brainString);

            String fastString = "This one likes\n to sleep.\n Be careful\n not to wake him!!";
            fastMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, fastString);

            secondStair = new Stairs(board);

            brain = new Brain(board, 5, 18);

            BasicObject[] removableWallsAroundStairs = setRemovableWallsAroundStairs();

            BasicObject[] removableWallsAroundSwitch = setRemovableWallsAroundSwitch();

            BasicObject switchSquareOne = new BasicObject(board);
            switchSquareOne.X = 30;
            switchSquareOne.Y = 2;
            firstSwitch = new Switch(switchSquareOne, board, removableWallsAroundSwitch);

            BasicObject switchSquareTwo = new BasicObject(board);
            switchSquareTwo.X = 2;
            switchSquareTwo.Y = 21;
            secondSwitch = new Switch(switchSquareTwo, board, removableWallsAroundStairs);

            darwin.setGridPosition(2, 2);

            if (board.isGridPositionOpen(darwin))
            {
                board.setGridPositionOccupied(darwin.X, darwin.Y);
                darwin.setPosition(board.getPosition(darwin).X, board.getPosition(darwin).Y);
            }

            // Darwin's lag movement
            counterReady = counter = 5;

            if (board.isGridPositionOpen(27, 21))
            {
                secondStair.setGridPosition(30, 21);
                secondStair.setDestination(board.getPosition(30, 21));
            }

            // add all the leaves to the map...
            leaves.ElementAt(0).setGridPosition(7, 7);
            leaves.ElementAt(1).setGridPosition(5, 15);
            leaves.ElementAt(2).setGridPosition(4, 2);
            leaves.ElementAt(3).setGridPosition(19, 7);
            leaves.ElementAt(4).setGridPosition(11, 21);
            leaves.ElementAt(5).setGridPosition(7, 8);
            leaves.ElementAt(6).setGridPosition(8, 17);
            leaves.ElementAt(7).setGridPosition(19, 2);
            leaves.ElementAt(8).setGridPosition(19, 1);
            leaves.ElementAt(9).setGridPosition(10, 14);
            leaves.ElementAt(10).setGridPosition(13, 4);
            leaves.ElementAt(11).setGridPosition(13, 3);
            leaves.ElementAt(12).setGridPosition(19, 16);
            leaves.ElementAt(13).setGridPosition(21, 7);
            leaves.ElementAt(14).setGridPosition(2, 16);
            leaves.ElementAt(15).setGridPosition(10, 18);
            leaves.ElementAt(16).setGridPosition(3, 16);
            leaves.ElementAt(17).setGridPosition(16, 15);
            leaves.ElementAt(18).setGridPosition(18, 8);
            leaves.ElementAt(19).setGridPosition(8, 5);
            leaves.ElementAt(20).setGridPosition(5, 7);
            leaves.ElementAt(21).setGridPosition(9, 5);
            leaves.ElementAt(22).setGridPosition(2, 6);
            leaves.ElementAt(23).setGridPosition(8, 8);
            leaves.ElementAt(24).setGridPosition(14, 6);
            leaves.ElementAt(25).setGridPosition(15, 7);
            leaves.ElementAt(26).setGridPosition(15, 8);
            leaves.ElementAt(27).setGridPosition(14, 10);
            leaves.ElementAt(28).setGridPosition(16, 18);
            leaves.ElementAt(29).setGridPosition(14, 22);
            leaves.ElementAt(30).setGridPosition(24, 2);
            leaves.ElementAt(31).setGridPosition(24, 3);
            leaves.ElementAt(32).setGridPosition(25, 6);
            leaves.ElementAt(33).setGridPosition(22, 8);
            leaves.ElementAt(34).setGridPosition(26, 6);
            leaves.ElementAt(35).setGridPosition(25, 10);
            leaves.ElementAt(36).setGridPosition(24, 11);
            leaves.ElementAt(37).setGridPosition(23, 14);
            leaves.ElementAt(38).setGridPosition(22, 17);
            leaves.ElementAt(39).setGridPosition(26, 20);
            leaves.ElementAt(41).setGridPosition(2, 22);
            leaves.ElementAt(42).setGridPosition(2, 20);
            leaves.ElementAt(43).setGridPosition(3, 21);
            leaves.ElementAt(44).setGridPosition(1, 21);
            leaves.ElementAt(45).setGridPosition(2, 18);
            leaves.ElementAt(46).setGridPosition(1, 18);
            leaves.ElementAt(47).setGridPosition(3, 18);
            leaves.ElementAt(48).setGridPosition(4, 18);
            leaves.ElementAt(49).setGridPosition(5, 19);
            leaves.ElementAt(50).setGridPosition(5, 20);
            leaves.ElementAt(51).setGridPosition(5, 21);
            leaves.ElementAt(52).setGridPosition(5, 22);
            leaves.ElementAt(53).setGridPosition(4, 1);
            leaves.ElementAt(54).setGridPosition(4, 2);
            leaves.ElementAt(55).setGridPosition(4, 3);
            leaves.ElementAt(56).setGridPosition(4, 4);
            leaves.ElementAt(57).setGridPosition(4, 5);
            leaves.ElementAt(58).setGridPosition(4, 6);
            leaves.ElementAt(59).setGridPosition(4, 7);
            leaves.ElementAt(60).setGridPosition(4, 8);
            leaves.ElementAt(61).setGridPosition(4, 9);
            leaves.ElementAt(62).setGridPosition(4, 10);
            leaves.ElementAt(63).setGridPosition(4, 11);
            leaves.ElementAt(64).setGridPosition(4, 12);
            leaves.ElementAt(65).setGridPosition(4, 13);
            leaves.ElementAt(66).setGridPosition(10, 4);
            leaves.ElementAt(67).setGridPosition(10, 5);
            leaves.ElementAt(68).setGridPosition(10, 6);
            leaves.ElementAt(69).setGridPosition(10, 7);
            leaves.ElementAt(70).setGridPosition(10, 8);
            leaves.ElementAt(71).setGridPosition(10, 9);
            leaves.ElementAt(72).setGridPosition(10, 10);
            leaves.ElementAt(73).setGridPosition(10, 11);
            leaves.ElementAt(74).setGridPosition(10, 12);
            leaves.ElementAt(75).setGridPosition(10, 13);
            leaves.ElementAt(76).setGridPosition(10, 14);
            leaves.ElementAt(77).setGridPosition(10, 15);
            leaves.ElementAt(78).setGridPosition(10, 16);
            leaves.ElementAt(79).setGridPosition(10, 17);
            leaves.ElementAt(80).setGridPosition(10, 18);
            leaves.ElementAt(81).setGridPosition(10, 19);
            leaves.ElementAt(82).setGridPosition(11, 19);
            leaves.ElementAt(83).setGridPosition(12, 19);
            leaves.ElementAt(84).setGridPosition(13, 19);
            leaves.ElementAt(85).setGridPosition(14, 19);
            leaves.ElementAt(86).setGridPosition(15, 19);
            leaves.ElementAt(87).setGridPosition(16, 19);
            leaves.ElementAt(88).setGridPosition(17, 19);
            leaves.ElementAt(89).setGridPosition(18, 19);
            leaves.ElementAt(90).setGridPosition(19, 19);
            leaves.ElementAt(91).setGridPosition(20, 19);
            leaves.ElementAt(92).setGridPosition(21, 19);
            leaves.ElementAt(93).setGridPosition(22, 19);
            leaves.ElementAt(94).setGridPosition(23, 19);
            leaves.ElementAt(95).setGridPosition(23, 18);
            leaves.ElementAt(96).setGridPosition(23, 17);
            leaves.ElementAt(97).setGridPosition(23, 16);
            leaves.ElementAt(98).setGridPosition(23, 15);
            leaves.ElementAt(99).setGridPosition(23, 14);
            leaves.ElementAt(100).setGridPosition(23, 13);
            leaves.ElementAt(101).setGridPosition(23, 12);
            leaves.ElementAt(102).setGridPosition(23, 11);
            leaves.ElementAt(103).setGridPosition(23, 10);
            leaves.ElementAt(104).setGridPosition(23, 9);
            leaves.ElementAt(105).setGridPosition(23, 8);
            leaves.ElementAt(106).setGridPosition(23, 7);
            leaves.ElementAt(107).setGridPosition(23, 6);
            leaves.ElementAt(108).setGridPosition(23, 5);
            leaves.ElementAt(109).setGridPosition(23, 4);
            leaves.ElementAt(110).setGridPosition(22, 4);
            leaves.ElementAt(111).setGridPosition(21, 4);
            leaves.ElementAt(112).setGridPosition(20, 4);
            leaves.ElementAt(113).setGridPosition(19, 4);
            leaves.ElementAt(114).setGridPosition(18, 4);
            leaves.ElementAt(115).setGridPosition(17, 4);
            leaves.ElementAt(116).setGridPosition(16, 4);
            leaves.ElementAt(117).setGridPosition(15, 4);
            leaves.ElementAt(118).setGridPosition(14, 4);
            leaves.ElementAt(119).setGridPosition(13, 4);
            leaves.ElementAt(120).setGridPosition(12, 4);
            leaves.ElementAt(121).setGridPosition(11, 4);

            leaves.ElementAt(134).setGridPosition(27, 1);
            leaves.ElementAt(135).setGridPosition(27, 2);
            leaves.ElementAt(136).setGridPosition(27, 3);

            leaves.ElementAt(122).setGridPosition(27, 4);
            leaves.ElementAt(123).setGridPosition(27, 5);
            leaves.ElementAt(124).setGridPosition(27, 6);
            leaves.ElementAt(125).setGridPosition(27, 7);
            leaves.ElementAt(126).setGridPosition(27, 8);
            leaves.ElementAt(127).setGridPosition(27, 9);
            leaves.ElementAt(128).setGridPosition(27, 10);
            leaves.ElementAt(129).setGridPosition(27, 11);
            leaves.ElementAt(130).setGridPosition(27, 12);
            leaves.ElementAt(131).setGridPosition(27, 13);
            leaves.ElementAt(132).setGridPosition(27, 14);
            leaves.ElementAt(133).setGridPosition(27, 15);

            zTime = new ZombieTime(board);
            zTimeReset = new ZombieTime(board);
        }
Exemplo n.º 6
0
        public void Initialize()
        {
            gameOverPosition.X = 320;
            gameOverPosition.Y = 130;

            device = graphics.GraphicsDevice;

            // set up all basic game objects for level1 here
            gameState = new GameState();
            gameStart = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight);
            gameStart2 = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight);

            board = new GameBoard(new Vector2(33, 25), new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight));
            darwin = new Darwin(board);
            firstZombie = new Zombie(10, 10, 15, 5, 15, 5, board);
            secondZombie = new Zombie(10, 16, 15, 5, 15, 5, board);
            thirdZombie = new Zombie(12, 10, 15, 5, 15, 5, board);
            fourthZombie = new Zombie(20, 7, 27, 15, 22, 2, board);
            fifthZombie = new Zombie(22, 10, 25, 15, 22, 2, board);
            sixthZombie = new Zombie(21, 4, 25, 15, 15, 2, board);

            String zombieString = "This a zombie,\n don't near him \nas a human!!";
            zombieMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, zombieString);

            String darwinString = "This is darwin,\n move with arrows, \n z to transform, \n a for actions";
            darwinMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, darwinString);

            String switchString = "This is a switch\n face it and press A\n to see what happens!!";
            switchMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, switchString);

            String brainString = "Move the brain as a \nzombie.\n Zombie's like brains!!";
            brainMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, brainString);

            stairs = new Stairs(board);

            brain = new Brain(board, 3, 3);

            BasicObject[] removableWalls = setRemovableWallsInLevelOne();

            BasicObject switchSquare = new BasicObject(board);
            switchSquare.X = 13;
            switchSquare.Y = 2;

            firstSwitch = new Switch(switchSquare, board, removableWalls);

            // Initial starting position
            darwin.setGridPosition(2, 20);

            if (board.isGridPositionOpen(darwin))
            {
                board.setGridPositionOccupied(darwin.X, darwin.Y);
                darwin.setPosition(board.getPosition(darwin).X, board.getPosition(darwin).Y);
            }

            // Darwin's lag movement
            counterReady = counter = 5;

            if (board.isGridPositionOpen(21, 20))
            {
                stairs.setGridPosition(27, 21);
                stairs.setDestination(board.getPosition(27, 21));
            }

            zTime = new ZombieTime(board);

            vortex = new Vortex(board, 19, 20);

            setPotionPosition(25, 4);

            setWalls();
        }
Exemplo n.º 7
0
        /**
         * moves zombie in the direction that brain currently is
         * */
        public void moveTowardsBrain(Brain brain, Darwin darwin)
        {
            int changeX = 0;
            int changeY = 0;

            changeX = brain.X - this.X;
            changeY = brain.Y - this.Y;

            if (Math.Abs(changeX) > Math.Abs(changeY))
            {
                //move in x direction
                if (brain.X > this.X)
                {
                    //move right
                    if (isZombieInRange(this.X + 1, this.Y))
                    {
                        // checks for board position to be open
                        if (board.isGridPositionOpen(this.X + 1, this.Y) || (darwin.X == this.X + 1 && darwin.Y == this.Y && !darwin.isZombie()))
                        {
                            MoveRight();
                        }
                    }
                }
                else if (brain.X < this.X)
                {
                    //move left
                    if (isZombieInRange(this.X - 1, this.Y))
                    {
                        // checks for board position to be open or occupied by brain
                        if (board.isGridPositionOpen(this.X - 1, this.Y) || (darwin.X == this.X - 1 && darwin.Y == this.Y && !darwin.isZombie()))
                        {
                            MoveLeft();
                        }
                    }
                }
            }
            else
            {
                //move in y direction
                if (brain.Y > this.Y)
                {
                    //move down
                    if (isZombieInRange(this.X, this.Y + 1))
                    {
                        // checks for board position to be open or occupied by brain
                        if (board.isGridPositionOpen(this.X, this.Y + 1) || (darwin.X == this.X && darwin.Y == this.Y + 1 && !darwin.isZombie()))
                        {
                            MoveDown();
                        }
                    }
                }
                else if (brain.Y < this.Y)
                {
                    //move up
                    if (isZombieInRange(this.X, this.Y - 1))
                    {
                        // checks for board position to be open or occupied by brain
                        if (board.isGridPositionOpen(this.X, this.Y - 1) || (darwin.X == this.X && darwin.Y == this.Y - 1 && !darwin.isZombie()))
                        {
                            MoveUp();
                        }
                    }
                }
            }
        }