Hi guys i hv 2 scripts connected, they work almost 100% fine but i hv an issue, in BaseCharacter one i calculate the Vital and Skill Modifier but when i want them to actualize in character creation with the points i give in my status they always show 0 at all the skills and vital has show the image, can anyone help me figure it out wt im doing wrong plz? ty
using UnityEngine;
using System.Collections;
using System; //added to acces enum class
public class BaseCharacter : MonoBehaviour
{
private string _name;
private int _level;
private uint _freeExp; //only assign possitive values
private AttributeClass[] _primaryAttribute;
private VitalClass[] _vital;
private Skill[] _skill;
public void Awake()
{
_name = string.Empty;
_level = 0;
_freeExp = 0;
_primaryAttribute = new AttributeClass[Enum.GetValues(typeof(AttributeName)).Length];
_vital = new VitalClass[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 average of all of the player 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 AttributeClass();
}
}
private void SetupVitals()
{
for (int cnt = 0; cnt < _vital.Length; cnt++)
_vital[cnt] = new VitalClass();
SetupVitalModifiers ();
}
private void SetupSkills()
{
for (int cnt = 0; cnt < _skill.Length; cnt++)
_skill[cnt] = new Skill ();
SetupSkillModifiers ();
}
public AttributeClass GetPrimaryAttribute(int index)
{
return _primaryAttribute [index];
}
public VitalClass 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.MAGIC), 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.MAGIC), .33f));
//melee defence
GetSkill ((int)SkillName.MELEE_DEFENSE).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.SPEED), .33f));
GetSkill ((int)SkillName.MELEE_DEFENSE).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));
//mafic defence
GetSkill ((int)SkillName.MAGIC_DEFENSE).AddModifier (new ModifyingAttribute (GetPrimaryAttribute ((int)AttributeName.CONCENTRATION), .33f));
GetSkill ((int)SkillName.MAGIC_DEFENSE).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.MAGIC), .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 ();
}
}
using UnityEngine;
using System.Collections;
using System;
public class CharacterGenerator : MonoBehaviour
{
private PlayerCharacter _player;
private const int STARTING_POINTS = 350;
private const int MIN_SARTING_ATTRIBUTE_VALUE = 10;
private const int STARTING_VALUE = 50;
private int pointsLeft;
// Use this for initialization
public void Start ()
{
_player = new PlayerCharacter ();
_player.Awake ();
pointsLeft = STARTING_POINTS;
for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++)
{
_player.GetPrimaryAttribute(cnt).BaseValue = STARTING_VALUE;
pointsLeft -= (STARTING_VALUE - MIN_SARTING_ATTRIBUTE_VALUE);
}
_player.StatUpdate ();
}
// Update is called once per frame
void Update ()
{
}
void OnGUI()
{
DisplayName ();
DisplayPointsLeft ();
DisplayAttributes ();
DisplayVitals ();
DisplaySkills ();
}
private void DisplayName()
{
GUI.Label(new Rect(10,10,50,25), "Name:" );
_player.Name = GUI.TextField (new Rect (65,10,100,25), _player.Name);
}
private void DisplayAttributes()
{
for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++)
{
GUI.Label (new Rect(10,40+(cnt * 25),120,25), ((AttributeName)cnt).ToString());
GUI.Label (new Rect(150,40+(cnt * 25),30,25), _player.GetPrimaryAttribute(cnt).AdjustedBaseValue.ToString());
if(GUI.Button(new Rect(170, 40+(cnt * 25),25,25), "-"))
{
if(_player.GetPrimaryAttribute(cnt).BaseValue > MIN_SARTING_ATTRIBUTE_VALUE)
{
_player.GetPrimaryAttribute(cnt).BaseValue--;
pointsLeft++;
_player.StatUpdate ();
}
}
if(GUI.Button(new Rect(200, 40+(cnt * 25),25,25), "+"))
{
if(pointsLeft > 0)
{
_player.GetPrimaryAttribute(cnt).BaseValue++;
pointsLeft--;
_player.StatUpdate ();
}
}
}
}
private void DisplayVitals()
{
for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++)
{
GUI.Label (new Rect(10,40+((cnt+7) * 25),120,25), ((VitalName)cnt).ToString());
GUI.Label (new Rect(150,40+((cnt+7) * 25),30,25), _player.GetVital(cnt).AdjustedBaseValue.ToString());
}
}
private void DisplaySkills()
{
for(int cnt = 0; cnt < Enum.GetValues(typeof(SkillName)).Length; cnt++)
{
GUI.Label (new Rect(250,40+(cnt * 25),130,25), ((SkillName)cnt).ToString());
GUI.Label (new Rect(400,40+(cnt * 25),30,25), _player.GetSkill(cnt).AdjustedBaseValue.ToString());
}
}
private void DisplayPointsLeft()
{
GUI.Label(new Rect(250,10,100,25), "Points Left: " + pointsLeft.ToString());
}
}