Skip to main content

020. Unity3d Tutorial - Base Character Class 3/3

See video

We continue with another tutorial in our Hack And Slash demo made with the Unity3d Game Engine.

In this video, I will be adding a couple of functions to the BaseCharacter class we just created that I omitted in the previous videos.

Tags:

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Offline
Joined: May 29 2011

if your game doesn't use skills will the script still function properly without anything that has to do with skills?

Offline
Joined: Oct 3 2011

Thank you so much for such a great tutoriel.

Can someone explain to me what I did wrong?...

Thank you!

using UnityEngine;
using System.Collections;
using System; //added to acces 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(VitalName)).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 average of all the players skills ans 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++) {
_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];
}

private void SetupVitalModifiers() {
//health
GetVital((int)VitalName.Health).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), .5f));
//energy
GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), 1));
//mana
GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Willpower), 1));
}

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.Constitution), .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 < _skill.Length; cnt++)
_skill[cnt].Update();
}
}

Offline
Joined: Nov 8 2011

Unity 3.4.1
Mono 2.4.2

Awsome tutorial I just bought x2 copies to show my thanks.

Only errors so far have been my own typos.

Offline
Joined: Nov 11 2011

This is my code:

using UnityEngine;
using System.Collections;
using System; // Added to access the enum's 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{
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();
}

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++){
_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];
}

private void SetupVitalModifiers(){
//Health
GetVital((int)VitalName.Health).AddModifier(new ModifyingAttribute((int)AttributeName.Constituion), .5f);

//Energy
GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute((int)AttributeName.Constituion), 1);

//Mana
GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute((int)AttributeName.Willpower), 1);

}
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 < _skill.Length; cnt++)
_skill[cnt].Update();
}
}

Offline
Joined: Nov 3 2011

these is the way i made it, but i don't undestand why i have these errors

using UnityEngine;
using System.Collections;
using System; //added to acces 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 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();
SetupVital();
SetupSkill();
}

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 the players 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 SetupVital() {
for(int cnt = 0; cnt < _vital.Length; cnt++){
_vital[cnt] = new Vital();
}
}

private void SetupSkill() {
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];
}

private void SetupVitalModifiers() {
//health
ModifyingAttribute health = new ModifyingAttribute();
health.attribute = GetPrimaryAttribute((int)AttributeName.Constituion);
health.ratio = .5f;

GetVital((int)vitalName.Health).AddModifier(health);

GetVital((int)VitalName.Health).Addmodifier(new ModifyingAttribute{attribute = GetPrimaryAttribute((int)AttributeName.Constituion), ratio = .5f});
//energy
ModifyingAttribute energyModifier = new ModifyingAttribute();
energyModifier.attributr = GetPrimaryAttribute((int)AttributeName.Constituion);
energyModifier.ratio = 1;

GetVital((int)VitalName.Energy).AddModifier(energyModifier);

//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 < _skill.Length; cnt++)
_skill[cnt].Update();
}
}

in the public Avake() it appears an erros: "Class, struct, or interface method must have a return type"

I don't know how to fix it.
Can you help me?

tylerguitar75's picture
Offline
Joined: Dec 15 2011

AedanQuad,
a few videos he had this error and he addressed it.

The code in question needs to be changed to

"public void Awake()"

Offline
Joined: Nov 3 2011

I made it "public void Awake ()" but it appears 47 errores...

I really don't understand where is the errores.

Offline
Joined: Dec 12 2011

hi have an error

Assets/Scripts/Character Classes/BaseCharacter.cs(92,31): error CS1061: Type `Vital' does not contain a definition for `AddModifier' and no extension method `AddModifier' of type `Vital' could be found (are you missing a using directive or an assembly reference?)

and this is my script

using UnityEngine;
using System.Collections;
using System; //added to acces 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];

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 the players 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++){
_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];
}

private void SetupVitalModifiers(){
//health
GetVital((int)VitalName.Health).Addmodifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constituion), .5f));
//energy
GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constituion), 1));
//mana
GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Willpower), 1));
}

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 < _skill.Length; cnt++)
_skill[cnt].Update();
}
}

Offline
Joined: Jan 16 2012

I was getting the same errors as you were.

"Assets/Scripts/Character Classes/BaseCharacter.cs(92,31): error CS1061: Type `Vital' does not contain a definition for `AddModifier' and no extension method `AddModifier' of type `Vital' could be found (are you missing a using directive or an assembly reference?)"

I went and re-wrote the scripts but it didn't help so I tried writing just one line of these:

private void SetupVitalModifiers(){
//health
GetVital((int)VitalName.Health).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), .5f));

I got there error I was always getting like you were.

Then I commented that line out and tried just writing one of these lines:

private void SetupSkillModifiers(){
//melee offense
GetSkill((int)SkillName.Melee_Offense).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Might), .33f));

I got no errors. So that made me look at the Vital script and the Skill script themselves and I realized that Vital started by referencing BaseStat:

public class Vital : BaseStat {

and Skill started by referencing ModifiedStat:

public class Skill : ModifiedStat {

When I changed the vital script to reference ModifiedStat and saved the script then my errors went away.

I hope that helps.

Offline
Joined: Apr 8 2012

Hi, I'm getting the same errors, I did that changes but I'm still getting them... any other idea on how can I solve them..? I modified the inheritance but that didn't help either...

Thanks.

Offline
Joined: Apr 6 2012

Hey I've fixed mine now :D
all you have to do is add the few lines of code he tells about in #19
just before he fast forwards
script:
using System.Collections.Generic;

public class ModifiedStat : BaseStat {
public List _mods; //A list of Attributes that modify the stat
private int _modValue;

public ModifiedStat(){
_mods = new List();
_modValue = 0;
}
public void AddModifier( ModifyingAttribute mod){
_mods.Add(mod);
}

private void CalculateModValue(){
_modValue = 0;

if(_mods.Count > 0)
foreach(ModifyingAttribute att in _mods)
_modValue += (int)(att.attribute.AdjustBaseValue * att.ratio);

}

public new int AdjustBaseValue{
get { return BaseValue + BuffValue + _modValue; }
}

public void Update(){
CalculateModValue();
}
}

public struct ModifyingAttribute{
public Attribute attribute;
public float ratio;

public ModifyingAttribute(Attribute att, float rat){
attribute = att;
ratio = rat;
}
}

Offline
Joined: Apr 6 2012

Hey!
I've really enjoyed watching your videos but i'm stuck at this video. :(
i have 3 errores repeated 45 times :(
CS 1502
CS 1503
Cs 1729

I've continued to script and is currently at video 31, but there have been no changes to the script that removed/gave me other errors :(

So please do help me out with this, I'd so like to compleate this AWSOME tutorial serie :)

anyways heres the code that i've used (Willpower have been changed to Focus):

using UnityEngine;
using System.Collections;
using System; // Added to access the enum's 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 {

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();

}

public void CalculateLevel() {

}

private void SetupPrimaryAttributes() {

for(int cnt = 0; cnt < _primaryAttribute.Length; cnt++) {

_primaryAttribute[cnt] = new Attribute();
_primaryAttribute[cnt].name = ((AttributeName)cnt).ToString ();

}

}

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];

}

private void SetupVitalModifiers() {

GetVital((int)VitalName.Health).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), .5f));

GetVital((int)VitalName.Energy).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Constitution), 1));

GetVital((int)VitalName.Mana).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Focus), 1));

}

private void SetupSkillModifiers() {

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));

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));

GetSkill((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f));

GetSkill((int)SkillName.Magic_Offence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Focus), .33f));

GetSkill((int)SkillName.Magic_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Concentration), .33f));

GetSkill((int)SkillName.Magic_Defence).AddModifier(new ModifyingAttribute(GetPrimaryAttribute((int)AttributeName.Focus), .33f));

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));

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));

}

}

Offline
Joined: May 1 2012

Hello ! I've been following your guide for some time now and I don't have any errors. However I don't seem to understand what th StatUpdate functino does which we have to use later in one of your videos. Can you please explain in details? It would be so helpful!