// CONSTRUCTOR public Enemy(Texture2D[] textures, int x, int y, Player p, Game1 game) : base(x, y, textures) { isActive = true; this.p = p; speed = 3; hitboxImage = textures[2]; direction = DirectionBear.FaceDown; prevX = this.X; prevY = this.Y; timePerFrame = 1.0 / fps; position = new Rectangle(x, y, 50, 100); hitBoxX = x; hitBoxY = y + (100 / 4 * 3); hitBox = new Rectangle(hitBoxX, hitBoxY, position.Width, position.Height / 4); this.game = game; }
//To see what direction state the Bears are in public void BearDirectionCheck() { switch (this.direction) { //For is the character is Facing Down case DirectionBear.FaceDown: if (this.PrevY > this.Y) { this.direction = DirectionBear.WalkDown; } else if (this.PrevX < this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkLeft; } else if (this.PrevY < this.Y) { this.direction = DirectionBear.WalkUp; } else if (this.PrevX > this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkRight; } else { this.direction = DirectionBear.FaceDown; } break; //For is the character is walking down case DirectionBear.WalkDown: if (this.PrevY > this.Y) { this.direction = DirectionBear.WalkDown; } else if (this.PrevX < this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkLeft; } else if (this.PrevY < this.Y) { this.direction = DirectionBear.WalkUp; } else if (this.PrevX > this.X && prevY == this.Y) { this.direction = DirectionBear.WalkRight; } else { this.direction = DirectionBear.FaceDown; } break; //For is the character is facing left case DirectionBear.FaceLeft: if (this.PrevY > this.Y) { this.direction = DirectionBear.WalkDown; } else if (this.PrevX < this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkLeft; } else if (this.PrevY < this.Y) { this.direction = DirectionBear.WalkUp; } else if (this.PrevX > this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkRight; } else { this.direction = DirectionBear.FaceLeft; } break; //For is the character is walking Left case DirectionBear.WalkLeft: if (this.PrevY > this.Y) { this.direction = DirectionBear.WalkDown; } else if (this.PrevX < this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkLeft; } else if (this.PrevY < this.Y) { this.direction = DirectionBear.WalkUp; } else if (this.PrevX > this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkRight; } else { direction = DirectionBear.FaceLeft; } break; //For is the character is facing up case DirectionBear.FaceUp: if (this.PrevY > this.Y) { this.direction = DirectionBear.WalkDown; } else if (this.PrevX < this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkLeft; } else if (this.PrevY < this.Y) { this.direction = DirectionBear.WalkUp; } else if (this.PrevX > this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkRight; } else { this.direction = DirectionBear.FaceUp; } break; //For is the character is walking up case DirectionBear.WalkUp: if (this.PrevY > this.Y) { this.direction = DirectionBear.WalkDown; } else if (this.PrevX < this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkLeft; } else if (this.PrevY < this.Y) { this.direction = DirectionBear.WalkUp; } else if (this.PrevX > this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkRight; } else { this.direction = DirectionBear.FaceUp; } break; //For is the character is facing right case DirectionBear.FaceRight: if (this.PrevY > this.Y) { this.direction = DirectionBear.WalkDown; } else if (this.PrevX < this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkLeft; } else if (this.PrevY < this.Y) { this.direction = DirectionBear.WalkUp; } else if (this.PrevX > this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkRight; } else { this.direction = DirectionBear.FaceRight; } break; //For is the character is walking right case DirectionBear.WalkRight: if (this.PrevY > this.Y) { this.direction = DirectionBear.WalkDown; } else if (this.PrevX < this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkLeft; } else if (this.PrevY < this.Y) { this.direction = DirectionBear.WalkUp; } else if (this.PrevX > this.X && this.PrevY == this.Y) { this.direction = DirectionBear.WalkRight; } else { this.direction = DirectionBear.FaceRight; } break; } }