3 Replies - 616 Views - Last Post: 20 June 2015 - 05:02 PM Rate Topic: -----

#1 TreeBaron   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-June 15

Strategy For checking characters in text adventure

Posted 19 June 2015 - 03:28 PM

I'm typing this from my phone right now so I'm afraid I don't have any code to post, and I'm new to programming as well so try to go easy on me ;)/>


Anyway so I'm developing a text adventure in c sharp so that I can get better at programming. Right now I've got a combat system and locations and sub locations working so I think I'm off to a good start. However there are two areas I am a little unsure of and I've ran into a bit of a problem.

So I want there to be characters in my game that the player can talk to, battle, and get quests from. I wanted these characters to not be static and be able to move around to different towns and sub locations.

However due to the number of characters I want and ther abilities I decided to make a character class like I'd done with locations and transfer variables as I'd Done with locations, to Something called currentcharacter. That way once set. Which would happen every turn I Could go console.writeline (currentcharacter.greeting).

I don't think this will. Work for several reasons.
1. I may want multiple characters interacting at a time.
2. I want more than one character in a place at a time.
3. In c# it is not possible to dynamically go through all instances of a class. This makes it difficult to check every character for their location and see if they are in a place.

I feel like I've written myself into a corner here. Any ideas or strategies on how to handle characters in my game would be helpful, even if I don't use your idea it may help me think k of something else so thank you!

Is This A Good Question/Topic? 0
  • +

Replies To: Strategy For checking characters in text adventure

#2 tlhIn`toq   User is offline

  • Xamarin Cert. Dev.
  • member icon

Reputation: 6537
  • View blog
  • Posts: 14,450
  • Joined: 02-June 10

Re: Strategy For checking characters in text adventure

Posted 19 June 2015 - 04:28 PM

Quote

In c# it is not possible to dynamically go through all instances of a class.

Its called 'collections'. When you make a new instance of a thing you put it in a collection so you can iterate through it.

List<Character> myCharacters = new List<List> Character();
//Later

Character someOgre = new Ogre();//Orge is a type derived from Character class.
myCharacters.Add(someOgre);


How did you make all the locations and keep track of them if you didn't have a collection of some kind? An array of Location[], an ObservableCollection<Location>, a List<Location>... Some kind of collection.

It sounds like you've built a lot more than you've planned. Never a promising start.

Take a look at the top link in my signature block for "I want to be a programmer, where do I start?" - That article has a lot of resources you probably need to work through BEFORE you try architecting a game.

This post has been edited by tlhIn`toq: 19 June 2015 - 04:29 PM

Was This Post Helpful? 1
  • +
  • -

#3 TreeBaron   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 19-June 15

Re: Strategy For checking characters in text adventure

Posted 20 June 2015 - 05:00 PM

Thanks for your help.

I am aware that you could make lists/arrays and such I just wasn't aware that you could do that with class types, I thought it was limited to simple variables.

This should help a lot, I'm definitely going to go back and fix locations with this. I had only added one location thus far, so it wasn't a problem yet I was just aware it would be one in the future.

This post has been edited by andrewsw: 20 June 2015 - 05:02 PM
Reason for edit:: Removed previous quote, just press REPLY

Was This Post Helpful? 0
  • +
  • -

#4 andrewsw   User is offline

  • palpable absurdity
  • member icon

Reputation: 6905
  • View blog
  • Posts: 28,567
  • Joined: 12-December 12

Re: Strategy For checking characters in text adventure

Posted 20 June 2015 - 05:02 PM

Note that you don't have to quote the previous post, there is a REPLY button further down the page.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1