Welcome to Code Forum!

Join a community that supports you and your coding journey from day one. We strive to be a friendly, supportive community that empowers everyone to be better developers. By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • Guest, before posting your code please take these rules into consideration:
    • It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
    • You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
    • Don't share a wall of code. All we want is the problem area, the code related to your issue.

    GIF shows where to locate </> in the thread and or post editor toolbar.
    To learn more about how to use our BBCode feature, review our "How to post your code into threads" here.

    Thank you, Code Forum.

C# I need help being able to switch to a different class without having to make a new instance of it if that is possible.

WibblyWall

New Coder
using Mid_Term_Project;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Potion_Game
{
internal class Location
{
public void MerlinShopOne()
{
Print("You see a...");
Print("\"a\" office");
Print("\"b\" cabinet");
Print("\"c\" shelves");
Print("Which would you like to inspect?");
string exploreShop = Console.ReadLine();
if (exploreShop == "a")
{
Print("You walk into Merlin's office and see a mess of papers all over his desk.");
Print("You look through the papers for a second but find nothing of use.");
Print("Would you like to...");
Print("\"a\" Look At One Of The Other Spots In The Store");
Print("\"b\" Do Something Else");
string exploreOffice = Console.ReadLine();
if (exploreOffice == "a")
{
Print("You step out of the office.");
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
MerlinShopOne();
}
else if (exploreOffice == "b")
{
Print("You step out of the office.");
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
Engine engine = new Engine();
engine.FirstEvent();
}
else
{
Print("Invalid Input, please enter one of the options given.");
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
MerlinShopOne();
}
}
else if (exploreShop == "b")
{
Print("You open the cabinet and find a pouch of 'Recovery Herb'.");
Print("Would you like to take the pouch?");
Print("\"a\" Yes");
Print("\"b\" No");
string cabinetItem = Console.ReadLine();
if (cabinetItem == "a")
{
Engine.inv.items.Add("Recovery Herb");
Print("You grab the pouch and put it in your bag then close the cabinet.");
Print("Would you like to...");
Print("\"a\" Look At One Of The Other Spots In The Store");
Print("\"b\" Do Something Else");
string exploreOffice = Console.ReadLine();
if (exploreOffice == "a")
{
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
MerlinShopOne();
}
else if (exploreOffice == "b")
{
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
Engine engine = new Engine();
engine.FirstEvent();
}
}
else if (cabinetItem == "b")
{
Print("You leave the pouch where it sits and close the cabinet.");
Print("Would you like to...");
Print("\"a\" Look At One Of The Other Spots In The Store");
Print("\"b\" Do Something Else");
string exploreOffice = Console.ReadLine();
if (exploreOffice == "a")
{
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
MerlinShopOne();
}
else if (exploreOffice == "b")
{
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
Engine engine = new Engine();
engine.FirstEvent();
}
else
{
Print("Invalid Input, please enter one of the options given.");
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
MerlinShopOne();
}
}
else
{
Print("Invalid Input, please enter one of the options given.");
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
MerlinShopOne();
}
}
else if (exploreShop == "c")
{
Print("You look at all the expensive potions on the shelves.");
Print("Probably best if you just leave them where they are.");
Print("Would you like to...");
Print("\"a\" Look At One Of The Other Spots In The Store");
Print("\"b\" Do Something Else");
string exploreOffice = Console.ReadLine();
if (exploreOffice == "a")
{
Print("You step out of the office.");
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
MerlinShopOne();
}
else if (exploreOffice == "b")
{
Print("You step out of the office.");
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
Engine engine = new Engine();
engine.FirstEvent();
}
}
else
{
Print("Invalid Input, please enter one of the options given.");
Print("Press Any Key To Continue");
Console.ReadKey();
Console.Clear();
MerlinShopOne();
}
}
public void TownSquare()
{

}
public void Store()
{

}
public void Woods()
{

}
public void Pond()
{

}
public void MerlinShop()
{

}
public static void Print(string text, int speed = 25)
{
foreach (char c in text)
{
Console.Write(c);
System.Threading.Thread.Sleep(speed);
}
Console.WriteLine();
}
}
}
 

Buy us a coffee!

Buy me a coffee.
Back
Top Bottom