Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7978755
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T09:34:31+00:00 2026-06-04T09:34:31+00:00

Basically, I am creating a pseudo-RPG game where a player has an inventory of

  • 0

Basically, I am creating a pseudo-RPG game where a player has an inventory of items and a character doll (to know which items are currently equipped).

What do you recommend is the best way to handle the collection of currently equipped items?

What I currently have is an EquipmentSlot enum that contains all of the possible locations for equipped items on the player, which I can set as a property on each Item that the player has.

public enum EquipmentSlot
{
    Head,
    Chest,
    Arms,
    Legs,
    Feet,
    OffHand,
    MainHand
}

Then I have a dictionary that contains each enum as a key, initializing them all to be null in the Player constructor:

PlayerEquipment = new Dictionary<EquipmentSlot, Item>(7);
PlayerEquipment.Add(EquipmentSlot.Head, null);
PlayerEquipment.Add(EquipmentSlot.Chest, null);
PlayerEquipment.Add(EquipmentSlot.Arms, null);
PlayerEquipment.Add(EquipmentSlot.Legs, null);
PlayerEquipment.Add(EquipmentSlot.Feet, null);
PlayerEquipment.Add(EquipmentSlot.OffHand, null);
PlayerEquipment.Add(EquipmentSlot.MainHand, null);

But as I’m coding this I’m starting to realize that it won’t work because I can’t access the keys as enumerations in other methods of my Player, because they are added in the constructor. I’m not sure where else I could add them to have them available to the rest of the class.

Is my dictionary approach the wrong way to go about this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T09:34:33+00:00Added an answer on June 4, 2026 at 9:34 am

    Provided you define PlayerEquipment as a class member, and not a local variable, you can access it anywhere in your class:

    public class Player
    {
         public Dictionary<EquipmentSlot, Item> PlayerEquipment { get; set; }
    
         public Player()
         {
             PlayerEquipment = new Dictionary<EquipmentSlot, Item>(7);
             PlayerEquipment.Add(EquipmentSlot.Head, null);
             // ...
         }
    
         // In other methods, you can use this as needed... ie:
         public void DropItem(EquipmentSlot slot)
         {
             this.PlayerEquipment[slot] = null; // Remove the item here...
         }
    
         //....Rest of class
    

    Note that, if you define the enum inside of your class, you’ll have to fully qualify it when using it from other classes, ie: Player.EquipmentSlot.Head. If, however, its defined outside of the class, you can just use EquipmentSlot.Head (assuming the same namespace or the appropriate using clause exists).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am creating a bluetooth based server program in Bluez which basically handles connections
Possible Duplicate: XNA Mouse Movement Basically, I am creating a game using XNA, and
OK people, I am creating a class that basically has to interact with a
I have been given a new task from the client which is basically creating
I'm basically creating a trivia type of game. Where you have a question and
The way I know how to represent a linked list is basically creating a
Basically I am creating a database driven website in Web Developer 2008. The database
I just need help. Basically I am creating a windows appllication that sends bulk
Basically I have a tabbed Panel I'm creating. When the user click on a
Basically, I am creating an XML file by taking the values from a column

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.