5 Replies - 361 Views - Last Post: 18 July 2017 - 03:35 PM Rate Topic: -----

#1 Snaef98  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-July 17

Using classes to define a list of preset items in the game? Help

Posted 18 July 2017 - 02:47 PM

Would this work and if so, how would I transfer the variables from 1 item in the list to a set of global variables for the inventory? My code below
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Crystal_Chronicles
{
    class GameItem
    {
        public string ItemName;
        public string ItemDescription;
        public string ItemQuality;
        public int ItemID;
        public int ItemILevel;
        public int ItemItemQuality;
        public int ItemEquipSlot;
        public int ItemType;
        public int ItemGoldValue;
        public int ItemDefenseValue;
        public int ItemAttackValue;
        public int ItemHPValue;
        public int ItemMPValue;

        public GameItem(string IName, string IDescription, string IQuality, int IID, int IILevel, int IItemQuality, int IEquipSlot, int IType, int IGoldValue, int IDefenseValue, int IAttackValue, int IHPValue, int IMPValue)
        {
            this.ItemName = IName;
            ItemDescription = IDescription;
            ItemQuality = IQuality;
            ItemID = IID;
            ItemILevel = IILevel;
            ItemItemQuality = IItemQuality;
            ItemEquipSlot = IEquipSlot;
            ItemType = IType;
            ItemGoldValue = IGoldValue;
            ItemDefenseValue = IDefenseValue;
            ItemAttackValue = IAttackValue;
            ItemHPValue = IHPValue;
            ItemMPValue = IMPValue;
        }

        static void Main()
        {
            List<GameItem> gameitem = new List<GameItem>();
            gameitem.Add (new GameItem("Adventurer's Tunic", "Starting Equipment", "Common", 1, 1, 1, 3, 3, 100, 2, 0, 5, 5));
        }
    }
} 


Is This A Good Question/Topic? 0
  • +

Replies To: Using classes to define a list of preset items in the game? Help

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13493
  • View blog
  • Posts: 53,899
  • Joined: 12-June 08

Re: Using classes to define a list of preset items in the game? Help

Posted 18 July 2017 - 02:53 PM

What global variables?
What inventory?
Was This Post Helpful? 0
  • +
  • -

#3 Snaef98  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-July 17

Re: Using classes to define a list of preset items in the game? Help

Posted 18 July 2017 - 02:55 PM

Sorry I didn't include that in the code, this is just the class for GameItem what im asking is how do I assign values from a class directly to other variables IE Variable 1 (from class item 1) to variable 1 of inventoryslot 1
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 13493
  • View blog
  • Posts: 53,899
  • Joined: 12-June 08

Re: Using classes to define a list of preset items in the game? Help

Posted 18 July 2017 - 02:56 PM

Is this inventory thing just a collection of type GameItem inside some player class?
Seems a simple "add item" function on the player class that takes in a parameter of type GameItem would work.
Was This Post Helpful? 0
  • +
  • -

#5 Snaef98  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-July 17

Re: Using classes to define a list of preset items in the game? Help

Posted 18 July 2017 - 03:00 PM

Here is the variables
 public string PlayerInventory1SlotName;
        public string PlayerInventory1SlotDesc;
        public string PlayerInventory1SlotQuality;
        public int PlayerInventory1SlotID;
        public int PlayerInventory1SlotILevel;
        public int PlayerInventory1SlotItemQuality;
        public int PlayerInventory1SlotEquipSlot;
        public int PlayerInventory1SlotType;
        public int PlayerInventory1SlotGoldValue;
        public int PlayerInventory1SlotDefenseValue;
        public int PlayerInventory1SlotAttackValue;
        public int PlayerInventory1SlotHPValue;
        public int PlayerInventory1SlotMPValue;


They are global variables. Because they are included as part of the save game struct and xml serialization. Also the inventory system is dependent as well. I need to be able to assign variables Directly from an item in the class as if it were an array basically.

The class is just going to list predesigned items with preset stats. I can use global variables but it would be cleaner to just list them in a class.
Was This Post Helpful? 0
  • +
  • -

#6 Snaef98  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 27
  • Joined: 11-July 17

Re: Using classes to define a list of preset items in the game? Help

Posted 18 July 2017 - 03:35 PM

You know what nevermind. I will I will just do a bunch of arrays. This isn't going to work since my system isn't based on classes and inheritance more advanced stuff then I know atm.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1