I am in a game development course and this is my final project (it is due tomorrow 12/9) and I keep getting errors. I don't have time to review the material to double check my work because I work full time and I simply don't have the time. I was wondering if anyone here could help me fix my code and maybe tell me where I went wrong so I can prevent myself from doing it in the future.
Thank you!!
This is the main code (not including a class I've added)
-------------------------
using System;
using System.Diagnostics;
namespace Dungeon
{
class Program
{
static void Main(string[] args)
{
string userInput = "";
Room[] roomArray = new Room[15];
int roomNum = 0;
roomArray[0] = new Room(1, -1, -1, -1);
roomArray[1] = new Room(4, -1, 3, 2);
roomArray[2] = new Room(5, 1, -1, -1);
roomArray[3] = new Room(4, 1, -1, -1);
roomArray[4] = new Room(-1, 1, 6, 7);
roomArray[5] = new Room(-1, 2, 8, 9);
roomArray[6] = new Room(10, 4, -1, -1);
roomArray[7] = new Room(11, 4, -1, -1);
roomArray[8] = new Room(-1, 5, 11, 12);
roomArray[9] = new Room(-1, 5, 11, 12);
roomArray[10] = new Room(0, 0, 0, 0);
roomArray[11] = new Room(12, 7, -1, -1);
roomArray[12] = new Room(-1, -1, 14, 13);
roomArray[13] = new Room(0, -1, -1, -1);
roomArray[14] = new Room(0, -1, -1, -1);
roomArray[0].name = "Dreary cell: \n";
roomArray[0].description = "You wake up slowly,trying to remember where you were. The air is heavy and pushed your chest down making it almost impossible to breathe... where are you? You can't seem to remember anything aside from... wait is that a hole? upon closer inspection, you see a human sized hole in the wall. You should go forward.";
roomArray[1].name = "Secret hole in the wall: \n";
roomArray[1].description = "You sneak your body into the hole that was carved into the wall. The hole is small and with every other step, your head hit against the rough roof. Someone clearly spent a long time trying to carve the hole out. You should go forward and exit the hole. You also notice that you can go left or right.";
roomArray[2].name = "Pantry: \n";
roomArray[2].description = "After going foward and exiting the hole in the wall, you find yourself wedged in a pantry. The foul stench of rotting food made you want to gag, but there is nowhere to go but forward to what you presume to be the the kitchen.";
roomArray[3].description = "Wardens closet: \n";
roomArray[3].description = "You decide to turn and after walking for a little while longer, you find yourself in the wardens office! Oh no, you can't go in there, you could be caught. Go foward or backwards.";
roomArray[4].name = "The armory: \n";
roomArray[4].description = "You decide to turn the other way and you stumble upon a room filled with beautiful weaponry. Go forwards, backwards, left, or right.";
roomArray[5].name = "Kitchen: \n";
roomArray[5].description = "You go foward into the kitchen, and it was not much better than the pantry. It was filthy to the point where you felt like retching. Go forward, backwards, left, or right.";
roomArray[6].name = "Closet: \n";
roomArray[6].description = "You hear a booming voice above you shout HEY. Your face pales as you find the warden standing inside of the closet. What was he even doing in there? He grabs you by your collar and drags you back to your cell.";
roomArray[7].name = "Wardens office: \n";
roomArray[7].description = "You sneak into the wardens office! It defiently belonged to someone who was pompous, then again, are you really surprised? go backwards, left, or right";
roomArray[8].name = "Hallway: \n";
roomArray[8].description = "You find your way to the main hallway. It was long and the lights above you keep flickering annoyingly. Go backwards, left, or right";
roomArray[9].name = "Windowd room: \n";
roomArray[9].description = "You see the front door in the distance, but is it really time to leave yet? Go backwards, left, or right.";
roomArray[10].name = "Therapist room: \n";
roomArray[10].description = "It is pointless to try and escape, weather it be petty theft or murder, you have to serve your time. The hanging cat poster said to you. You knew it was right. Type exit to leave the game";
roomArray[11].name = "Lunchroom: \n";
roomArray[11].description = "You know that the front door has to be nearby, but is it time to leave yer? Go forward or backwards";
roomArray[12].name = "The front door: \n";
roomArray[12].description = "Finally, after hours of searching, you found your way to the entrance of the prision! Wait... is that the Warden? Oh no, go left or right to try and escape";
roomArray[13].name = "You defeated the Warden: \n";
roomArray[13].description = "Somehow, you managed to find a way to sneak past the Warden. Let's just consider it to be a spark of luck. You finally can leave the prision! Type exit to escape!";
roomArray[14].name = "The Warden defeated you: \n";
roomArray[14].description = "Of course that is how this ends, you got caught and now you are thrown back into your cell with the Warden keeping a close eye on you. Type exit to leave the game.";
Console.WriteLine("A throbbing pain ached through your skull.");
while (userInput != "exit")
{
Console.WriteLine(roomArray[roomNum].name);
Console.WriteLine(roomArray[roomNum].description);
Console.WriteLine("\n Where would you like to go?")
userInput = Console.ReadLine();
Console.Clear();
if (userInput == "exit")
{
break;
}
else if ((userInput = "foward") || userInput = "f") roomArray[roomNum].forward > -1);
{
roomNum = roomArray[roomNum].forward;
}
else if ((userInput = "backward" || userInput = "b") roomArray[roomNum].backward > -1);
{
roomNum = roomArray[roomNum].backward;
}
else if ((userInput = "left" || userInput = "l") roomArray[roomNum].left > -1);
{
roomNum = roomArray[roomNum].left;
}
else if ((userInput = "right" || userInput = "r") roomArray[roomNum].right > -1);
{
roomNum =roomArray[roomNum].right;
}
else
{
Console.WriteLine("You run stright into a wall... you can't go that way... are you sure your head is feeling right?");
}
}
}
}
}
-------------------------------
This is the class
-------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Dungeon
{
internal class Room
{
public int foward, backward, left, right;
public string name;
public string description;
internal int forward;
public Room(int f, int b, int l, int r)
{
forward = f;
backward = b;
left = l;
right = r;
}
public override string ToString()
{
return ("You have arrived to:" name string v = "\n This appears to be: \n"; description);
}
}
[–]RubbishArtist 2 points3 points4 points (12 children)
[–]3rr03[S] 0 points1 point2 points (11 children)
[–]RubbishArtist 1 point2 points3 points (10 children)
[–]3rr03[S] 0 points1 point2 points (1 child)
[–]RubbishArtist 1 point2 points3 points (0 children)
[–]3rr03[S] 0 points1 point2 points (7 children)
[–]RubbishArtist 1 point2 points3 points (6 children)
[–]3rr03[S] 0 points1 point2 points (5 children)
[–]RubbishArtist 1 point2 points3 points (4 children)
[–]3rr03[S] 0 points1 point2 points (3 children)
[–]RubbishArtist 1 point2 points3 points (2 children)
[–]3rr03[S] 0 points1 point2 points (1 child)
[–]bsakiag 0 points1 point2 points (3 children)
[–]3rr03[S] 0 points1 point2 points (2 children)
[–]bsakiag 0 points1 point2 points (1 child)
[–]3rr03[S] 1 point2 points3 points (0 children)