private void goThroughTheDoor_Click(object sender, EventArgs e) { moves++; IHasExteriorDoor hasDoor = currentLocation as IHasExteriorDoor; MoveToANewLocation(hasDoor.DoorLocation); }
public void Move() { bool hidden = false; while (!hidden) { //If my location has an exterior door, "flip a coin" to determine whether to go through the exterior door. if (myLocation is IHasExteriorDoor) { //Save locationWithDoor as a IHasExteriorDoor. IHasExteriorDoor locationWithDoor = myLocation as IHasExteriorDoor; if (random.Next(2) == 1) { //In that case, move through the exteroir door by reassigning myLocation to locationWithDoor.DoorLocation, brilliantly. myLocation = locationWithDoor.DoorLocation; } } //Move myself to a location via one of the exits, randomly. myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; if (myLocation is IHidingPlace) { hidden = true; } } }
public void Move() { bool hiddingPlace = false; while (!hiddingPlace) { if (myLocation is IHasExteriorDoor) //he is in a room with a door { IHasExteriorDoor doorLocation = myLocation as IHasExteriorDoor; if (random.Next(2) == 1) //he decides to go through that door { myLocation = doorLocation.DoorLocation; //go through the door location in room } } int number = myLocation.Exits.Length; //check the number of room exits myLocation = myLocation.Exits[random.Next(number)]; //go through the one of the room exits //I am going to hide because my location has a door if (myLocation is IHidingPlace) { hiddingPlace = true; } } }
private void goThrough_Click(object sender, EventArgs e) { IHasExteriorDoor hasDoor = currentLocation as IHasExteriorDoor; MoveToNewLocation(hasDoor.DoorLocation); stepsNeededToFindOpponent++; }
private void goThroughTheDoor_Click(object sender, EventArgs e) { //считаем, что если на эту кнопку получилось нажать, то это гарантирует, что нисходящее приведение выполнится успешно IHasExteriorDoor hasDoor = CurrentLocation as IHasExteriorDoor; MoveToANewLocation(hasDoor.DoorLocation); }
public void Move() { bool WhereToHide = false; while (WhereToHide == false) { if (MyLocation is IHasExteriorDoor) { IHasExteriorDoor NewLocation = MyLocation as IHasExteriorDoor; if (random.Next(2) == 1) { MyLocation = NewLocation.DoorLocation; } } int RandomNumber = random.Next(MyLocation.Exits.Length); MyLocation = MyLocation.Exits[RandomNumber]; if (MyLocation is IHidingPlace) { WhereToHide = true; } } }
/// <summary> /// Causes the player to go through door /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void GoThroughTheDoor_Click(object sender, EventArgs e) { IHasExteriorDoor currentLocationVariable = currentLocation as IHasExteriorDoor; MoveToANewLocation(currentLocationVariable.DoorLocation); Log.Information("You have moved to a new location: {0}", currentLocation.Name); }
public void Move() { bool hidden = false; while (!hidden) { if (myLocation is IHasExteriorDoor) { IHasExteriorDoor locationWithDoor = myLocation as IHasExteriorDoor; if (random.Next(2) == 1 || myLocation.Exits.Length == 0) { myLocation = locationWithDoor.DoorLocation; } } if (myLocation.Exits.Length > 0) { int rand = random.Next(myLocation.Exits.Length); myLocation = myLocation.Exits[rand]; } if (myLocation is IHidingPlace) { hidden = true; } } }
private void goThroughDoor_Click(object sender, EventArgs e) { IHasExteriorDoor hasDoor = CurrentLocation as IHasExteriorDoor; MoveToLocation(hasDoor.DoorLocation); Moves++; }
private void goThroughTheDoor_Click(object sender, EventArgs e) { //downcast to gain access to doorloacation field IHasExteriorDoor hasDoor = currentLocation as IHasExteriorDoor; MoveToANewLoacation(hasDoor.DoorLocation); }
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; //} }
public void Move() { bool isHidden = false; while (!isHidden) { if (myLocation is IHasExteriorDoor) { if (random.Next(2) == 1) { IHasExteriorDoor myLocationWithDoor = myLocation as IHasExteriorDoor; myLocation = myLocationWithDoor.DoorLocation; } } int rand = random.Next(myLocation.Exits.Length); myLocation = myLocation.Exits[rand]; if (myLocation is IHidingLocation) { isHidden = true; } } }
private void goThroughTheDoor_Click(object sender, EventArgs e) { if (currentLocation is IHasExteriorDoor) { IHasExteriorDoor withDoor = currentLocation as IHasExteriorDoor; MoveToANewLocation(withDoor.DoorLocation); } }
private void goThroughTheDoor_Click(object sender, EventArgs e) { //currentLocation = (currentLocation as IHasExteriorDoor).DoorLocation; IHasExteriorDoor hasDoor = currentLocation as IHasExteriorDoor; //currentLocation = currentLocation.exits.FirstOrDefault(x => x is OutsideWithDoor); MoveToANewLocation(hasDoor.DoorLocation); }
private void button2_Click(object sender, EventArgs e) { if (CurrentLocation is IHasExteriorDoor) { IHasExteriorDoor NewLocation = CurrentLocation as IHasExteriorDoor; GoTo(NewLocation.DoorLocation); } }
private void goThroughTheDoor_Click(object sender, EventArgs e) { IHasExteriorDoor 門 = 目前位置 as IHasExteriorDoor; //用 as 關鍵字 將 目前位置 強制向下轉換為 IHasExteriorDoor, //以方便訪問 DoorLocation 字串 MoveToANewLocation(門.DoorLocation); }
public void Move() { if (myLocation is IHasExteriorDoor && random.Next(2) == 1) { IHasExteriorDoor locationWithExteriorDoor = myLocation as IHasExteriorDoor; myLocation = locationWithExteriorDoor.DoorLocation; } do { myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; } while (!(myLocation is IHidingPlace)); }
void GoThroughExteriorDoor() { // create an instance of something that implements the interface allow us to // distinguish between class "[...]WithDoor" and not IHasExteriorDoor hasExitDoor = CurrentLocation as IHasExteriorDoor; if (hasExitDoor != null) { MoveToANewLocation(CurrentLocation); } else { throw new ArgumentNullException("Sorry this place hasn't an Exterior Door"); } }
private void goThroughTheDoor_Click(object sender, EventArgs e) { if (currentLocation is IHasExteriorDoor) { IHasExteriorDoor hasExteriorDoor = currentLocation as IHasExteriorDoor; MoveToANewLocation(hasExteriorDoor.DoorLocation); } if (currentLocation is IHidingPlace) { check.Visible = true; } else { check.Visible = false; } }
public void Move() { if (myLocation is IHasExteriorDoor) { if (random.Next(2) == 1) { IHasExteriorDoor outsideLocation = myLocation as IHasExteriorDoor; myLocation = outsideLocation.DoorLocation; } } myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; if (!(myLocation is IHidingPlace)) { Move(); } }
public void Move() { if (myLocation is IHasExteriorDoor) { if (random.Next(2) == 1) { IHasExteriorDoor myDoorLocation = myLocation as IHasExteriorDoor; myLocation = myDoorLocation.DoorLocation; } } while (true) { myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; if (myLocation is IHidingPlace) { return; } } }
public void Move() { if (myLocation is IHasExteriorDoor) { if (1 == random.Next(2)) { IHasExteriorDoor hasDoor = myLocation as IHasExteriorDoor; myLocation = hasDoor.DoorLocation; } else { myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; } } else { myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; } Console.WriteLine(myLocation.Name); }
public void Move() { while (true) { if (myLocation is IHasExteriorDoor) { IHasExteriorDoor locationWithDoor = myLocation as IHasExteriorDoor; if (random.Next(2) == 1) { myLocation = locationWithDoor.DoorLocation; } } int rand = random.Next(myLocation.Exits.Length); myLocation = myLocation.Exits[rand]; if (myLocation is IHidingPlace) { break; } } }
public void Move() { if (myLocation is IHasExteriorDoor) { IHasExteriorDoor nextLocation = myLocation as IHasExteriorDoor; int goThroughDoor = random.Next(2); if (goThroughDoor == 1) { myLocation = nextLocation.DoorLocation; } } int rand = random.Next(myLocation.Exits.Length); myLocation = myLocation.Exits[rand]; IHidingPlace myLocTest = myLocation as IHidingPlace; if (myLocTest == null) { Move(); } }
public void Move() { bool hidden = false; while (!hidden) { if (myLocation is IHasExteriorDoor) { if (random.Next(2) == 1) { IHasExteriorDoor nextLocation = myLocation as IHasExteriorDoor; myLocation = nextLocation.DoorLocation; } } myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; if (myLocation is IHidingPlace) { hidden = true; } } }
public void Move() { do { if (myLocation is IHasExteriorDoor) { if (random.Next(2) == 1) { IHasExteriorDoor ext = myLocation as IHasExteriorDoor; myLocation = ext.DoorLocation; } else { myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; } } else { myLocation = myLocation.Exits[random.Next(myLocation.Exits.Length)]; } } while (!(myLocation is IHidingPlace)); }
public void Move() { bool hiding = false; while (!hiding) { if (myLocation is IHasExteriorDoor) { if (random.Next(2) == 1) { IHasExteriorDoor myExteriorLocation = myLocation as IHasExteriorDoor; myLocation = myExteriorLocation.DoorLocationn; } } int rand = random.Next(myLocation.Exits.Length); myLocation = myLocation.Exits[rand]; if (myLocation is IHidingPlace) { hiding = true; } } }
public void Move() { if (myLocation is IHasExteriorDoor) { IHasExteriorDoor LocationWithDoor = myLocation as IHasExteriorDoor; if (myHidingPlace.Next(2) == 1) { myLocation = LocationWithDoor.DoorLocation; } } bool hidden = false; while (!hidden) { int rand = myHidingPlace.Next(myLocation.Exits.Length); myLocation = myLocation.Exits[rand]; if (myLocation is IHidingPlace) { hidden = true; } } }
public void Move() { bool hide = false; while (!hide) { if (myLocation is IHasExteriorDoor) { if (random.Next(2) == 1) { IHasExteriorDoor temp = myLocation as IHasExteriorDoor; myLocation = temp.DoorLocation; } } int ranNum = random.Next(myLocation.Exits.Length); myLocation = myLocation.Exits[ranNum]; if (myLocation is IHidingPlace) { hide = true; } } }
private void goThroughTheDoor_Click(object sender, EventArgs e) { IHasExteriorDoor exitDoor = currentLocation as IHasExteriorDoor; MoveToANewLocation(exitDoor.DoorLocationn); }