Here we go again. This same line was used in another script, but it compiled just fine. Here is the entire code:
using UnityEngine;
using System.Collections;
using System; //access to 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];
SetupPrimaryAttributes();
SetupVitals();
SetupSkills();
}
public string Name {
set{ return _name; }
get{ _name= value; }
}
public int Level {
set { return _level; }
get { _level= value; }
}
public uint FreeExp {
set { return _freeExp; }
get { _freeExp= value; }
}
public void AddExp(uint exp){
_freeExp+= exp;
CalculateLevel();
}
//take average of all player's skills and assign that as the player level
public void CalculateLevel() {
}
private void SetupPrimaryAttributes() {
for(int cnt=0; cnt < _primaryAttribute.Length; cnt++) {
_primaryAttribute[cnt]=new Attribute();
}
}
private void SetupVitals() {
for(int cnt=0; cnt < _vital.Length; cnt++) {
_primaryVitals[cnt]=new Vital();
}
}
private void SetupSkills() {
for(int cnt=0; cnt < _skill.Length; cnt++) {
_primarySkills[cnt]=new Skill();
}
}
public Attribute GetPrimaryAttribute(int index) {
return _primaryAttribute[index];
}
public Vital GetVitals(int index) {
return _vital[index];
}
public Skill GetSkill(int index) {
return _skill[index];
}
private void SetupVitalModifers() {
// health
GetVital=((int)VitalName.Life).AddModifer( new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution ), .5f));
//energy
GetVital=((int)VitalName.Energy).AddModifer(new ModifyingAttribute (GetPrimaryAttribute((int)AttributeName.Constitution ), 1));
//mana
GetVital=((int)VitalName.Mana).AddModifer( new ModifyingAttribute (GetPrimaryAttribute((int)AttributeName.Willpower ), 1));
}
private void SetupSkillModifers(){
//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.Nibleness), .33f));
//melee defense
GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f));
GetSkill((int)SkillName.Melee_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), .33f));
//magic offense
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 defense
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 offense
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 defense
GetSkill((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Speed), .33f));
GetSkill((int)SkillName.Ranged_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Nibleness), .33f));
}
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();
}
}
The name value doe not exist, yet in BaseStat, it worked just fine as a setter and getter.
public int ExpToLevel {
get{ return _expToLevel;}
set{ _expToLevel=value;}
}
Other Errors:
Assets/Scripts/Character Classes/BaseCharacter.cs(31,14): error CS0127: BaseCharacter.Name.set': A return keyword must not be followed by any expression when method returns void Assets/Scripts/Character Classes/BaseCharacter.cs(31,14): error CS0029: Cannot implicitly convert type string’ to void' Assets/Scripts/Character Classes/BaseCharacter.cs(37,15): error CS0127: BaseCharacter.Level.set’: A return keyword must not be followed by any expression when method returns void
Assets/Scripts/Character Classes/BaseCharacter.cs(37,15): error CS0029: Cannot implicitly convert type int' to void’
Assets/Scripts/Character Classes/BaseCharacter.cs(42,15): error CS0127: `BaseCharacter.FreeExp.set’: A return keyword must not be followed by any expression when method returns void
Please help! Thanks!