public void move() { //RoomWithDoor myRoomWithADoor; if(myLocation is IHasExteriorDoor) { IHasExteriorDoor myPlaceWithADoor = myLocation as IHasExteriorDoor; if (random.Next(2) == 1) { //go through the door myLocation = myPlaceWithADoor.DoorLocation; } } do { myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; } while (!(myLocation is IHidingPlace)); //bool hidden = false; //while (!hidden) //{ // int rand = random.Next(myLocation.Exits.Length); // myLocation = myLocation.Exits[rand]; // if (myLocation is IHidingPlace) // hidden = true; //} }
//check public bool Check(Location tryLocation) { if (this.myLocation == tryLocation) return true; // found you! else return false; // Opponent is not there. }
public void ResetOpponent(Location resetLocation) { myLocation = resetLocation; random = new Random(); }
public Opponent(Location startingLocation) { myLocation = startingLocation; random = new Random(); }
private void MoveToANewLocation(Location newLocation) { currentLocation = newLocation; ////clear the olde items with //ExitsComboBox.Items.Clear(); ////initialize the ComboBox list with newlocation's exits. //for (int i = 0; i < newLocation.Exits.Length; i++) //{ // ExitsComboBox.Items.Add(newLocation.Exits[i].Name); //} ////reset the Combo box so it displays the first item in the list. //ExitsComboBox.SelectedIndex = 0; RedrawForm(); ////update current location's description to the text box. //textBox1.Text = currentLocation.Description; ////check if the current location has a door //if (currentLocation is IHasExteriorDoor) //{ // GoThroughTheDoorButton.Visible = true; //} //else //{ // GoThroughTheDoorButton.Visible = false; //} //if (newLocation is IHidingPlace) //{ // check_button.Visible = true; // IHidingPlace myHidingPlace = newLocation as IHidingPlace; // check_button.Text = "Check " + myHidingPlace.HidingPlaceName.ToString() + "\r\n"; //} //else // check_button.Visible = false; }