/* constructor * sets an initial area for the zombie to take up * mymaxX, myminX are the max/min allowed horizontal range for the zombie * mymaxY, myminY are the max/min allowed vertical range for the zombie * Gameboard myboard -- the board which the zombie is moving on **/ public Zombie(int startX, int startY, int mymaxX, int myminX, int mymaxY, int myminY, GameBoard myboard) : base(myboard) { maxX = mymaxX; maxY = mymaxY; minX = myminX; minY = myminY; // start with no zombie vision allowVision = false; visionMaxX = 0; visionMaxY = 0; allowRangeDetection = true; board = myboard; this.X = startX; this.Y = startY; if (board.isGridPositionOpen(this)) { board.setGridPositionOccupied(this.X, this.Y); } destination = new Rectangle(0, 0, ZOMBIE_WIDTH, ZOMBIE_HEIGHT); this.setPosition(board.getPosition(this).X, board.getPosition(this).Y); source = new Rectangle(0, 0, ZOMBIE_WIDTH, ZOMBIE_HEIGHT); }
//BasicObject potentialGridPosition; //constructor public Darwin(GameBoard myboard) : base(myboard) { // Init the frame or cell of the animation that will be shown. source = new Rectangle(); source.Width = DARWIN_HEIGHT; source.Height = DARWIN_WIDTH; source.X = 0; source.Y = 0; // for animating feet downSource = new Rectangle[3]; downSource[0] = new Rectangle(0, 0, DARWIN_WIDTH, DARWIN_HEIGHT); downSource[1] = new Rectangle(DARWIN_WIDTH, 0, DARWIN_WIDTH, DARWIN_HEIGHT); downSource[2] = new Rectangle(DARWIN_WIDTH * 2, 0, DARWIN_WIDTH, DARWIN_HEIGHT); downCount = 0; // tweaks to make darwin look natural darwinLag = 10; zombieLag = 15; darwinCount = 0; zombieCount = 0; widthLength = board.getPosition(10, 10).X - board.getPosition(9, 10).X; heightLength = board.getPosition(10, 10).Y - board.getPosition(10, 9).Y; darwinWidthLength = widthLength / darwinLag; darwinHeightLength = heightLength / darwinLag; zombieWidthLength = widthLength / zombieLag; zombieHeightLength = heightLength / zombieLag; this.setEventLag(darwinLag); inMotion = false; }
public BasicObject(GameBoard myBoard) { board = myBoard; eventLagMax = eventLagMin = 5; eventFlag = true; }
//BasicObject potentialGridPosition; //constructor public Darwin(GameBoard myboard) : base(myboard) { // Init the frame or cell of the animation that will be shown. source = new Rectangle(); source.Width = DARWIN_HEIGHT; source.Height = DARWIN_WIDTH; source.X = 0; source.Y = 0; //potentialGridPosition.setGridPosition(5, 5); board = myboard; this.setGridPosition(5, 5); }
// used to have message focus on a given gameboard square public void pointToSquare(int x,int y,GameBoard board) { int newX = board.getPosition(x, y).X; int newY = board.getPosition(x, y).Y; destination.X = newX + 40; destination.Y = newY - 94; while ((destination.X + destination.Width) > 1080) destination.X -= 5; while ((destination.Y) < 0) destination.Y += 5; position.X = destination.X+20; position.Y = destination.Y+7; }
/* posX is the X coordinate of the switch * posy is the Y coordinate of the switch * myboard is the gameboard * walls is an array basic objects with the positions on the grid that the switch will control **/ public Switch(BasicObject switchSquare, GameBoard myboard, BasicObject[] walls) : base(myboard) { //switch inherits an X and Y from the basic object this.X = switchSquare.X; this.Y = switchSquare.Y; this.walls = walls; if (board.isGridPositionOpen(this.X, this.Y)) { board.setGridPositionOccupied(this.X, this.Y); } else { // you are putting a switch on a block that is already occupied. That isn't good. // Throw an error or something } turnOn(); }
public Search(GameBoard myboard) { board = myboard; foundSolution = true; foundLength = 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); }
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); }
public void Update(GameTime gameTime, KeyboardState ks, GameBoard board, int currentDarwinX, int currentDarwinY) { base.Update(gameTime); if (inMotion) { if (isZombie()) { zombieCount++; } else { darwinCount++; } if (isZombie()) { switch (moveDirection) { case Dir.Left: this.destination.X = this.destination.X - zombieWidthLength; break; case Dir.Down: this.destination.Y = this.destination.Y + zombieHeightLength; break; case Dir.Right: this.destination.X = this.destination.X + zombieWidthLength; break; case Dir.Up: this.destination.Y = this.destination.Y - zombieHeightLength; break; } if (zombieCount > zombieLag) { inMotion = false; zombieCount = 0; switch (moveDirection) { case Dir.Left: this.MoveLeft(); break; case Dir.Down: this.MoveDown(); break; case Dir.Right: this.MoveRight(); break; case Dir.Up: this.MoveUp(); break; } } } else if (!isZombie()) { if (darwinCount > darwinLag / 2) { downCount = 2; } switch (moveDirection) { case Dir.Left: this.destination.X = this.destination.X - darwinWidthLength; break; case Dir.Down: this.destination.Y = this.destination.Y + darwinHeightLength; break; case Dir.Right: this.destination.X = this.destination.X + darwinWidthLength; break; case Dir.Up: this.destination.Y = this.destination.Y - darwinHeightLength; break; } if (darwinCount > darwinLag) { inMotion = false; darwinCount = 0; switch (moveDirection) { case Dir.Left: this.MoveLeft(); downCount = 0; break; case Dir.Down: this.MoveDown(); downCount = 0; break; case Dir.Right: this.MoveRight(); downCount = 0; break; case Dir.Up: this.MoveUp(); downCount = 0; break; } } } } else { moveDarwin(ks, board, currentDarwinX, currentDarwinY); } //if (canEventHappen()) //{ // updateDarwinTransformState(ks); // this.setEventFalse(); //} if (!isZombieButtonBeingPressed) { updateDarwinTransformState(ks); } if (ks.IsKeyUp(Keys.Z)) { isZombieButtonBeingPressed = false; } }
private void moveDarwin(KeyboardState ks, GameBoard board, int currentDarwinX, int currentDarwinY) { if (ks.IsKeyDown(Keys.Right)) { facing = Dir.Right; if (board.isGridPositionOpen(currentDarwinX + 1, currentDarwinY)) { this.MoveRight(); } /*else { collision = true; }*/ } if (ks.IsKeyDown(Keys.Left)) { facing = Dir.Left; if(board.isGridPositionOpen(currentDarwinX -1, currentDarwinY)) { this.MoveLeft(); } /*else { collision = true; }*/ } if (ks.IsKeyDown(Keys.Up)) { facing = Dir.Up; if(board.isGridPositionOpen(currentDarwinX, currentDarwinY - 1)) { this.MoveUp(); } /*else { collision = true; }*/ } if (ks.IsKeyDown(Keys.Down)) { facing = Dir.Down; if(board.isGridPositionOpen(currentDarwinX, currentDarwinY + 1)) { this.MoveDown(); } /*else { collision = true; }*/ } }
private void moveDarwin(KeyboardState ks, GameBoard board, int currentDarwinX, int currentDarwinY) { // has a direction been picked to go in, used to get rid of diagonal movement bool hasPicked = false; if (ks.IsKeyDown(Keys.Right)) { if (board.isGridPositionOpen(currentDarwinX + 1, currentDarwinY) && !hasPicked && facing == Dir.Right) { hasPicked = true; moveDirection = Dir.Right; inMotion = true; downCount = 1; } else { facing = Dir.Right; downCount = 0; } } if (ks.IsKeyDown(Keys.Left)) { if (board.isGridPositionOpen(currentDarwinX - 1, currentDarwinY) && !hasPicked && facing == Dir.Left) { hasPicked = true; moveDirection = Dir.Left; inMotion = true; downCount = 1; } else { facing = Dir.Left; downCount = 0; } } if (ks.IsKeyDown(Keys.Up)) { if (board.isGridPositionOpen(currentDarwinX, currentDarwinY - 1) && !hasPicked && facing == Dir.Up) { hasPicked = true; moveDirection = Dir.Up; inMotion = true; downCount = 1; } else { facing = Dir.Up; downCount = 0; } } if (ks.IsKeyDown(Keys.Down)) { if (board.isGridPositionOpen(currentDarwinX, currentDarwinY + 1) && !hasPicked && facing == Dir.Down) { hasPicked = true; moveDirection = Dir.Down; inMotion = true; downCount = 1; } else { facing = Dir.Down; downCount = 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(); }
public void Update(GameTime gameTime, KeyboardState ks, GameBoard board, int currentDarwinX, int currentDarwinY) { base.Update(gameTime); if (this.canEventHappen()) { updateDarwinTransformState(ks); this.setEventFalse(); } moveDarwin(ks, board, currentDarwinX, currentDarwinY); setPictureSize(board.getSquareWidth(), board.getSquareLength()); }
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, 9, 24, 5, 15, 5, board); secondZombie = new Zombie(12, 9, 24, 5, 15, 5, board); thirdZombie = new Zombie(8, 8, 24, 5, 15, 5, board); fourthZombie = new Zombie(8, 12, 17, 5, 20, 10, board); myZombieList = new List <Zombie>(); myZombieList.Add(firstZombie); myZombieList.Add(secondZombie); myZombieList.Add(thirdZombie); myZombieList.Add(fourthZombie); cannibalZombie = new CannibalZombie(29, 3, board.getNumSquaresX() - 1, 1, board.getNumSquaresY() - 1, 1, myZombieList, darwin, 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 cannibalString = "Cannibal Zombies eat\n other zombies!!\n Use this to\n your advantage!!"; cannibalMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, cannibalString); stairs = new Stairs(board); removableWalls = setRemovableWallsInLevelTwo(); // Initial starting position darwin.setGridPosition(21, 20); if (board.isGridPositionOpen(darwin)) { board.setGridPositionOccupied(darwin.X, darwin.Y); darwin.setPosition(board.getPosition(darwin).X, board.getPosition(darwin).Y); } if (board.isGridPositionOpen(27, 20)) { stairs.setGridPosition(27, 20); stairs.setDestination(board.getPosition(27, 20)); } zTime = new ZombieTime(board); zTimeReset = new ZombieTime(board); setWallsInLevelTwo(); potion = new Potion(board); potion.setDestination(board.getPosition(3, 3)); potion.setGridPosition(3, 3); }
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, 9, 24, 5, 15, 5, board); secondZombie = new Zombie(12, 9, 24, 5, 15, 5, board); thirdZombie = new Zombie(8, 8, 24, 5, 15, 5, board); fourthZombie = new Zombie(8, 12, 17, 5, 20, 10, board); myZombieList= new List<Zombie>(); myZombieList.Add(firstZombie); myZombieList.Add(secondZombie); myZombieList.Add(thirdZombie); myZombieList.Add(fourthZombie); cannibalZombie = new CannibalZombie(29,3,board.getNumSquaresX()-1,1,board.getNumSquaresY()-1,1,myZombieList,darwin,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 cannibalString = "Cannibal Zombies eat\n other zombies!!\n Use this to\n your advantage!!"; cannibalMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, cannibalString); stairs = new Stairs(board); removableWalls = setRemovableWallsInLevelTwo(); // Initial starting position darwin.setGridPosition(21, 20); if (board.isGridPositionOpen(darwin)) { board.setGridPositionOccupied(darwin.X, darwin.Y); darwin.setPosition(board.getPosition(darwin).X, board.getPosition(darwin).Y); } if (board.isGridPositionOpen(27, 20)) { stairs.setGridPosition(27, 20); stairs.setDestination(board.getPosition(27, 20)); } zTime = new ZombieTime(board); zTimeReset = new ZombieTime(board); setWallsInLevelTwo(); potion = new Potion(board); potion.setDestination(board.getPosition(3,3)); potion.setGridPosition(3, 3); }
public void Update(GameTime gameTime, KeyboardState ks, GameBoard board, int currentDarwinX, int currentDarwinY) { base.Update(gameTime); if (inMotion) { if (isZombie()) { zombieCount++; } else { darwinCount++; } if (isZombie()) { switch (moveDirection) { case Dir.Left: this.destination.X = this.destination.X - zombieWidthLength; break; case Dir.Down: this.destination.Y = this.destination.Y + zombieHeightLength; break; case Dir.Right: this.destination.X = this.destination.X + zombieWidthLength; break; case Dir.Up: this.destination.Y = this.destination.Y - zombieHeightLength; break; } if (zombieCount > zombieLag) { inMotion = false; zombieCount = 0; switch (moveDirection) { case Dir.Left: this.MoveLeft(); break; case Dir.Down: this.MoveDown(); break; case Dir.Right: this.MoveRight(); break; case Dir.Up: this.MoveUp(); break; } } } else if (!isZombie()) { if (darwinCount > darwinLag / 2) { downCount = 2; } switch (moveDirection) { case Dir.Left: this.destination.X = this.destination.X - darwinWidthLength; break; case Dir.Down: this.destination.Y = this.destination.Y + darwinHeightLength; break; case Dir.Right: this.destination.X = this.destination.X + darwinWidthLength; break; case Dir.Up: this.destination.Y = this.destination.Y - darwinHeightLength; break; } if (darwinCount > darwinLag) { inMotion = false; darwinCount = 0; switch (moveDirection) { case Dir.Left: this.MoveLeft(); downCount = 0; break; case Dir.Down: this.MoveDown(); downCount = 0; break; case Dir.Right: this.MoveRight(); downCount = 0; break; case Dir.Up: this.MoveUp(); downCount = 0; break; } } } } else { moveDarwin(ks, board, currentDarwinX, currentDarwinY); } //if (canEventHappen()) //{ // updateDarwinTransformState(ks); // this.setEventFalse(); //} if (!isZombieButtonBeingPressed) updateDarwinTransformState(ks); if (ks.IsKeyUp(Keys.Z)) isZombieButtonBeingPressed = false; }
public Stairs(GameBoard myBoard) : base(myBoard) { // DO nothing }