I'm trying to create a multidimensional array as a sort of 2D map for a text-based RPG game. I want to create a multidimensional array that's, for example, 5x5. The array would be filled with 0s to represent a space void of an object. Other numbers would represent the player
on the map, an enemy
, an npc
, a skill-object
(like an enchantment table, etc.), doors
that link to maps, and chests
. They would all have different values to represent what object is there. If a player
tries walking into a chest
, it would instead loot the chest
. Then the chest
would be reset to 0 to represent the empty space, letting the player
walk there and representing that there is no more chest. If the player
tries walking over an enemy
, it would instead engage combat (handled by a separate class and functions). Walking over a number representing a door
would link to another multidimensional array that represents another map.
I want to know what kind of property I need to put inside the player
class to handle where he is on the map. A function would then change that value to move him around the map. Would creating a class for a map be a good idea? Would I store the values for the objects there or in the individual classes for those objects? How would I go about this? Thank you for your help. For reference, here's my player class (careful, it's long...):
public class Player
{
public string name { get; set; } //Name of Player
public int level { get; set; } //Player's combat level (average of combat-related skills' levels)
public int health { get; set; } //Player's health (player dies when this value reaches 0)
public int health_max { get; set; } //Player's maximum health
public int stamina { get; set; } //Player's stamina (used for power attacks, slowly recharges on own)
public int stamina_max { get; set; } //Player's maxiumum stamina
public int fatigue { get; set; } //Player's fatigue rate (player cannot fight or run while fatigue is 100)
public int hunger { get; set; } //Player's hunger level (player becomes weaker as hunger increases)
public int style { get; set; } //Player's fighting style (refer to styles.txt)
// tons of skills fields
}
<X,Y>
locations). \$\endgroup\$