2 Replies - 162 Views - Last Post: 08 March 2015 - 09:48 PM Rate Topic: -----

#1 WildPants  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-March 15

Looking for Feedback on my first little text based game (Unity/C#)

Posted 08 March 2015 - 09:28 PM

Hello, this is my first post on these forums but I just finished my first little text based game in C# for Unity. Just wonder if I could maybe get some feedback and possibly some pointers. I'm learning through a Udemy course and they provided a hosting service so you can test the game out in the web player here. In their example they used a finite state machine for the entirety of their game. Which I realize I could have done, but since I paused the tutorial video early and decided to go off on my own I took a different approach, using integers to detect whether a player had obtained an object or not and if they obtained the object then call this state. (I think I'm describing that right? If not let me know.) This is only my second time using the C# language in unity and the first time around I just made one of those small chop binary games where the computer guesses a number in your head. Looking for real and constructive feedback. (Even if it lands me in the nightmare.in.code forum) haha :withstupid:/>
Anyway thanks for taking the time.

you can also use this direct link to check out the game: http://gamebucket.io...80-2e56cf1549e6


-WildPants


Last but not least, here is my code:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;

public class TextController : MonoBehaviour {
	
	public Text text;
	
	private enum States {spawn, key_0, lever_0, cart_0, key_1, lever_1, cart_1, wife, lever_2};
	private States myState;
	
	int key;
	int lever;
	int key_lock;
	
	
	// Use this for initialization
	void Start () {
		myState = States.spawn;
	
	}
	
	// Update is called once per frame
	void Update () {
		print (myState); 
		if 		(myState == States.spawn)		{state_spawn();}
		else if (myState == States.key_0)		{state_key_0();}
		else if (myState == States.key_1)		{state_key_1();}
		else if (myState == States.cart_0)		{state_cart_0();}
		else if (myState == States.cart_1)		{state_cart_1();}
		else if (myState == States.lever_0)		{state_lever_0();}
		else if (myState == States.lever_1)		{state_lever_1();}
		else if (myState == States.lever_2)		{state_lever_2();}
		else if (myState == States.wife)		{state_wife ();}

	}

	 
	 // When at start location.
	 void state_spawn () {
	 	text.text = "You are in Hell, you've payed the toll to cross Styx and now you're here to find your wife..." +
					"you just hope there's something left of her to find. " +
					"There are three corridors: one leading left where you can clearly " +
					"see a very old door and a very small object shines at its foot. " +
					"Then there's a corridor to the right, lit by candles dripping red wax. " +
					"Finally in front of you sits a passenger cart on a very old and " +
					"rusted track that seemingly goes on forever down a dark and musty corridor. " +
					"You can clearly see a mechanism that will release the cart and send it on its way " +
					"down the corridor but without a lever it's useless.\n\n" +
					"Press L to go down the left corridor.\n" +
					"Press C to inspect the cart.\n" +
					"Press R to go down the right corridor.";
		if (Input.GetKeyDown(KeyCode.L)) {
			myState = States.key_0;
			state_key_0 ();
		}
		else if (Input.GetKeyDown(KeyCode.C)) { 
			myState = States.cart_0;
			state_cart_0 ();
		}
		else if (Input.GetKeyDown(KeyCode.R)) {
			myState = States.lever_0;
			state_lever_0 ();		
		}
	}
	
	
	//Left Corridor, Key Pickup
	void state_key_0 () {
		if (key == 0){
			text.text = "You venture down the left corridor toward the very old door to find that it is rusted shut. " +
						"However, at the foot of the door you see a small object shining in a pile of discarded rotten flesh.\n\n" +
						"Press P to pick up the object.\n" +
						"Press B to go Back to where you started.";
			} 	if (Input.GetKeyDown(KeyCode.P)) {
					key = 1;
					myState = States.key_1;
					state_key_1 ();
				}
				else if (Input.GetKeyDown(KeyCode.B)/>/>) {
					myState = States.spawn;
					state_spawn ();
				}
					
		else if (key > 0){
			text.text = "You venture down the left corridor toward the very old door to find that it is still rusted shut.\n\n" +
						"Press B to go Back to where you started.";
			}	if (Input.GetKeyDown(KeyCode.B)/>/>) {
					myState = States.spawn;
					state_spawn ();
				}
							
	}
	
	
	//When Key is obtained in Left Corridor
	void state_key_1 () {
		text.text = "Congratulations you found an Old Rotten Key. You wonder what it opens as " +
					"you slide it into your pocket.\n\n" +
					"Press B to go Back to where you started.";
		if (Input.GetKeyDown(KeyCode.B)/>/>) {
			myState = States.spawn;
			state_spawn ();	
		}				
	}
	
	
	//When Cart is Chosen, check if lever is 0 or greater than 0. 
	void state_cart_0 () {
		if (lever == 0){
			text.text = "You approach the passenger cart, and see the broken mechanism to its left. " +
						"You know that this piece of shit is useless without a lever for that mechanism.\n\n" +
						"Press B to turn back and start looking for a way to find that lever.";
		} 	if (Input.GetKeyDown(KeyCode.B)/>/>) {
				myState = States.spawn;
				state_spawn ();
			}
		else if (lever > 0){
			text.text = "You approach the passenger cart, and see the broken mechanism to its left. " +
						"You know that this piece of shit is useless without a lever for that mechanism.\n\n" +
						"Press W to wedge the lever into the mechanism.\n" +
						"Press B to go back where you started."; 
		}	if(Input.GetKeyDown(KeyCode.W)) {
				myState = States.cart_1;
				state_cart_1 ();
			}
			else if(Input.GetKeyDown(KeyCode.B)/>/>) {
				myState = States.spawn;
				state_spawn ();
			}
			
	}
	
	
	//When Cart is Chosen and lever is greater than 0.
	void state_cart_1 () {
		
		text.text = "Nice, finally got that damned thing wedged into the Mechanism.\n" +
					"Now lets get moving!\n\n" +
					"Press P to Pull the lever and jump on and find your wife.";
		if (Input.GetKeyDown(KeyCode.P)) {
			myState = States.wife;
			state_wife ();
		} 
		
	}
	
	
	//When Right Corridor is Chosen but key = 0
	void state_lever_0 () {
		if (key == 0){	
			text.text = "You walk viligantly down the Right Corridor as you watch the wax drip slowly from the candles. " +
						"Suddenly chills run down your spine as you realize those candles aren't dripping wax at all, no. " +
						"Son-of-a-bitch, it's blood. \n" +
						"You come to the end of the corridor to find a cage clearly containing the lever. " + 
						"You try to open it only to find that it is kept secure by a padlock made of bone and you " +
						"think to yourself, how the hell am I going to open this thing?\n\n" +
						"Press B to turn back and start looking for a key to get to the lever";
			}	if (Input.GetKeyDown(KeyCode.B)/>/>) {
				myState = States.spawn;
				state_spawn();
		
		} else if (key > 0){
			text.text = "You walk viligantly down the Right Corridor as you watch the wax drip slowly from the candles. " +
						"Suddenly chills run down your spine as you realize those candles aren't dripping wax at all, no. " +
						"Son-of-a-bitch, it's blood... " +
						"You come to the end of the corridor to find a cage clearly containing the lever. " + 
						"You try to open it only to find that it is kept secure by a padlock made of bone and you " +
						"think to yourself, how the hell am I going to open this thing?\n\n" +
						"Press K to use the Old Rotten key.\n" +
						"Press B to go back to where you started."; 
			} if (Input.GetKeyDown(KeyCode.K)) {
				key_lock = 1;
				myState = States.lever_1;
				state_lever_1();
			} else if (Input.GetKeyDown(KeyCode.B)/>/>) {
				myState = States.spawn;
				state_spawn();
				
		} else if (lever > 0){
			text.text = "You walk viligantly down the Right Corridor as you watch the blood drip slowly from the candles. " +
						"It doesn't seem to startle you as much as it did the first time around. " +
						"Finally you reach the now empty cage and stare at the padlock on the floor all while you wonder why the hell you came back this way.\n\n" +
						"Press B to go back to where you started";
			} if (Input.GetKeyDown(KeyCode.B)/>/>) {
				myState = States.spawn;
				state_spawn ();
						
		} else if (key_lock > 0){
			text.text = "You return to the cage, luckily the lever is still there.\n\n" +
						"Press T to take the lever,\n" +
						"Press B to go back to where you started.";
			if (Input.GetKeyDown(KeyCode.T)) {
				lever = 1;
				key_lock = 0;
				myState = States.lever_2;
				state_lever_2 ();
			} else if (Input.GetKeyDown(KeyCode.B)/>/>){
				myState = States.spawn;
				state_spawn();
			}					
		}
	}
	
	
	//When Lever Cage is opened and the object is attainable
	void state_lever_1 () {
		
		text.text = "You shimmy the key in the lock and feel it come loose. The padlock falls to the ground " +
					"and the door to the cage swings open. The lever is within reach.\n\n" +
					"Press T to take the lever.\n" +
					"Press B to go back to where you started.";
		if (Input.GetKeyDown(KeyCode.T)) {
			lever = 1;
			myState = States.lever_2;
			state_lever_2 ();
		} else if (Input.GetKeyDown(KeyCode.B)/>/>){
			myState = States.spawn;
			state_spawn();
		} 
		
	}
	
	
	//When Lever is attained
	void state_lever_2 () {
		
		text.text = "Congratulations you got the Rusty Old Lever \n\n" +
					"Press B to go back to where you started.";
		if (Input.GetKeyDown(KeyCode.B)/>/>) {
			myState = States.spawn;
			state_spawn ();

		} 
		
	}
	void state_wife () {
		
		text.text = "Congratulations, you eventually found your wife and got out of Hell.";
			
	} 
		
}


Is This A Good Question/Topic? 0
  • +

Replies To: Looking for Feedback on my first little text based game (Unity/C#)

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 10037
  • View blog
  • Posts: 38,366
  • Joined: 12-June 08

Re: Looking for Feedback on my first little text based game (Unity/C#)

Posted 08 March 2015 - 09:41 PM

There's not much there.. I mean the writing isn't great, the game play is pretty bland. Nice use of states though.
Was This Post Helpful? 1
  • +
  • -

#3 WildPants  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 08-March 15

Re: Looking for Feedback on my first little text based game (Unity/C#)

Posted 08 March 2015 - 09:48 PM

View Postmodi123_1, on 08 March 2015 - 09:41 PM, said:

There's not much there.. I mean the writing isn't great, the game play is pretty bland. Nice use of states though.


Thanks much for the quick reply modi. Yeah like I said I really could have expanded on everything but basically for me this was just learning about using states and enumerations. Not so much the creative side of things. But yeah thanks for the feedback.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1