// refer to Zombie constructor for details public BabyZombie(int x, int y, int maxX, int minX, int maxY, int minY, Darwin dar, GameBoard gb) : base(x, y, maxX, minX, maxY, minY, gb) { darwin = dar; babyCount = 0; babyCountTwo = 0; babySource = new Rectangle[6]; babySource[0] = new Rectangle(0, 0, 64, 64); babySource[1] = new Rectangle(65, 0, 64, 64); babySource[2] = new Rectangle(128, 0, 64, 64); babySource[3] = new Rectangle(192, 0, 64, 64); babySource[4] = new Rectangle(256, 0, 64, 64); babySource[5] = new Rectangle(320, 0, 64, 64); goingToExplode = false; exploding = false; explodeCount = 0; explodeSource = new Rectangle[3]; explodeSource[0] = new Rectangle(0, 0, 75, 90); explodeSource[1] = new Rectangle(76, 0, 87, 90); explodeSource[2] = new Rectangle(169, 0, 101, 90); this.setEventLag(40); }
public void Initialize() { gameOverPosition.X = 320; gameOverPosition.Y = 130; device = graphics.GraphicsDevice; gameState = new GameState(); 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); zTime = new ZombieTime(board); nurseryOne = new Nursery(board, darwin); nurseryTwo = new Nursery(board, darwin); fatBossZombie = new FatBossZombie(15, 4, 19, 14, 4, 3, darwin, board); fatBossZombie.resetGapeMode(); stairs = new Stairs(board); walls = setWallsInLevelSix(); setLevelState(); gameState.setState(GameState.state.Start); }
private void updateSnakeCollision(Snake snake, Darwin darwin, GameTime gameTime) { if (!snake.isSnakeInPit()) { snake.setZombieAlive(false); } else { snake.Update(gameTime, darwin, flames); if (snake.lineOfSight & snake.allowedToWalk) { if (snake.lineOfSightDirection.Equals(LegendOfDarwin.GameObject.Snake.Direction.Up)) { checkForDarwinAboveSnake(snake, darwin); } if (snake.lineOfSightDirection.Equals(LegendOfDarwin.GameObject.Snake.Direction.Down)) { checkForDarwinBelowSnake(snake, darwin); } if (snake.lineOfSightDirection.Equals(LegendOfDarwin.GameObject.Snake.Direction.Right)) { checkForDarwinRightOfSnake(snake, darwin); } if (snake.lineOfSightDirection.Equals(LegendOfDarwin.GameObject.Snake.Direction.Left)) { checkForDarwinLeftOfSnake(snake, darwin); } } } }
//private LinkedList<BabyZombie> babies; public FatBossZombie(int x, int y, int maxX, int minX, int maxY, int minY, Darwin dar, GameBoard gb) : base(x, y, maxX, minX, maxY, minY, gb) { darwin = dar; destination.Height = board.getSquareLength() * 3; destination.Width = board.getSquareWidth() * 3; source = new Rectangle(0, 0, 128, 128); setEventLag(10); explodeSource = new Rectangle[4]; explodeSource[0] = new Rectangle(0, 0, 75, 90); explodeSource[1] = new Rectangle(0, 0, 75, 90); explodeSource[2] = new Rectangle(76, 0, 87, 90); explodeSource[3] = new Rectangle(169, 0, 101, 90); ran = new Random(); ran1 = new Random(); deathExplodeCount = new int[9]; deathExplodeBool = new bool[9]; for (int i = 0; i < 9; i++) { deathExplodeBool[i] = new bool(); deathExplodeCount[i] = new int(); } reset(); ZOMBIE_MOVE_RATE = 50; }
public void Update(GameTime gameTime, KeyboardState ks, Darwin darwin, ZombieTime zTime) { if (this.isOnTop(darwin) && !isConsumed) { consumePotion(zTime); } }
private void checkForFlameDeath(Flame flame, Darwin darwin) { if (darwin.isOnTop(flame)) { this.gameOver = true; } }
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(GameTime gameTime, KeyboardState ks, Darwin darwin, ZombieTime zTime) { if(this.isOnTop(darwin) && !isConsumed) { consumePotion(zTime); } }
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 bool isDarwinLeftOfSnakeSomewhere(Darwin darwin) { if (darwin.Y == this.Y && darwin.X < this.X) { return(true); } return(false); }
public bool isDarwinBelowSnakeSomewhere(Darwin darwin) { if (darwin.X == this.X && darwin.Y > this.Y) { return(true); } return(false); }
public bool isDarwinDirectlyBelowSnake(Darwin darwin) { if ((this.Y + 1 == darwin.Y) && darwin.X == this.X) { return(true); } return(false); }
public bool isDarwinDirectlyLeftOfSnake(Darwin darwin) { if ((this.X - 1 == darwin.X) && darwin.Y == this.Y) { return(true); } return(false); }
public void Update(GameTime gameTime, Darwin darwin, LinkedList <Flame> flames) { //base.Update(gameTime); if (movecounter > ZOMBIE_MOVE_RATE) { allowedToWalk = true; // snakes can die in fire if (flames != null) { this.checkForFieryDeath(flames); } if (snakeDelayCounter > (ZOMBIE_MOVE_RATE * 5)) { snakeDelayCounter = 0; delaySnakeCounter = false; } if (!delaySnakeCounter && (isDarwinAboveSnakeSomewhere(darwin) || isDarwinBelowSnakeSomewhere(darwin) || isDarwinRightOfSnakeSomewhere(darwin) || isDarwinLeftOfSnakeSomewhere(darwin))) { lineOfSight = true; if (isDarwinAboveSnakeSomewhere(darwin)) { lineOfSightDirection = Direction.Up; } if (isDarwinBelowSnakeSomewhere(darwin)) { lineOfSightDirection = Direction.Down; } if (isDarwinRightOfSnakeSomewhere(darwin)) { lineOfSightDirection = Direction.Right; } if (isDarwinLeftOfSnakeSomewhere(darwin)) { lineOfSightDirection = Direction.Left; } } else { lineOfSight = false; this.RandomWalk(); } movecounter = 0; } else { allowedToWalk = false; } movecounter++; snakeDelayCounter++; }
public void Update(GameTime gameTime, Darwin darwin, LinkedList<Flame> flames) { //base.Update(gameTime); if (movecounter > ZOMBIE_MOVE_RATE) { allowedToWalk = true; // snakes can die in fire if(flames != null) this.checkForFieryDeath(flames); if (snakeDelayCounter > (ZOMBIE_MOVE_RATE * 5)) { snakeDelayCounter = 0; delaySnakeCounter = false; } if (!delaySnakeCounter && (isDarwinAboveSnakeSomewhere(darwin) || isDarwinBelowSnakeSomewhere(darwin) || isDarwinRightOfSnakeSomewhere(darwin) || isDarwinLeftOfSnakeSomewhere(darwin))) { lineOfSight = true; if (isDarwinAboveSnakeSomewhere(darwin) ){ lineOfSightDirection = Direction.Up; } if (isDarwinBelowSnakeSomewhere(darwin)){ lineOfSightDirection = Direction.Down; } if (isDarwinRightOfSnakeSomewhere(darwin)) { lineOfSightDirection = Direction.Right; } if (isDarwinLeftOfSnakeSomewhere(darwin)) { lineOfSightDirection = Direction.Left; } } else { lineOfSight = false; this.RandomWalk(); } movecounter = 0; } else { allowedToWalk = false; } movecounter++; snakeDelayCounter++; }
public void Update(Darwin darwin) { // if darwin is on top of the leaf if (darwin.isOnTop(this)) { // we want to break it, and wake up the zombie who is listening to it breakLeaf(); parentZombie.wakeUp(); parentZombie.assignLeaf(this); } }
/** * checks whether or not darwin is in the zombies range * returns true if he is, false otherwise */ public bool isDarwinInRange(Darwin darwin) { if (darwin.X <= maxX && darwin.X >= minX && darwin.Y >= minY && darwin.Y <= maxY) { return(true); } else { return(false); } }
/* * checks if darwin is on the dance floor or not * that is, is darwin inside the patrol path * Point must be set up so top left pt is first, * bottom right pt is 3rd * */ public bool isDarwinOnFloor(Darwin myDarwin) { // Vector2 minPt = pathList[0]; Vector2 maxPt = pathList[2]; if (myDarwin.X >= minPt.X && myDarwin.X <= maxPt.X && myDarwin.Y >= minPt.Y && myDarwin.Y <= maxPt.Y) return true; else return false; }
private void ProcessChange(Darwin.Objects.SeasonCheckbox c) { if (c.Checked) { SpeciesFlagInformation |= (c).SeasonFlag; } else { SpeciesFlagInformation ^= (c).SeasonFlag; } }
// make sure sprite is facing darwin private void updateFacingDarwin(Darwin darwin) { if (darwin.X <= this.X) { darwinDirection = Direction.Left; } else { darwinDirection = Direction.Right; } }
// methods for moving darwin when the snake comes into contact with him public void pushDarwinUp(Darwin darwin) { if (board.isGridPositionOpen(darwin.X, darwin.Y - 1)) { darwin.MoveUp(); if (board.isGridPositionOpen(this.X, this.Y - 1)) { this.MoveUp(); } } }
public void pushDarwinDown(Darwin darwin) { if (board.isGridPositionOpen(darwin.X, darwin.Y + 1)) { darwin.MoveDown(); if (board.isGridPositionOpen(this.X, this.Y + 1)) { this.MoveDown(); } } }
public void pushDarwinLeft(Darwin darwin) { if (board.isGridPositionOpen(darwin.X - 1, darwin.Y)) { darwin.MoveLeft(); if (board.isGridPositionOpen(this.X - 1, this.Y)) { this.MoveLeft(); } } }
/// <summary> /// Once the zombie has seen Darwin, he wants to chase after him to eat his brains /// </summary> public void chaseDarwin(Darwin darwin) { // do this better later if (this.X < darwin.X) this.MoveRight(); else if (this.X > darwin.X) this.MoveLeft(); else if (this.Y < darwin.Y) this.MoveDown(); else if (this.Y > darwin.Y) this.MoveUp(); }
/* * checks if darwin is on the conga line path or not * that is, is darwin on the patrol path * Point must be set up so top left pt is first, * bottom right pt is 3rd * */ public bool isDarwinOnPath(Darwin myDarwin) { // Vector2 minPt = pathList[0]; Vector2 maxPt = pathList[2]; if ((myDarwin.X >= minPt.X && myDarwin.X <= maxPt.X && (myDarwin.Y == minPt.Y || myDarwin.Y == maxPt.Y)) || ((myDarwin.X == minPt.X || myDarwin.X == maxPt.X) && myDarwin.Y >= minPt.Y && myDarwin.Y <= maxPt.Y)) return true; else return false; }
// you should set ranges to whole board public CongaLeaderZombie(int startX, int startY, int mymaxX, int myminX, int mymaxY, int myminY, Vector2[] myPathList, Darwin mydarwin, GameBoard myboard) : base(startX, startY, mymaxX, myminX, mymaxY, myminY, myboard) { allowRangeDetection = false; allowVision = true; visionMaxX = 6; visionMaxY = 6; darwin = mydarwin; pathList = myPathList; ZOMBIE_MOVE_RATE = 20; followerZombies = new List<CongaFollowerZombie>(); }
// checks squares that boss inhabits for darwin public bool isInCollision(Darwin myDarwin) { if ((this.X == darwin.X && this.Y == darwin.Y) || (this.X + 1 == darwin.X && this.Y == darwin.Y) || (this.X + 2 == darwin.X && this.Y == darwin.Y) || (this.X == darwin.X && this.Y + 1 == darwin.Y) || (this.X + 1 == darwin.X && this.Y + 1 == darwin.Y) || (this.X + 2 == darwin.X && this.Y + 1 == darwin.Y) || (this.X == darwin.X && this.Y + 2 == darwin.Y) || (this.X + 1 == darwin.X && this.Y + 2 == darwin.Y) || (this.X + 2 == darwin.X && this.Y + 2 == darwin.Y)) { return(true); } else { return(false); } }
// set ranges to whole board public CongaFollowerZombie(int startX, int startY, int mymaxX, int myminX, int mymaxY, int myminY, Vector2[] myPathList, CongaLeaderZombie myLeader, Darwin mydarwin, GameBoard myboard) : base(startX, startY, mymaxX, myminX, mymaxY, myminY, myboard) { allowRangeDetection = false; allowVision = true; visionMaxX = 4; visionMaxY = 4; darwin = mydarwin; pathList = myPathList; ZOMBIE_MOVE_RATE = 20; startPosit = new Vector2(startX, startY); leaderZombie = myLeader; }
// set ranges to whole board public CongaFollowerZombie(int startX, int startY, int mymaxX, int myminX, int mymaxY, int myminY, Vector2[] myPathList,CongaLeaderZombie myLeader, Darwin mydarwin, GameBoard myboard) : base(startX, startY, mymaxX, myminX, mymaxY, myminY, myboard) { allowRangeDetection = false; allowVision = true; visionMaxX = 4; visionMaxY = 4; darwin = mydarwin; pathList = myPathList; ZOMBIE_MOVE_RATE = 20; startPosit = new Vector2(startX,startY); leaderZombie = myLeader; }
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; } } }
static void Main(string[] args) { var score = 0d; while (score < 490) { var d = new Darwin(x => new Simulator(new DnaCleaner(x)).AverageScore(100)); var dna = d.Evolove(1000); var c = new DnaCleaner(dna); var s = new Simulator(c); score = s.AverageScore(); Console.WriteLine($"Score: {score}"); } }
/** * Initalizes a cannibal on the game board * * Arguments * int startX, startY -- start position of cannibal * int mymaxX, mymaxY, myminX, myminY -- range that cannibal can walk around in * List myListZombies -- list of the other non-cannibal zombies on the board * Darwin mydarwin -- reference to Darwin * Gameboard myboard -- board that cannibal is to be played on */ public CannibalZombie(int startX, int startY, int mymaxX, int myminX, int mymaxY, int myminY, List <Zombie> myListZombies, Darwin mydarwin, GameBoard myboard) : base(startX, startY, mymaxX, myminX, mymaxY, myminY, myboard) { allowRangeDetection = false; allowVision = true; goAroundMode = false; visionMaxX = 6; visionMaxY = 6; pathCount = 0; pathLimit = 0; darwin = mydarwin; zombies = myListZombies; ZOMBIE_MOVE_RATE = 40; }
/** * Initalizes a cannibal on the game board * * Arguments * int startX, startY -- start position of cannibal * int mymaxX, mymaxY, myminX, myminY -- range that cannibal can walk around in * List myListZombies -- list of the other non-cannibal zombies on the board * Darwin mydarwin -- reference to Darwin * Gameboard myboard -- board that cannibal is to be played on */ public CannibalZombie(int startX, int startY, int mymaxX, int myminX, int mymaxY, int myminY,List<Zombie> myListZombies,Darwin mydarwin,GameBoard myboard): base(startX,startY,mymaxX,myminX, mymaxY, myminY, myboard) { allowRangeDetection = false; allowVision = true; goAroundMode = false; visionMaxX = 6; visionMaxY = 6; pathCount = 0; pathLimit = 0; darwin = mydarwin; zombies = myListZombies; ZOMBIE_MOVE_RATE=40; }
/* * checks if darwin is on the dance floor or not * that is, is darwin inside the patrol path * Point must be set up so top left pt is first, * bottom right pt is 3rd * */ public bool isDarwinOnFloor(Darwin myDarwin) { // check for actual min.max points Vector2 minPt = getMinPtOnPath(); Vector2 maxPt = getMaxPtOnPath(); if (myDarwin.X >= minPt.X && myDarwin.X <= maxPt.X && myDarwin.Y >= minPt.Y && myDarwin.Y <= maxPt.Y) { return(true); } else { return(false); } }
/// <summary> /// At this point on the grid, look around for Darwin. /// </summary> public void lookForDarwin(Darwin darwin) { if (this.isPointInVision(darwin.X, darwin.Y)) { chaseDarwin(darwin); } else { this.goBackToSleep(); } // if see darwin // chaseDarwin() // else // this.goBackToSleep() }
/* * checks if darwin is on the conga line path or not * that is, is darwin on the patrol path * Point must be set up so top left pt is first, * bottom right pt is 3rd * */ public bool isDarwinOnPath(Darwin myDarwin) { // Vector2 minPt = getMinPtOnPath(); Vector2 maxPt = getMaxPtOnPath(); if ((myDarwin.X >= minPt.X && myDarwin.X <= maxPt.X && (myDarwin.Y == minPt.Y || myDarwin.Y == maxPt.Y)) || ((myDarwin.X == minPt.X || myDarwin.X == maxPt.X) && myDarwin.Y >= minPt.Y && myDarwin.Y <= maxPt.Y)) { return(true); } else { return(false); } }
public void SelectsRandomDnaWeightedByFitnessExcluding() { // Arrange float totalFitness = 0f; List <Dna> parentPool = Enumerable.Range(0, 5) .Select((_) => Dna.GenerateRandomDnaEncoding(1, new int[] { 1 }, 1, ActivationType.BinaryStep, false)) .Select((dna, index) => { dna.RawFitnessRating = Mathf.Pow(index, 2); totalFitness += dna.RawFitnessRating; return(dna); }) .ToList(); Dna excludedDna = parentPool[3]; // second fitess dna totalFitness -= excludedDna.RawFitnessRating; // List<Dna> remainingCandidatePool = parentPool.FindAll(dna => dna != excludedDna); Dictionary <Dna, float> expectedProportions = parentPool.ToDictionary( dna => dna, dna => dna == excludedDna ? 0 : dna.RawFitnessRating / totalFitness ); // Act int sampleSize = 100000; Dictionary <Dna, int> selectionResults = parentPool.ToDictionary(dna => dna, dna => 0); for (int i = 0; i < sampleSize; i++) { selectionResults[Darwin.SelectRandomBasedOnFitness(parentPool, excludedDna)]++; } // Assert Dictionary <Dna, float> actualProportions = selectionResults.ToDictionary( kvp => kvp.Key, kvp => (float)kvp.Value / (float)sampleSize ); selectionResults[excludedDna].Should().Be(0, "excluded was never selected"); foreach (Dna dna in parentPool) { actualProportions[dna].Should().BeApproximately(expectedProportions[dna], 0.01f, "proportion was within 1% of expected value"); } }
//private Vector2[] spawnPoints; public Nursery(GameBoard gb, Darwin darwin) : base(gb) { babies = new BabyZombie[maxBabies]; /*spawnPoints = new Vector2[10]; for (int i = 0; i < 10; i++) { spawnPoints[i] = new Vector2(); } */ for (int i = 0; i < maxBabies; i++) { babies[i] = new BabyZombie(0, 0, 32, 0, 24, 0, darwin, gb); babies[i].setZombieAlive(false); } this.setEventLag(babyTimeSpawn); this.destination.Height = board.getSquareLength() * 3; this.destination.Width = board.getSquareWidth() * 2; }
public bool isDarwinRightOfSnakeSomewhere(Darwin darwin) { if (darwin.Y == this.Y && darwin.X > this.X) { return true; } return false; }
/** * checks whether or not darwin is in the zombies range * returns true if he is, false otherwise */ public bool isDarwinInRange(Darwin darwin) { if (darwin.X <= maxX && darwin.X >= minX && darwin.Y >= minY && darwin.Y <= maxY) return true; else return false; }
/** * 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(); } } } }
private void StartSearch(Darwin.Enum.SearchType t = Enum.SearchType.Normal) { int statusin = -1; try { statusin = Int32.Parse(cbStatus.SelectedValue.ToString()); } catch { } SearchResults s = new SearchResults(t, cbKingdom.SelectedValue, cbPhylum.SelectedValue, cbClass.SelectedValue, cbOrder.SelectedValue, cbFamily.SelectedValue, cbGenus.SelectedValue, txtName.Text, txtAnySearch.Text, monthPicker1.GetMonthsInformation(), speciesFlags1.GetSpeciesInformation(), distributionPicker1.GetDistributionInformation(), speciesColourUC1.GetSelectedColour(), cbYVP.Checked, statusin); s.StartPosition = FormStartPosition.CenterScreen; s.Show(); }
// 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++; } }
// check for darwins relative position to snake public bool isDarwinAboveSnakeSomewhere(Darwin darwin) { if(darwin.X == this.X && darwin.Y < this.Y){ return true; } return false; }
public bool isDarwinDirectlyBelowSnake(Darwin darwin) { if ((this.Y + 1 == darwin.Y) && darwin.X == this.X) { return true; } return false; }
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 bool isDarwinDirectlyRightOfSnake(Darwin darwin) { if ((this.X + 1 == darwin.X) && darwin.Y == this.Y) { return true; } return false; }
public void pushDarwinDown(Darwin darwin) { if(board.isGridPositionOpen(darwin.X, darwin.Y + 1)) { darwin.MoveDown(); if (board.isGridPositionOpen(this.X, this.Y + 1)) { this.MoveDown(); } } }
public void pushDarwinRight(Darwin darwin) { if (board.isGridPositionOpen(darwin.X + 1, darwin.Y)) { darwin.MoveRight(); if (board.isGridPositionOpen(this.X + 1, this.Y)) { this.MoveRight(); } } }
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 bool isDarwinBelowSnakeSomewhere(Darwin darwin) { if (darwin.X == this.X && darwin.Y > this.Y) { return true; } return false; }