示例#1
0
 public bool TryMoveForward() //move where this unit looks. returns true if the unit has moved.
 {
     if (World.IsPassable(CoordX + lookX, CoordY + lookY))
     {
         Timing.AddActionTime(TimeCost.MoveCost(this));
         CoordX += lookX;
         CoordY += lookY;
         return(true);
     }
     return(false);
 }
示例#2
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.");
            }
        }
示例#3
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);
 }
示例#4
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));
        }