- Home /
c# parsing error Help please and the error is at where it says public string Name
here is the script
using UnityEngine; using System.Collections; using System; //added to acces the enum class
public class BaseCharactor : MonoBehaviour { private string _name; private int _level; private uint _freeExp;
private Attribute[] _primaryAttribute; private Vital[] _vital; private Skill[] _skills;
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];
_skills = new Skill[Enum.GetValues(typeof(SkillName)).Length];
SetupPrimaryAttributes();
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 avg of all of the players skills and assign that as the player level public void CalculateLevel() { }
private void SetupPrimaryAttributes() { }
private void SetupVitals() { for(int cnt = 0; cnt < _vital.Length; cnt++) { _primaryAttribute[cnt] = new Attribute(); }
}
private void SetupSkills() { for(int cnt = 0; cnt < _skills.Length; cnt++) { _primaryAttribute[cnt] = new Attribute(); }
}
public Attribute GetPrimaryAttribute(int index) { return _primaryAttribute[index]; }
public Vital GetVital(int index) { return _vital[index]; }
public Skill GetSkill(int index) { return _skills[index]; }
private void SetupVitalModifiers() { //health ModifyingAttribute health = new ModifyingAttribute(); health.attribute = GetPrimaryAttribute((int)AttributeName.Constituion); health.ratio = .5f;
GetVital((int)VitalName.Health).AddModifier(health);
//energy
ModifyingAttribute energyModifier = new ModifyingAttribute();
energyModifier.attribute = GetPrimaryAttribute((int)AttributeName.Constituion);
energyModifier.ratio = 1;
//mana
ModifyingAttribute manaModifier = new ModifyingAttribute();
manaModifier.attribute = GetPrimaryAttribute((int)AttributeName.Willpower);
manaModifier.ratio = 1;
GetVital((int)VitalName.Mana).AddModifier(energyModifier);
}
private void SetupSkillModifiers() { //melee offence GetSkill((int)SkillName.Melee_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Might), .33f)); GetSkill((int)SkillName.Melee_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Nimbleness), .33f)); //melee defence GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f)); GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constituion), .33f)); //magic offence GetSkill((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f)); GetSkill((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Willpower), .33f)); //magic defence GetSkill((int)SkillName.Magic_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f)); GetSkill((int)SkillName.Magic_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Willpower), .33f)); //ranged offence GetSkill((int)SkillName.Ranged_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f)); GetSkill((int)SkillName.Ranged_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f)); //ranged defence GetSkill((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f)); GetSkill((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Nimbleness), .33f));
}
public void StatUpdate() { for(int cnt = 0; cnt < _Vital.Length; cnt++) _Vital[cnt].Update();
for(int cnt = 0; cnt < _skills.Length; cnt++)
_skills[cnt].Update();
}
}
How do you guys always manage to NOT highlight the entire script? I'll think I will refuse to answer to such posts in future until it's fixed (try edit post)
Answer by Bunny83 · Feb 01, 2011 at 09:38 PM
Right befor your
public string Name
you have to delete one of the curly brackets. You closed the class before the properties...
The right formating of the script text would help to find such basic mistakes...
Your answer
Follow this Question
Related Questions
Jukebox parsing error 2 Answers
CS8025 parsing error, can't find, halp ! 0 Answers
unity 3d - c# scripting problems 1 Answer
Errors CS1525 and CS8025.... 1 Answer
CS8025 Error (Parsing Error) 1 Answer