Exemple #1
0
        void peepDialogue()
        {
            Log.AddLine("Peep in which direction?");
            ConsoleKeyInfo keyPressed = Console.ReadKey(true);

            KeyToVector.ProcessInput(keyPressed);
            int peepX = CoordX + KeyToVector.x, peepY = CoordY + KeyToVector.y;

            if (peepX == CoordX && peepY == CoordY)
            {
                int randomMessageNumber = MyRandom.getRandomInt(3);
                switch (randomMessageNumber)
                {
                case 0:
                    Log.AddLine("You feel SO introversive for a moment");
                    break;

                case 1:
                    Log.AddLine("You peep yourself. So interesting");
                    break;

                case 2:
                    Log.AddLine("If you wanna, hm, look at yourself, get a room, please.");
                    break;
                }
                return;
            }
            //don't peep through walls anymore! :D
            if (World.IsPassable(peepX, peepY) || World.IsDoorPresent(peepX, peepY))
            {
                isPeeping = true;
                lastPeepX = peepX;
                lastPeepY = peepY;
                WorldRendering.drawInCircleFOV(peepX, peepY, visibilityRadius);
                WorldRendering.drawUnitsInCircle(peepX, peepY, visibilityRadius);
                this.Draw();
                Console.ForegroundColor = ConsoleColor.Gray;
                Timing.AddActionTime(TimeCost.CloseDoorCost(this));
                Log.ReplaceLastLine("You carefully peep in that direction... Press space or esc to stop");
                keyPressed = Console.ReadKey(true);
                if (keyPressed.Key == ConsoleKey.Spacebar || keyPressed.Key == ConsoleKey.Escape)
                {
                    isPeeping = false;
                    Log.ReplaceLastLine("You carefully peep in that direction...");
                }
            }
            else
            {
                Log.ReplaceLastLine("You try to peep through this, but in vain.");
            }
        }
Exemple #2
0
 public void MoveOrOpenOrAttack(int x, int y) //-1 or 0 or 1 for x and y
 {
     if (World.IsDoorPresent(CoordX + x, CoordY + y))
     {
         if (World.TryUnlockDoor(CoordX + x, CoordY + y, Inv.GetAllKeys))
         {
             Timing.AddActionTime(TimeCost.OpenDoorCost(this));
             Log.AddLine("You have unlocked the door with your key.");
             return;
         }
         if (World.TryOpenDoor(CoordX + x, CoordY + y))
         {
             Timing.AddActionTime(TimeCost.OpenDoorCost(this));
             Log.AddLine("You opened the door.");
             return;
         }
     }
     if (World.IsPassable(CoordX + x, CoordY + y))
     {
         CoordX += x;
         CoordY += y;
         Timing.AddActionTime(TimeCost.MoveCost(this));
         if (World.isItemPresent(CoordX, CoordY))
         {
             List <Item> list = World.getItemListAt(CoordX, CoordY);
             int         numberOfItemsOnFloor = list.Count();
             if (numberOfItemsOnFloor > 1)
             {
                 Log.AddLine("You see here: " + list[0].DisplayName + " and " + (numberOfItemsOnFloor - 1).ToString() + " more items");
             }
             else
             {
                 Log.AddLine("You see here: " + list[0].DisplayName);
             }
         }
         return;
     }
     if (World.isActorPresent(CoordX + x, CoordY + y))
     {
         Actor attacked = World.getActorAt(CoordX + x, CoordY + y);
         Attack.MeleeAttack(this, attacked);
     }
     else if (!World.IsPassable(CoordX + x, CoordY + y))
     {
         Log.AddLine("Locked! You need a key.");
     }
     //World.Redraw(CoordX-x, CoordY-y);
 }
Exemple #3
0
        void turnToRandomPassableDirection() //turn to random direction which is passable
        {
            int newLookX, newLookY;
            int tries = 0;

            do
            {
                newLookX = MyRandom.getRandomInt(-1, 2);
                newLookY = MyRandom.getRandomInt(-1, 2);

                if (tries > 50)
                {
                    break;             //this is
                }
                tries++;               //a quite dirty workaround
            } while ((newLookX == 0 && newLookY == 0) || !World.IsPassable(CoordX + newLookX, CoordY + newLookY));
            turnToDirection(newLookX, newLookY);
            Timing.AddActionTime(TimeCost.GuardWait(this));
        }
Exemple #4
0
        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...");
            }
        }
Exemple #5
0
        void strangleDialogue()
        {
            Log.AddLine("Grab in which direction?");
            ConsoleKeyInfo keyPressed = Console.ReadKey(true);

            KeyToVector.ProcessInput(keyPressed);
            int strangleX = CoordX + KeyToVector.x, strangleY = CoordY + KeyToVector.y;

            if (strangleX == CoordX && strangleY == CoordY)
            {
                int randomMessageNumber = MyRandom.getRandomInt(3);
                switch (randomMessageNumber)
                {
                case 0:
                    Log.AddLine("Wanna strangle yourself huh?");
                    break;

                case 1:
                    Log.AddLine("Suicide will not help with your mission.");
                    break;

                case 2:
                    Log.AddLine("If you wanna touch yourself, get a room, please.");
                    break;
                }
                return;
            }
            if (World.isActorPresent(strangleX, strangleY))
            {
                Attack.Strangle(this, World.getActorAt(strangleX, strangleY));
                Timing.AddActionTime(TimeCost.StrangleCost(this));
            }
            else
            {
                Log.AddLine("There's nobody here!");
            }
        }
Exemple #6
0
 public void handleKeys(ConsoleKeyInfo keyPressed)
 {
     if (isPeeping)
     {
         Timing.AddActionTime(TimeCost.ContinuePeepCost(this));
         ContinuePeep(keyPressed);
         return;
     }
     //MOVING/WAITING
     if (keyPressed.Key == ConsoleKey.NumPad5) //skip turn
     {
         Timing.AddActionTime(TimeCost.SkipTurnCost(this));
         return;
     }
     KeyToVector.ProcessInput(keyPressed);
     if (KeyToVector.ProperButtonPressed)
     {
         MoveOrOpenOrAttack(KeyToVector.x, KeyToVector.y);
     }
     //ACTIONS
     if (keyPressed.Key == ConsoleKey.D1)
     {
         seeTheStats();
     }
     if (keyPressed.Key == ConsoleKey.C) //close door
     {
         closeDoorDialogue();
     }
     if (keyPressed.Key == ConsoleKey.D) //drop an item
     {
         Inv.DropDialogue();
     }
     if (keyPressed.Key == ConsoleKey.F) //fire current weapon
     {
         shootDialogue();
     }
     if (keyPressed.Key == ConsoleKey.G) //grab (pick up) an item
     {
         Inv.PickupDialogue();
     }
     if (keyPressed.Key == ConsoleKey.I) //show inventory
     {
         Inv.ShowInventory();
     }
     if (keyPressed.Key == ConsoleKey.P) //peep
     {
         peepDialogue();
     }
     if (keyPressed.Key == ConsoleKey.S) //strangle
     {
         strangleDialogue();
     }
     if (keyPressed.Key == ConsoleKey.W) //wield a weapon
     {
         Inv.WieldDialogue();
     }
     if (keyPressed.Key == ConsoleKey.Q) //ready the ammo
     {
         Inv.ReadyAmmoDialogue();
     }
     if (keyPressed.Key == ConsoleKey.R) //reload a gun
     {
         Inv.ReloadDialogue();
     }
     //TODO!
 }