You are viewing our Forum Archives. To view or take place in current topics click here.
Need help with code (Advanced programmers only)
Posted:
Need help with code (Advanced programmers only)Posted:
Status: Offline
Joined: Jun 08, 201212Year Member
Posts: 407
Reputation Power: 18
Status: Offline
Joined: Jun 08, 201212Year Member
Posts: 407
Reputation Power: 18
Hey guys, for the past few weeks i have been working on an mmorpg and have got stuck with the attributes and skills. The code is correct from what i can see but thought i would get a second opinion.
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();
}
//Calculate Level Still Needs To Be Worked On
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
ModifyingAttribute healthModifier = new ModifyingAttribute();
healthModifier.attribute = GetPrimaryAttribute((int)AttributeName.Constitution);
healthModifier.ratio = .5f;
GetVital((int)VitalName.Health).AddModifier(healthModifier);
//Stamina
ModifyingAttribute staminaModifier = new ModifyingAttribute();
staminaModifier.attribute = GetPrimaryAttribute((int)AttributeName.Stamina);
staminaModifier.ratio = 1;
GetVital((int)VitalName.Stamina).AddModifier(staminaModifier);
//Magic
ModifyingAttribute magicModifier = new ModifyingAttribute();
magicModifier.attribute = GetPrimaryAttribute((int)AttributeName.Willpower);
magicModifier.ratio = 1;
GetVital((int)VitalName.Magic).AddModifier(magicModifier);
}
private void SetupSkillModifiers(){
//Melee Offence
ModifyingAttribute MeleeOffenceModifier1 = new ModifyingAttribute();
ModifyingAttribute MeleeOffenceModifier2 = new ModifyingAttribute();
MeleeOffenceModifier1.attribute = GetPrimaryAttribute((int)AttributeName.Strength);
MeleeOffenceModifier1.ratio = .33f;
MeleeOffenceModifier2.attribute = GetPrimaryAttribute((int)AttributeName.Speed);
MeleeOffenceModifier2.ratio = .33f;
GetSkill((int)SkillName.Melee_Offence).AddModifier(MeleeOffenceModifier1);
GetSkill((int)SkillName.Melee_Offence).AddModifier(MeleeOffenceModifier2);
//Melee Defence
ModifyingAttribute MeleeDefenceModifier1 = new ModifyingAttribute();
ModifyingAttribute MeleeDefenceModifier2 = new ModifyingAttribute();
MeleeDefenceModifier1.attribute = GetPrimaryAttribute((int)AttributeName.Agility);
MeleeDefenceModifier1.ratio = .33f;
MeleeDefenceModifier2.attribute = GetPrimaryAttribute((int)AttributeName.Speed);
MeleeDefenceModifier2.ratio = .33f;
GetSkill((int)SkillName.Melee_Defense).AddModifier(MeleeDefenceModifier1);
GetSkill((int)SkillName.Melee_Defense).AddModifier(MeleeDefenceModifier2);
//Ranged Offence
ModifyingAttribute RangedOffenceModifier1 = new ModifyingAttribute();
ModifyingAttribute RangedOffenceModifier2 = new ModifyingAttribute();
RangedOffenceModifier1.attribute = GetPrimaryAttribute((int)AttributeName.Concentration);
RangedOffenceModifier2.attribute = GetPrimaryAttribute((int)AttributeName.Agility);
GetSkill((int)SkillName.Ranged_Offence).AddModifier(RangedOffenceModifier1);
GetSkill((int)SkillName.Ranged_Offence).AddModifier(RangedOffenceModifier2);
//Ranged Defence
ModifyingAttribute RangedDefenceModifier1 = new ModifyingAttribute();
ModifyingAttribute RangedDefenceModifier2 = new ModifyingAttribute();
RangedOffenceModifier1.attribute = GetPrimaryAttribute((int)AttributeName.Stamina);
RangedOffenceModifier2.attribute = GetPrimaryAttribute((int)AttributeName.Strength);
GetSkill((int)SkillName.Ranged_Defense).AddModifier(RangedDefenceModifier1);
GetSkill((int)SkillName.Ranged_Defense).AddModifier(RangedDefenceModifier2);
//More To Be Added In Future Updates
}
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();
}
}
#2. Posted:
Status: Offline
Joined: Jul 21, 201212Year Member
Posts: 428
Reputation Power: 18
You code like a monkey... what is a "uint" lol....
- 0useful
- 1not useful
#3. Posted:
Status: Offline
Joined: Apr 07, 201113Year Member
Posts: 369
Reputation Power: 14
Status: Offline
Joined: Apr 07, 201113Year Member
Posts: 369
Reputation Power: 14
Cyx wrote You code like a monkey... what is a "uint" lol....
Guess you don't know much about coding?
- 0useful
- 0not useful
#4. Posted:
Status: Offline
Joined: Aug 14, 200915Year Member
Posts: 1,291
Reputation Power: 65
Status: Offline
Joined: Aug 14, 200915Year Member
Posts: 1,291
Reputation Power: 65
Cyx wrote You code like a monkey... what is a "uint" lol....
A uint is an unsigned 32-bit integer.
@OP, I'm not sure why you're asking people if it works or not, just run it through a compiler and see for yourself.
- 1useful
- 0not useful
#5. Posted:
Status: Offline
Joined: Jun 08, 201212Year Member
Posts: 407
Reputation Power: 18
Status: Offline
Joined: Jun 08, 201212Year Member
Posts: 407
Reputation Power: 18
Cyx wrote You code like a monkey... what is a "uint" lol....
Your actually pretty funny haha, there is nothing wrong with the code and you obv can't code for shit for not even knowing what a uint is. Funny guy
- 0useful
- 0not useful
#6. Posted:
Status: Offline
Joined: Jun 08, 201212Year Member
Posts: 407
Reputation Power: 18
Status: Offline
Joined: Jun 08, 201212Year Member
Posts: 407
Reputation Power: 18
Experiment5X wroteCyx wrote You code like a monkey... what is a "uint" lol....
A uint is an unsigned 32-bit integer.
@OP, I'm not sure why you're asking people if it works or not, just run it through a compiler and see for yourself.
It was a simple spelling mistake but thanks for your time
- 0useful
- 0not useful
You are viewing our Forum Archives. To view or take place in current topics click here.