I need help in scripting in C#. There might be silly mistakes as I am a Beginner.
When I try to Dislpay the Vitals And Skills The never show.
The script I used for vitals is:
public class Vital : ModifiedStat {
private int _curValue;
public Vital(){
_curValue = 0;
ExpToLevel = 50;
LevelModifier = 1.1f;
}
public int CurValue{
get{
if(_curValue > AddjustedBaseValue)
_curValue = AddjustedBaseValue;
return _curValue;
}
set{_curValue = value;}
}
}
public enum VitalName {
Health,
Energy,
Mana
}
The Script for Skills is:
public class Skill : ModifiedStat {
private bool _known;
public Skill(){
_known = false;
ExpToLevel = 25;
LevelModifier = 1.1f;
}
public bool known {
get{return _known;}
set{_known = value;}
}
}
public enum SkillName{
Melee_Offence,
Melee_Defence,
Ranged_Offence,
Ranged_Defence,
Magic_Offence,
Magic_Defence
}
The script I used to Display the labels is:
using UnityEngine;
using System.Collections;
using System; //used for the enum class
public class CharacterGenerator : MonoBehaviour {
private PlayerCharacter _toon;
void Start()
{
_toon = new PlayerCharacter();
_toon.Awake();
}
void Update(){
}
void OnGUI(){
DisplayName();
DisplayAttribute();
DisplayVitals();
DispalySkills();
}
private void DisplayName(){
GUI.Label(new Rect(10, 10, 50, 25), "Name:");
_toon.Name = GUI.TextArea(new Rect(65, 10, 100, 25), _toon.Name);
}
private void DisplayAttribute(){
for(int cnt = 0; cnt < Enum.GetValues(typeof(AttributeName)).Length; cnt++){
GUI.Label(new Rect(10, 40+(cnt* 25), 100, 25),((AttributeName)cnt).ToString() );
GUI.Label(new Rect(115, 40+(cnt* 25), 30, 25), _toon.GetPrimaryAttribute(cnt).AddjustedBaseValue.ToString());
}
}
private void DisplayVitals(){
for(int cnt = 0; cnt < Enum.GetValues(typeof(VitalName)).Length; cnt++){
GUI.Label(new Rect(10, 40 + (cnt + 7 * 25), 100, 25),((VitalName)cnt).ToString() );
GUI.Label(new Rect(115, 40 + (cnt + 7 * 25), 30, 25), _toon.GetVital(cnt).AddjustedBaseValue.ToString());
}
}
private void DispalySkills(){}
}
Please help me
![]()
So I should change- _toon.GetComponent.GetVital
– saurabhn04No. I should be something like: _toon.getComponent(name of the script).name; something like that.
– dorpeleg