using UnityEngine; using System.Collections; using System; //added to access the enum class
public class BaseCharacter : MonoBehaviour { private string _name; private int _level; private uint _freeExp;
private Attribute[] _primaryAttribute;
private Vital[] _vital;
private Skill[] _skill;
public void Awake () {
_name = String.Empty;
_level = 0;
_freeExp = 0;
_primaryAttribute = new Attribute[Enum.GetValues(typeof(AttributeName)).Length];
;
_vital = new Vital[Enum.GetValues(typeof(VitalName)).Length];
_skill = new Skill[Enum.GetValues(typeof(SkillName)).Length];
SetUpPrimaryAttribute();
SetUpVitals();
SetUpSkills();
}
public string Name {
get{ return _name; }
set{ _name = value;}
}
public int Level {
get{ return _level; }
set{ _level = value;}
}
public uint FreeExp {
get{ return _freeExp; }
set{ _freeExp = value;}
}
public void AddExp(uint exp) {
_freeExp += exp;
CalculateLevel();
}
//take average of all of the players skills and assign that as the player level
public void CalculateLevel() {
}
private void SetUpPrimaryAttribute() {
for(int cnt = 0; cnt < _primaryAttribute.Length; cnt++) {
_primaryAttribute[cnt] = new Attribute();
}
}
private void SetUpVitals() {
for(int cnt = 0; cnt < _vital.Length; cnt++) {
_vital[cnt] = new Vital();
}
}
private void SetUpSkills() {
for(int cnt = 0; cnt < _skill.Length; cnt++) {
_skill[cnt] = new Skill();
}
}
public Attribute GetPrimaryAttribute(int index) {
return _primaryAttribute[index];
}
public Vital GetVital(int index) {
return _vital[index];
}
public Skill GetSkill(int index) {
return _skill[index];
}
void AddSkillModifier(SkillName skillName, AttributeName attributeName, float value) {
Skill skill = GetSkill((int)skillName);
Attribute primary = GetPrimaryAttribute((int)attributeName);
// Below is my new error --- error CS1729: The type `ModifyingAttribute' does not contain a constructor that takes`2' arguments
ModifyingAttribute modifier = new ModifyingAttribute(primary, value);
skill.AddModifier(modifier);
}
private void SetUpVitalModifiers() {
//health
GetVital((int)VitalName.Health).AddModifier(new ModifyingAttribute{attribute = GetPrimaryAttribute((int)AttributeName.Constitution), ratio = .5f});
//energy
GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute{attribute = GetPrimaryAttribute((int)AttributeName.Constitution), ratio = 1});
//mana
GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute{attribute = GetPrimaryAttribute((int)AttributeName.WillPower), ratio = 1});
}
public void SetUpSkillModifiers() {
// Check comments right side ->
float m = 0.33f;
AddSkillModifier(SkillName.Melee_Offence, AttributeName.Might , m);
AddSkillModifier(SkillName.Melee_Offence, AttributeName.Nimbleness , m);
AddSkillModifier(SkillName.Melee_Defence, AttributeName.Speed , m);
AddSkillModifier(SkillName.Melee_Defence, AttributeName.Constitution , m);
AddSkillModifier(SkillName.Magic_Offence, AttributeName.Concentration, m);
AddSkillModifier(SkillName.Magic_Offence, AttributeName.WillPower , m);
AddSkillModifier(SkillName.Magic_Defence, AttributeName.Concentration, m);
AddSkillModifier(SkillName.Magic_Defence, AttributeName.WillPower , m);
AddSkillModifier(SkillName.Ranged_Offence, AttributeName.Concentration, m);
AddSkillModifier(SkillName.Ranged_Offence, AttributeName.Speed , m);
AddSkillModifier(SkillName.Ranged_Defence, AttributeName.Speed , m);
AddSkillModifier(SkillName.Ranged_Defence, AttributeName.Nimbleness , m);
}
public void StatUpdate () {
for(int cnt = 0; cnt < _vital.Length; cnt++)
_vital[cnt].Update();
for(int cnt = 0; cnt < _skill.Length; cnt++)
_skill[cnt].Update();
}
}
Could you post the actual errors? They make it far easier to work out what's wrong
– anon85704231If you can't take the time to phrase a good question you won't get any answers. Unity gives you a detailed error message which would be much better than posting error codes... You also get the line number where the error occurred. A short google: 1729 == Wrong constructor parameter count, 1502 == best overloaded function match have invalid arguments, 1503 == can't convert type into type. If you don't tell use where the error have been spotted we can't even say what class is involved. And without seeing the class implementations we can't help you.
– Bunny83BTW: what are those ***? did you try to highlight that part as bold and italic? Inside a code block you can't use any markup so you might remove it.
– Bunny83and i wasn't stealing the code i was actually working through a tutorial so help me learn!
– anon73191669