BaseCharacter.Awake C# (CSharp) Method

Awake() public method

public Awake ( ) : void
return void
    public void Awake()
    {
        Name = string.Empty;
        Level = 0;
        FreeExp = 0;

        int attributesCount = Enum.GetValues(typeof(AttributeName)).Length;
        primaryAttributes = new Attribute[attributesCount];
        SetupPrimaryAttributes();

        int vitalsCount = Enum.GetValues(typeof(VitalName)).Length;
        vitals = new Vital[vitalsCount];
        SetupVitals();

        int skillsCount = Enum.GetValues(typeof(SkillName)).Length;
        skills = new Skill[skillsCount];
        SetupSkills();
    }

Usage Example

Example #1
0
    // Use this for initialization
    void Start()
    {
        _player = new BaseCharacter();
        _player.Awake();
        addExp  = false;
        js      = GameObject.FindGameObjectWithTag("PlayerInventory");
        jScript = js.GetComponent <PlayerInventory>();

        SetStats();

        if (PlayerPrefs.HasKey("HP"))
        {
            jScript.fullHP    = PlayerPrefs.GetInt("HP");
            jScript.currentHP = jScript.fullHP;
        }
        if (PlayerPrefs.HasKey("MP"))
        {
            jScript.fullMP    = PlayerPrefs.GetInt("MP");
            jScript.currentMP = PlayerPrefs.GetInt("MP");
        }
    }