Example #1
0
 public Pit(int id, Room room)
 {
     this.id = id;
     this.Type = EntityType.pit;
     location = room;
     location.addOccupant(this);
     UnityEngine.Debug.Log("Pit " + id + " is born in Room " + (location.id + 1));
 }
Example #2
0
 public void move(Room room)
 {
     location.removeOccupant(this);  //leave the current room
         location = room;
         location.addOccupant(this);         //enter the new Room.
         //Debug.WriteLine("Arrow.move(): The arrow is in Room " + (location.id + 1));
         //Console.WriteLine("The arrow is in Room " + (location.id + 1));
 }
Example #3
0
 //TODO: Change the bat name to int id...
 public Bat(string name, Room room)
 {
     //isAlive = true;
     this.name = name;
     this.Type = EntityType.bat;
     location = room;
     location.addOccupant(this);
     UnityEngine.Debug.Log("Bat " + name + " is born in Room " + (location.id + 1));
 }
Example #4
0
 public Wumpus(string name, Room room)
 {
     isAlive = true;
         this.name = name;
         this.Type = EntityType.wumpus;
         metPlayer = false;
         location = room;
         location.addOccupant(this);
         dice = new System.Random();
         System.Diagnostics.Debug.WriteLine("Wumpus is born in Room " + (location.id + 1));
 }
Example #5
0
 public void move(Room room)
 {
     if (location == null){
         location = room;
         location.addOccupant(this);
         }
     else {
         location.removeOccupant(this);  //leave the current room
         location = room;
         location.addOccupant(this);         //enter the new Room.
         }
     UnityEngine.Debug.Log("Player is now in Room " + (location.id + 1));
     this.sense();
 }
Example #6
0
    public void fly(List<Room> path, Room current, Wumpus target)
    {
        //Random rand = new Random();
            location = current;
            location.addOccupant(this);
            int flightLength = 0;

            //TODO: this is ugly, clean up later
            foreach (Room room in path){   //check current length of flight
                if (flightLength < maxFlight){
                    if (location.hasOccupant(target)){
                        target.die();
                        //Console.WriteLine("Aha! You got the Wumpus!");
                        return;
                        }
                    //check if rooms are connected
                    if (location.hasNeighbor(room)){
                        move(room);
                        }
                    else{
                        //Console.WriteLine("Room " + (location.id + 1) + " is not neighbors with Room " +
                                                //	(room.id + 1) + "! Picking another room...");
                        int i = Random.Range(0, location.neighbors.Count - 1);
                        move(location.neighbors[i]);
                        }
                    if (location == current){
                        //Console.WriteLine("Ouch! The arrow got you!");
                        break;
                        }
                    flightLength++;
                    }
            }
            //Console.WriteLine("Missed!");
            target.wake();  //wake the wumpus if you miss
            used = true;
    }
Example #7
0
 public void move(Room room)
 {
     if (location == null){
             location = room;
             location.addOccupant(this);
             }
         else    {
             location.removeOccupant(this);  //leave the current room
             location = room;
             location.addOccupant(this);         //enter the new Room.
             }
         System.Diagnostics.Debug.WriteLine("Wumpus.move() : " + name + " has moved to Room " + (location.id + 1));
 }
Example #8
0
 public void addOccupant(IEntity occupant, Room room)
 {
     occupants.Add(occupant);
     room.addOccupant(occupant);
 }