コード例 #1
0
 void DoPatrolling()
 {
     //close door if neccessary
     if (World.TryCloseDoor(CoordX - lookX, CoordY - lookY))
     {
         return;
     }
     //let's SUDDENLY turn to the random direction, maybe? :D
     if (MyRandom.getRandomInt(suddenTurningFrequency) == 0)
     {
         turnToRandomPassableDirection();
         return;
     }
     //Move forward if there is nothing to do...
     if (TryMoveForward())
     {
         return;
     }
     else //or open door if there is. Otherwise turn to random direction
     {
         if (!World.TryOpenDoor(CoordX + lookX, CoordY + lookY))
         {
             turnToRandomPassableDirection();
         }
     }
 }
コード例 #2
0
ファイル: Player.cs プロジェクト: sidav/StealthRoguelike
        void closeDoorDialogue()
        {
            Log.AddLine("Close door in which direction?");
            ConsoleKeyInfo keyPressed = Console.ReadKey(true);

            KeyToVector.ProcessInput(keyPressed);
            int doorX = CoordX + KeyToVector.x, doorY = CoordY + KeyToVector.y;

            if (doorX == CoordX && doorY == CoordY)
            {
                int randomMessageNumber = MyRandom.getRandomInt(3);
                switch (randomMessageNumber)
                {
                case 0:
                    Log.AddLine("Wow. You costumed like a door this Halloween?");
                    break;

                case 1:
                    Log.AddLine("You have almost closed yourself, but suddenly remembered that you're not a door.");
                    break;

                case 2:
                    Log.AddLine("Okay... Try another time");
                    break;
                }
                return;
            }
            if (World.TryCloseDoor(doorX, doorY))
            {
                Timing.AddActionTime(TimeCost.PeepCost(this));
                Log.ReplaceLastLine("You carefully closed the door.");
            }
            else
            {
                Log.ReplaceLastLine("You tried to close this, but something went wrong...");
            }
        }