예제 #1
0
        private void goThroughTheDoor_Click(object sender, EventArgs e)
        {
            moves++;
            IHasExteriorDoor hasDoor = currentLocation as IHasExteriorDoor;

            MoveToANewLocation(hasDoor.DoorLocation);
        }
예제 #2
0
        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;
                }
            }
        }
예제 #3
0
        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;
                }
            }
        }
예제 #4
0
        private void goThrough_Click(object sender, EventArgs e)
        {
            IHasExteriorDoor hasDoor = currentLocation as IHasExteriorDoor;

            MoveToNewLocation(hasDoor.DoorLocation);
            stepsNeededToFindOpponent++;
        }
예제 #5
0
        private void goThroughTheDoor_Click(object sender, EventArgs e)
        {
            //считаем, что если на эту кнопку получилось нажать, то это гарантирует, что нисходящее приведение выполнится успешно
            IHasExteriorDoor hasDoor = CurrentLocation as IHasExteriorDoor;

            MoveToANewLocation(hasDoor.DoorLocation);
        }
예제 #6
0
        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;
                }
            }
        }
예제 #7
0
        /// <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);
        }
예제 #8
0
        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;
                }
            }
        }
예제 #9
0
        private void goThroughDoor_Click(object sender, EventArgs e)
        {
            IHasExteriorDoor hasDoor = CurrentLocation as IHasExteriorDoor;

            MoveToLocation(hasDoor.DoorLocation);
            Moves++;
        }
예제 #10
0
        private void goThroughTheDoor_Click(object sender, EventArgs e)
        {
            //downcast to gain access to doorloacation field
            IHasExteriorDoor hasDoor = currentLocation as IHasExteriorDoor;

            MoveToANewLoacation(hasDoor.DoorLocation);
        }
예제 #11
0
        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;
            //}
        }
예제 #12
0
        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;
                }
            }
        }
예제 #13
0
 private void goThroughTheDoor_Click(object sender, EventArgs e)
 {
     if (currentLocation is IHasExteriorDoor)
     {
         IHasExteriorDoor withDoor = currentLocation as IHasExteriorDoor;
         MoveToANewLocation(withDoor.DoorLocation);
     }
 }
예제 #14
0
        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);
        }
예제 #15
0
파일: Form1.cs 프로젝트: GvidasN/HideNSeek
 private void button2_Click(object sender, EventArgs e)
 {
     if (CurrentLocation is IHasExteriorDoor)
     {
         IHasExteriorDoor NewLocation = CurrentLocation as IHasExteriorDoor;
         GoTo(NewLocation.DoorLocation);
     }
 }
예제 #16
0
        private void goThroughTheDoor_Click(object sender, EventArgs e)
        {
            IHasExteriorDoor 門 = 目前位置 as IHasExteriorDoor;

            //用 as 關鍵字 將 目前位置 強制向下轉換為 IHasExteriorDoor,
            //以方便訪問 DoorLocation 字串
            MoveToANewLocation(門.DoorLocation);
        }
예제 #17
0
        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));
        }
예제 #18
0
        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");
            }
        }
예제 #19
0
파일: Form1.cs 프로젝트: Dare7890/Courses
 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;
     }
 }
예제 #20
0
        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();
            }
        }
예제 #21
0
 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;
         }
     }
 }
예제 #22
0
 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);
 }
예제 #23
0
파일: Opponent.cs 프로젝트: blaec/House
 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;
         }
     }
 }
예제 #24
0
        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();
            }
        }
예제 #25
0
        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;
                }
            }
        }
예제 #26
0
 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));
 }
예제 #27
0
        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;
                }
            }
        }
예제 #28
0
        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;
                }
            }
        }
예제 #29
0
        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;
                }
            }
        }
예제 #30
0
        private void goThroughTheDoor_Click(object sender, EventArgs e)
        {
            IHasExteriorDoor exitDoor = currentLocation as IHasExteriorDoor;

            MoveToANewLocation(exitDoor.DoorLocationn);
        }