Esempio n. 1
0
 /// <summary>
 /// Uses the item to warp to another location
 /// </summary>
 /// <returns>true if the potion was consumed</returns>
 public override Boolean Use(Human human)
 {
     // Cannot use a crystal when the player is already in the destination map or when there is no item to use
     if (human.battling == 0 && human.area != destination[0] && quantity > 0)
     {
         human.MoveToWorld(destination);
         if (this is WarpCrystal)
             quantity--;
         return true;
     }
     else
         return false;
 }
Esempio n. 2
0
        /// <summary>
        /// Changes between rooms in the area
        /// </summary>
        /// <param name="direction">The direction to move in {horizontal change, vertical change}</param>
        public void ChangeRoom(int[] direction)
        {
            // Clear the old room
            for (int y = 3; y < 16; ++y)
                ConsoleTools.Draw(9, y, "                                 ");
            ConsoleTools.Draw(25, 9, Constants.CharValue("playerToken"));

            // If the room moving to is outside the bounds of the area, it is a boss room
            if (currentRoom[0] + direction[0] < 0 || currentRoom[0] + direction[0] == length
                || currentRoom[1] + direction[1] < 0 || currentRoom[1] + direction[1] == width)

                // If the human has not beat the boss already, fight it
                if (human.progress < human.area)
                {
                    human.Heal();
                    human.battling = 2;
                    Enemy enemy = new Boss(human.area);
                    int result = Battle.Fight(human, enemy);
                    human.battling = 0;
                    if (result > 0)
                    {
                        human += enemy.Reward;
                        human.progress++;
                        human.MoveToWorld(new int[] { 0, 16, 6 });
                    }
                    else if (result == 0)
                    {
                        try
                        {
                            File.Delete(directory + human.SaveFile);
                        }
                        catch (Exception) { }
                        Console.BackgroundColor = ConsoleColor.Black;
                        Console.ForegroundColor = ConsoleColor.White;
                        ConsoleTools.CenterConsole(25, 2);
                        Console.WriteLine("        You Lost!");
                        ConsoleTools.Pause();
                        Environment.Exit(0);
                    }
                }

                // Otherwise move to town
                else
                    human.MoveToWorld(new int[] { 0, 16, 6 });

            // If the room is within the area's bounds, move into it and position the player appropriately
            else
            {
                // Change rooms
                currentRoom[0] += direction[0];
                currentRoom[1] += direction[1];

                // Set the new player position
                if (direction[0] == 1)
                    human.Position = new int[] { 0, human.Position[1] };
                if (direction[0] == -1)
                    human.Position = new int[] { CurrentRoom.HorizontalSize - 1, human.Position[1] };
                if (direction[1] == 1)
                    human.Position = new int[] { human.Position[0], 0 };
                if (direction[1] == -1)
                    human.Position = new int[] { human.Position[0], CurrentRoom.VerticalSize - 1 };

                DisplayStats();
            }
        }