Hi, I am quite new to unity, and have started making an item and skills system for my game. What I have done in my scripts is make each item constructed with 3 parameters (a name, a 2d icon and a 3d texture). Then, each item is given a list of actions that you can do with it. I called them functions in the script, so please don’t get them confused with actual functions! Each new function is added to the list of functions that the item has with 3 parameters, an action type, a magnitude and a list of skills that the action uses.
What I wanted to know is, when I am creating new items, how do I put the list of skills as a parameter? I’m really stuck here, so help would be great !
What I want to do is make a new action, then add it to a list of actions that the item has. Each action has it’s own list, which contains the skills that are used. When I construct an item and it’s actions, I want to have the list as a parameter, so that each time I create an action I create a new list that the action uses.
To put it without the context of my game, if I want to pass have a list as a parameter of a constructor, how do I represent a list when I create a new instance of that class?
using System.Collections.Generic;
public class Example {
public List<Actions> actions;
public Example (List<Actions> actions) {
this.actions = actions;
}
}
Example example = new Example(new List<Actions>());
Not really, I’m still confused.
I simply can’t wrap my head around what exactly it is that you want.
Please tell me if I’m correct:
-You have items (as in: certain objects the player can interact with or use)
-All of those items have certain attributes (name, icon, texture) and different sets of actions they can perform
What confuses me the most is the part about the skills.
Are those skills like “skill-requirements”? (You need to unlock/have some skills to use specific actions)
Sorry that I can’t really help you, but the code you provided hasn’t cleared up anything. I’d love to know about the structure of your code. Something like a class diagram would be sweet.
The thing is that while there’s tons of ways to implement the same thing, only a fraction of them is actually good.
Anyway, I’d still love to know more about the surrounding code structure. I just wrote an inventory system myself (with items and all this stuff) and it took me some tries to get it all right. Now I have a system that allows me to implement complex behavior for unique items easily.
Maybe the OP should/could restructure his code.
tag instead of [QUOTE]. ;)
Anyway.
Including a list as a parameter is as easy as with any type.
[CODE]List<string> example = new List<string>();
example .Add("Stuff");
example .Add("More Stuff");
items[addedCount].functions.Add(new Function(Function.functionTypes.Attack, 1f, example));
However, I think you shouldn’t add the skills in form of a List, but rather List. That way you can’t add nonsense like non-existent skills.