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) { base.Update(gameTime); // if we be a zombie, we cant use switches if (!darwin.isZombie() && this.canEventHappen()) { this.setEventFalse(); // grab us the current 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)) { toggleSwitch(ks); } break; case (LegendOfDarwin.Darwin.Dir.Right): if (((this.X - 1) == darwin.X) && (this.Y == darwin.Y)) { toggleSwitch(ks); } break; case (LegendOfDarwin.Darwin.Dir.Up): if ((this.X == darwin.X) && ((this.Y + 1) == darwin.Y)) { toggleSwitch(ks); } break; case (LegendOfDarwin.Darwin.Dir.Down): if ((this.X == darwin.X) && ((this.Y - 1) == darwin.Y)) { toggleSwitch(ks); } break; } } }