public PieceSprite(Texture2D textureImage, Vector2 position, Point frameSize, int collisionOffset, Point currentFrame, Point sheetSize, Vector2 speed, SpriteFont font, Room room) : base(textureImage, position, frameSize, collisionOffset, currentFrame, sheetSize, speed, null, font) { this.room = room; }
public WGame(Game game) { this.game = game; board = new Board(); status = "Start"; turn = "wumpus"; bumped = false; prevRoom = Board.Player.Room; }
// All parameters with default values public Room(int room, Room[] adjRooms = null, bool player = false, bool wumpus = false, Hazard hazard = null) { roomNumber = room; adjacentRooms = adjRooms; this.player = player; this.wumpus = wumpus; this.hazard = hazard; }
// Start room public Player(Room start) { room = start; arrows = new Arrow[]{ new Arrow(), new Arrow(), new Arrow(), new Arrow(), new Arrow() }; }
/****************************************************************************************** * Constructors *****************************************************************************************/ // No parameters public Player() { room = null; arrows = new Arrow[]{ new Arrow(), new Arrow(), new Arrow(), new Arrow(), new Arrow() }; }
public static void gameStatus() { // Only update the status if the player moves if (Board.Player.Room != prevRoom) { // Set previous room to current room prevRoom = Board.Player.Room; // Wumpu's turn turn = "Wumpus"; // Did the player bump the Wumpus if (bumped && Board.Wumpus.Room.Number == Board.Player.Room.Number) { status = "Eaten"; } else if (!bumped && Board.Wumpus.Room.Number == Board.Player.Room.Number) { status = "Bumped"; bumped = true; Board.Wumpus.Awake = true; } // Did the player fall into a pit? else if (Board.Player.Room.Hazard != null) { if (Board.Player.Room.Hazard.Type == "pit") { status = "Pit"; } } // Room is empty else { status = "Play"; } } // Did a Superbat moved the player else if (Board.RandomMove) { Board.RandomMove = false; status = "Superbat"; } }
/****************************************************************************************** * Constructors *****************************************************************************************/ // No parameters public Hazard() { room = null; type = "None"; }
// Start room and arrows public Player(Room start, Arrow[] arrows) { room = start; this.arrows = arrows; }
/****************************************************************************************** * Shoot Arrow * * @property rooms - Array of rooms to send to trajectory * * First convert the integer room numbers to Room objects via the map. Then set the * trajectory for the arrow. The arrow will check if it hit the Wumpus and return the * result. *****************************************************************************************/ public bool shoot(Arrow arrow, int[] roomNumbers) { Room[] rooms = new Room[5]; // Convert each roomNumber into a room foreach (int room in roomNumbers) { rooms[room - 1] = Board.Map[room]; } // Set trajectory (Shoot arrow) arrow.Trajectory = rooms; // Return whether the arrow killed the Wumpus return arrow.KillWumpus; }
/****************************************************************************************** * Move Player * * @property rooms - Array of rooms to send to trajectory * * Sets the room room for the player to the Room object in the map corresponding to * the integer room number entered. *****************************************************************************************/ public void move(int roomNumber) { room = Board.Map[roomNumber]; }
/****************************************************************************************** * Constructors *****************************************************************************************/ //No parameters public Wumpus() { room = null; awake = false; alive = true; }
// Trajectory public Arrow(Room[] traj) { trajectory = traj; shot = true; killWumpus = false; }
// Room and Sleep state public Wumpus(Room room, bool state) { this.room = room; awake = state; alive = true; }
// Room public Wumpus(Room room) { this.room = room; awake = false; alive = true; }
// Type public Hazard(string type) { room = null; this.type = type; }
// Type and room public Hazard(string type, Room room) { this.type = type; this.room = room; }
/****************************************************************************************** * Move Wumpus * * @property random - Random number generator * * Once awake, the Wumpus has a 75% chance of moving each turn *****************************************************************************************/ public void move() { Random random = new Random(); // Move Wumpus if (random.Next(1, 100) >= 25) { Room oldRoom = room; room = room.randomRoom(); oldRoom.Wumpus = false; room.Wumpus = true; } // Check to see if killed player if (room.Number == Board.Player.Room.Number) { Board.Player.Alive = false; } }