public new void Update(GameTime gameTime, Darwin darwin) { eventLagMin++; if (eventLagMin > eventLagMax) { this.eventFlag = true; } if (movecounter > ZOMBIE_MOVE_RATE) { if (killMode) { // attack ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); foreach (CongaFollowerZombie follower in followerZombies) follower.activateKillMode(); } else if (isDarwinOnFloor(darwin) && !darwin.isZombie()) { // darwin is human he must die ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X,darwin.Y); } else if (isDarwinOnFloor(darwin) && !isDarwinOnPath(darwin)) { ZOMBIE_MOVE_RATE = 10; // case where darwin is a zombie not in the conga line this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); } else { ZOMBIE_MOVE_RATE = 20; if (enemyAlert) { source.X = 128; enemyAlertCount++; if (enemyAlertCount > 2) { enemyAlert = false; enemyAlertCount = 0; } } else this.source.X = 0; followPath(); } movecounter = 0; } movecounter++; }
public void Update(GameTime gameTime, KeyboardState ks, Darwin darwin) { base.Update(gameTime); // if darwin is a zombie, he cant push boxes if (!darwin.isZombie() && this.canEventHappen() && ks.IsKeyDown(Keys.A)) { this.setEventFalse(); // get Darwin's current facing direction LegendOfDarwin.Darwin.Dir facing = darwin.facing; // check switch position in relation to darwin's position + facing direction switch (facing) { case (LegendOfDarwin.Darwin.Dir.Left): if (((this.X + 1) == darwin.X) && (this.Y == darwin.Y)) { if (board.isGridPositionOpen(this.X - 1, this.Y)) { this.MoveLeft(); boxSound.Play(); } } break; case (LegendOfDarwin.Darwin.Dir.Right): if (((this.X - 1) == darwin.X) && (this.Y == darwin.Y)) { if (board.isGridPositionOpen(this.X + 1, this.Y)) { this.MoveRight(); boxSound.Play(); } } break; case (LegendOfDarwin.Darwin.Dir.Up): if ((this.X == darwin.X) && ((this.Y + 1) == darwin.Y)) { if (board.isGridPositionOpen(this.X, this.Y - 1)) { this.MoveUp(); boxSound.Play(); } } break; case (LegendOfDarwin.Darwin.Dir.Down): if ((this.X == darwin.X) && ((this.Y - 1) == darwin.Y)) { if (board.isGridPositionOpen(this.X, this.Y + 1)) { this.MoveDown(); boxSound.Play(); } } break; } } }
private void UpdateLevelState(GameTime gameTime) { checkLevelOver(); if (darwin.isZombie() && darwin.isDarwinAlive()) { if (zTime.isTimedOut()) { gameOver = true; } else { zTime.Update(gameTime); } } KeyboardState ks = Keyboard.GetState(); if (darwin.isDarwinAlive()) { checkForExitGame(ks); checkForGameOver(); if (fatBossZombie.isZombieAlive()) { checkForGameOverWithBoss(); } darwin.Update(gameTime, ks, board, darwin.X, darwin.Y); } if (ks.IsKeyDown(Keys.H) && messageModeCounter > 10) { messageMode = true; messageModeCounter = 0; } messageModeCounter++; if (fatBossZombie.isZombieAlive()) { fatBossZombie.checkForBabyDeaths(nurseryOne, nurseryTwo); } nurseryOne.Update(gameTime); nurseryTwo.Update(gameTime); if (fatBossZombie.isZombieAlive()) { fatBossZombie.Update(gameTime); } updateFirstBabyWaveExplosion(); updateSecondBabyWaveExplosion(); }
// checks if darwin is in front of boss and boss has his mouth open and darwin is a human public bool canDarwinBeEaten() { if ((darwin.X == this.X || darwin.X == this.X + 1 || darwin.X == this.X + 2)) { if (darwin.Y == this.Y + 3 && !darwin.isZombie() && gapeMode && this.isZombieAlive()) { return(true); } } return(false); }
public void Update(GameTime gameTime, KeyboardState ks, Darwin darwin) { base.Update(gameTime); // if darwin is a zombie, he cant push boxes if (!darwin.isZombie() && this.canEventHappen() && ks.IsKeyDown(Keys.A)) { this.setEventFalse(); // get Darwin's current facing direction LegendOfDarwin.Darwin.Dir facing = darwin.facing; // check switch position in relation to darwin's position + facing direction switch (facing) { case (LegendOfDarwin.Darwin.Dir.Left): if (((this.X + 1) == darwin.X) && (this.Y == darwin.Y)) { if (board.isGridPositionOpen(this.X - 1, this.Y)) { this.MoveLeft(); boxSound.Play(); } } break; case (LegendOfDarwin.Darwin.Dir.Right): if (((this.X - 1) == darwin.X) && (this.Y == darwin.Y)) if (board.isGridPositionOpen(this.X + 1, this.Y)) { this.MoveRight(); boxSound.Play(); } break; case (LegendOfDarwin.Darwin.Dir.Up): if ((this.X == darwin.X) && ((this.Y + 1) == darwin.Y)) if (board.isGridPositionOpen(this.X, this.Y - 1)) { this.MoveUp(); boxSound.Play(); } break; case (LegendOfDarwin.Darwin.Dir.Down): if ((this.X == darwin.X) && ((this.Y - 1) == darwin.Y)) if (board.isGridPositionOpen(this.X, this.Y + 1)) { this.MoveDown(); boxSound.Play(); } break; } } }
public void Update(Darwin darwin) { // once the zombie can move if (movecounter > ZOMBIE_MOVE_RATE) { // check if he see's darwin // might be better to have a ! instead of the pyrozombie just stopping his patrol if (this.isPointInVision(darwin.X, darwin.Y)) { // pyro zombies dislike darwin if (!darwin.isZombie()) { patrolling = false; } } else { patrolling = true; playFlameSound = true; } // if he is patrolling if (this.patrolling) { // could probably do this better if ((this.X == nextPoint.X) && (this.Y == nextPoint.Y)) { // switch patrol points Vector2 temp = currentPoint; setCurrentPatrolPoint(this.getNextPatrolPoint()); setNextPatrolPoint(temp); } else { this.moveToPoint(nextPoint); } } // reset move counter movecounter = 0; } movecounter++; }
// update to be used for brainless levels public void Update(GameTime gameTime, Darwin darwin) { //testRun(); if (this.isZombieAlive()) { if (movecounter > ZOMBIE_MOVE_RATE) { 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++; } }
public void Update(Darwin darwin) { // once the zombie can move if (movecounter > ZOMBIE_MOVE_RATE) { // check if he see's darwin // might be better to have a ! instead of the pyrozombie just stopping his patrol if (this.isPointInVision(darwin.X, darwin.Y)) { // pyro zombies dislike darwin if (!darwin.isZombie()) { patrolling = false; } } else { patrolling = true; playFlameSound = true; } // if he is patrolling if (this.patrolling) { // could probably do this better if ((this.X == nextPoint.X) && (this.Y == nextPoint.Y)) { // switch patrol points Vector2 temp = currentPoint; setCurrentPatrolPoint(this.getNextPatrolPoint()); setNextPatrolPoint(temp); } else { this.moveToPoint(nextPoint); } } // reset move counter movecounter = 0; } movecounter++; }
public new void Update(GameTime gameTime, Darwin darwin) { eventLagMin++; if (eventLagMin > eventLagMax) { this.eventFlag = true; } foreach (Zombie myzombie in zombies) CollisionWithZombie(myzombie); if (movecounter > ZOMBIE_MOVE_RATE) { //these loops are seperate because the top loop could potentially remove zombies from the list this.updateListOfZombies(this.removeDeadZombies(zombies)); int intendedptX = 0; int intendedptY = 0; bool hasZombieDest = false; bool goForDarwin = true; int closestZombieDist = 10000; // checks where other zombies are, and where zombie darwin is, finds closest one that is in range foreach (Zombie myzombie in zombies) { if (isVisionAllowed() && isPointInVision(myzombie.X, myzombie.Y) && myzombie.isZombieAlive()) { int dist = Math.Abs(this.X - myzombie.X) + Math.Abs(this.Y - myzombie.Y); if (dist < closestZombieDist) { closestZombieDist = dist; intendedptX = myzombie.X; intendedptY = myzombie.Y; hasZombieDest = true; goForDarwin = false; } } } if (hasZombieDest) { if (Math.Abs(this.X - darwin.X) + Math.Abs(this.Y - darwin.Y) <= closestZombieDist && darwin.isZombie()) { goForDarwin = true; hasZombieDest = false; } } if (goAroundMode) goAroundObstacle(); else if (isVisionAllowed() && isPointInVision(darwin.X, darwin.Y) && darwin.isZombie() && goForDarwin) { // either go for darwin or a zombie, use exclamation mark source.X = 64; this.enemyAlert = true; this.moveTowardsPoint(darwin.X, darwin.Y); } else if (hasZombieDest) { source.X = 64; this.enemyAlert = true; this.moveTowardsPoint(intendedptX, intendedptY); } else { if (enemyAlert) { source.X = 128; enemyAlertCount++; if (enemyAlertCount > 2) { enemyAlert = false; enemyAlertCount = 0; } } else this.source.X = 0; this.RandomWalk(); } movecounter = 0; } movecounter++; }
// update to be used for brainless levels public void Update(GameTime gameTime, Darwin darwin) { //testRun(); if (this.isZombieAlive()) { if (movecounter > ZOMBIE_MOVE_RATE) { 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++; } }
/** * moves zombie in the direction that darwin currently is * */ public void moveTowardsDarwin(Darwin darwin) { int changeX = 0; int changeY = 0; changeX = darwin.X - this.X; changeY = darwin.Y - this.Y; if (Math.Abs(changeX) > Math.Abs(changeY)) { //move in x direction if (darwin.X > this.X) { //move right if (isZombieInRange(this.X + 1, this.Y)) { // checks for board position to be open or occupied by darwin if (board.isGridPositionOpen(this.X + 1, this.Y) || (darwin.X == this.X + 1 && darwin.Y == this.Y && !darwin.isZombie())) MoveRight(); } } else if (darwin.X < this.X) { //move left if (isZombieInRange(this.X - 1, this.Y)) { // checks for board position to be open or occupied by darwin 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 (darwin.Y > this.Y) { //move down if (isZombieInRange(this.X, this.Y + 1)) { // checks for board position to be open or occupied by darwin if (board.isGridPositionOpen(this.X, this.Y+1) || (darwin.X == this.X && darwin.Y == this.Y+1 && !darwin.isZombie())) MoveDown(); } } else if (darwin.Y < this.Y) { //move up if (isZombieInRange(this.X, this.Y - 1)) { // checks for board position to be open or occupied by darwin if (board.isGridPositionOpen(this.X, this.Y - 1) || (darwin.X == this.X && darwin.Y == this.Y - 1 && !darwin.isZombie())) MoveUp(); } } } }
/** * 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(); } } } } }
public new void Update(GameTime gameTime, Darwin darwin) { eventLagMin++; if (eventLagMin > eventLagMax) { this.eventFlag = true; } if (movecounter > ZOMBIE_MOVE_RATE) { if (killMode) { // attack ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); foreach (CongaFollowerZombie follower in followerZombies) follower.activateKillMode(); } else if (isDarwinOnFloor(darwin) && !darwin.isZombie()) { // darwin is human he must die ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X,darwin.Y); } else if (isDarwinOnFloor(darwin) && !isDarwinOnPath(darwin)) { ZOMBIE_MOVE_RATE = 10; // case where darwin is a zombie not in the conga line this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); } else { ZOMBIE_MOVE_RATE = 20; if (enemyAlert) { source.X = 128; enemyAlertCount++; if (enemyAlertCount > 2) { enemyAlert = false; enemyAlertCount = 0; } } else this.source.X = 0; followPath(); } movecounter = 0; } movecounter++; }
/** * moves cannibal towards a specified point within the cannibals range * will go around stuff to get there * */ public void moveTowardsPoint(int ptX, int ptY) { int changeX = 0; int changeY = 0; int intendedPathX = 0; int intendedPathY = 0; changeX = ptX - this.X; changeY = ptY - this.Y; if (Math.Abs(changeX) > Math.Abs(changeY)) { //move in x direction if (ptX > this.X) { //intend to move right intendedPathX = this.X + 1; intendedPathY = this.Y; } else if (ptX < this.X) { //intend to move left intendedPathX = this.X - 1; intendedPathY = this.Y; } } else { //move in y direction if (ptY > this.Y) { //intend to move down intendedPathX = this.X; intendedPathY = this.Y + 1; } else if (ptY < this.Y) { //intend to move up intendedPathX = this.X; intendedPathY = this.Y - 1; } } if (isZombieInRange(intendedPathX, intendedPathY)) { bool canMoveThere = false; foreach (Zombie zombieToEat in zombies) { if (zombieToEat.X == intendedPathX && zombieToEat.Y == intendedPathY) { canMoveThere = true; } } if (darwin.X == intendedPathX && darwin.Y == intendedPathY && darwin.isZombie()) { canMoveThere = true; } // checks for board position to be open if (board.isGridPositionOpen(intendedPathX, intendedPathY) || canMoveThere) { if (intendedPathX == this.X + 1) { MoveRight(); } else if (intendedPathX == this.X - 1) { MoveLeft(); } else if (intendedPathY == this.Y + 1) { MoveDown(); } else if (intendedPathY == this.Y - 1) { MoveUp(); } } else { //attempt to find way around obstacle //FindWhichWay(intendedPathX, intendedPathY); //if (!goAroundMode) //{ RandomWalk(); //} //else // goAroundObstacle(); } } }
public new void Update(GameTime gameTime, Darwin darwin) { eventLagMin++; if (eventLagMin > eventLagMax) { this.eventFlag = true; } foreach (Zombie myzombie in zombies) { CollisionWithZombie(myzombie); } if (movecounter > ZOMBIE_MOVE_RATE) { //these loops are seperate because the top loop could potentially remove zombies from the list this.updateListOfZombies(this.removeDeadZombies(zombies)); int intendedptX = 0; int intendedptY = 0; bool hasZombieDest = false; bool goForDarwin = true; int closestZombieDist = 10000; // checks where other zombies are, and where zombie darwin is, finds closest one that is in range foreach (Zombie myzombie in zombies) { if (isVisionAllowed() && isPointInVision(myzombie.X, myzombie.Y) && myzombie.isZombieAlive()) { int dist = Math.Abs(this.X - myzombie.X) + Math.Abs(this.Y - myzombie.Y); if (dist < closestZombieDist) { closestZombieDist = dist; intendedptX = myzombie.X; intendedptY = myzombie.Y; hasZombieDest = true; goForDarwin = false; } } } if (hasZombieDest) { if (Math.Abs(this.X - darwin.X) + Math.Abs(this.Y - darwin.Y) <= closestZombieDist && darwin.isZombie()) { goForDarwin = true; hasZombieDest = false; } } if (goAroundMode) { goAroundObstacle(); } else if (isVisionAllowed() && isPointInVision(darwin.X, darwin.Y) && darwin.isZombie() && goForDarwin) { // either go for darwin or a zombie, use exclamation mark source.X = 64; this.enemyAlert = true; this.moveTowardsPoint(darwin.X, darwin.Y); } else if (hasZombieDest) { source.X = 64; this.enemyAlert = true; this.moveTowardsPoint(intendedptX, intendedptY); } else { if (enemyAlert) { source.X = 128; enemyAlertCount++; if (enemyAlertCount > 2) { enemyAlert = false; enemyAlertCount = 0; } } else { this.source.X = 0; } this.RandomWalk(); } movecounter = 0; } movecounter++; }
public new void Update(GameTime gameTime, Darwin darwin) { eventLagMin++; if (eventLagMin > eventLagMax) { this.eventFlag = true; } if (movecounter > ZOMBIE_MOVE_RATE) { if (preKillMode) { // zombie's groove has been thrown off, alert leader source.X = 128; killMode = true; preKillMode = false; leaderZombie.activateKillMode(); } else if(killMode) { // just kill darwin ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); } else if (this.isPointInVision(darwin.X, darwin.Y) && !darwin.isZombie() && isDarwinOnFloor(darwin)) { // darwin is a human on the dance floow he must die ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); } else if ((isDarwinOnFloor(darwin) && !darwin.isZombie()) || (darwin.isZombie() && isDarwinOnFloor(darwin) && !isDarwinOnPath(darwin))) { if (!hasBeenSeen) { // get ready to attack ZOMBIE_MOVE_RATE = 20; hasBeenSeenCounter++; if (hasBeenSeenCounter > 3) hasBeenSeen = true; followPath(); } else { // someone saw darwin, attack ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); } } else { // no threat at the moment, just dance, watch out for alarm from other zombies ZOMBIE_MOVE_RATE = 20; hasBeenSeen = false; hasBeenSeenCounter = 0; if (enemyAlert) { source.X = 128; enemyAlertCount++; if (enemyAlertCount > 2) { enemyAlert = false; enemyAlertCount = 0; } } else this.source.X = 0; followPath(); } movecounter = 0; } movecounter++; }
private void UpdateLevelState(GameTime gameTime) { if (darwin.isZombie() && darwin.isDarwinAlive()) { if (zTime.isTimedOut()) { gameOver = true; } else { zTime.Update(gameTime); } } KeyboardState ks = Keyboard.GetState(); checkForExitGame(ks); updateKeyHeldDown(ks); if (darwin.isDarwinAlive()) { foreach (Flame flame in flames) { this.checkForFlameDeath(flame, darwin); } darwin.Update(gameTime, ks, board, darwin.X, darwin.Y); } stairs.Update(gameTime, darwin); potion.Update(gameTime, ks, darwin, zTime); foreach (Box b in boxes) { b.Update(gameTime, ks, darwin); } foreach (Vortex v in vortexes) { v.Update(gameTime, ks); // maybe update this so that boxes can't go in holes foreach (Box b in boxes) { v.CollisionWithBO(b, board); } } northZombie.Update(darwin); southZombie.Update(darwin); eastZombie.Update(darwin); westZombie.Update(darwin); if (!darwin.isZombie()) { if (!northZombie.isPatrolling()) { if (darwin.X == northZombie.X) { flames.AddLast(new Flame(board, northZombie.X, northZombie.Y + 1)); flames.AddLast(new Flame(board, northZombie.X, northZombie.Y + 2)); flames.AddLast(new Flame(board, northZombie.X, northZombie.Y + 3)); northZombie.doFlameSound(); } } else if (!southZombie.isPatrolling()) { if (darwin.X == southZombie.X) { flames.AddLast(new Flame(board, southZombie.X, southZombie.Y - 1)); flames.AddLast(new Flame(board, southZombie.X, southZombie.Y - 2)); flames.AddLast(new Flame(board, southZombie.X, southZombie.Y - 3)); southZombie.doFlameSound(); } } else if (!eastZombie.isPatrolling()) { if (darwin.Y == eastZombie.Y) { flames.AddLast(new Flame(board, eastZombie.X - 1, eastZombie.Y)); flames.AddLast(new Flame(board, eastZombie.X - 2, eastZombie.Y)); flames.AddLast(new Flame(board, eastZombie.X - 3, eastZombie.Y)); eastZombie.doFlameSound(); } } else if (!westZombie.isPatrolling()) { if (darwin.Y == westZombie.Y) { flames.AddLast(new Flame(board, westZombie.X + 1, westZombie.Y)); flames.AddLast(new Flame(board, westZombie.X + 2, westZombie.Y)); flames.AddLast(new Flame(board, westZombie.X + 3, westZombie.Y)); westZombie.doFlameSound(); } } } foreach (Flame flame in flames) { flame.Update(); if (!flame.isAlive()) { //flames.Remove(flame); } } if (darwin.isDarwinAlive()) { if (snake.isZombieAlive()) { updateSnakeCollision(snake, darwin, gameTime); } if (snake2.isZombieAlive()) { updateSnakeCollision(snake2, darwin, gameTime); } if (snake3.isZombieAlive()) { updateSnakeCollision(snake3, darwin, gameTime); } if (snake4.isZombieAlive()) { updateSnakeCollision(snake4, darwin, gameTime); } } foreach (Vortex v in vortexes) { if (darwin.isOnTop(v)) { fellDownPit = true; gameOver = true; } } checkForGameWin(); checkForSwitchToLevelSix(); if (ks.IsKeyDown(Keys.H) && messageModeCounter > 10) { messageMode = true; messageModeCounter = 0; } messageModeCounter++; }
/* * moves zombie towards a given point * Used for straight line portions of the patrol path * */ public void moveTowardsPoint(int ptX, int ptY) { int changeX = 0; int changeY = 0; int intendedPathX = 0; int intendedPathY = 0; changeX = ptX - this.X; changeY = ptY - this.Y; if (Math.Abs(changeX) > Math.Abs(changeY)) { //move in x direction if (ptX > this.X) { //intend to move right intendedPathX = this.X + 1; intendedPathY = this.Y; } else if (ptX < this.X) { //intend to move left intendedPathX = this.X - 1; intendedPathY = this.Y; } } else { //move in y direction if (ptY > this.Y) { //intend to move down intendedPathX = this.X; intendedPathY = this.Y + 1; } else if (ptY < this.Y) { //intend to move up intendedPathX = this.X; intendedPathY = this.Y - 1; } } if (isZombieInRange(intendedPathX, intendedPathY)) { bool canMoveThere = false; if (darwin.X == intendedPathX && darwin.Y == intendedPathY && (!darwin.isZombie() || killMode)) { canMoveThere = true; } else if (darwin.X == intendedPathX && darwin.Y == intendedPathY && darwin.isZombie() && !killMode) { preKillMode = true; } // checks for board position to be open if (board.isGridPositionOpen(intendedPathX, intendedPathY) || canMoveThere) { if (intendedPathX == this.X + 1) { MoveRight(); } else if (intendedPathX == this.X - 1) { MoveLeft(); } else if (intendedPathY == this.Y + 1) { MoveDown(); } else if (intendedPathY == this.Y - 1) { MoveUp(); } } else { if (!preKillMode) { RandomWalk(); } } } }
public new void Update(GameTime gameTime, Darwin darwin) { eventLagMin++; if (eventLagMin > eventLagMax) { this.eventFlag = true; } if (movecounter > ZOMBIE_MOVE_RATE) { if (preKillMode) { // zombie's groove has been thrown off, alert leader source.X = 128; killMode = true; preKillMode = false; leaderZombie.activateKillMode(); } else if (killMode) { // just kill darwin ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); } else if (this.isPointInVision(darwin.X, darwin.Y) && !darwin.isZombie() && isDarwinOnFloor(darwin)) { // darwin is a human on the dance floow he must die ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); } else if ((isDarwinOnFloor(darwin) && !darwin.isZombie()) || (darwin.isZombie() && isDarwinOnFloor(darwin) && !isDarwinOnPath(darwin))) { if (!hasBeenSeen) { // get ready to attack ZOMBIE_MOVE_RATE = 20; hasBeenSeenCounter++; if (hasBeenSeenCounter > 3) { hasBeenSeen = true; } followPath(); } else { // someone saw darwin, attack ZOMBIE_MOVE_RATE = 10; this.enemyAlert = true; source.X = 64; moveTowardsPoint(darwin.X, darwin.Y); } } else { // no threat at the moment, just dance, watch out for alarm from other zombies ZOMBIE_MOVE_RATE = 20; hasBeenSeen = false; hasBeenSeenCounter = 0; if (enemyAlert) { source.X = 128; enemyAlertCount++; if (enemyAlertCount > 2) { enemyAlert = false; enemyAlertCount = 0; } } else { this.source.X = 0; } followPath(); } movecounter = 0; } movecounter++; }