4/10/2014

Project RPG BÀI 14A. DỌN DẸP FILE VITAL



Thêm chú thích và các công dụng để dễ hiểu rõ hơn phần nào về các tính năng của script Vital...


Double click vào file Vital và xóa tất cả đi, chèn lại đoạn script sau vào:

/// <summary>
/// Vital.cs
/// This class contain all the extra function for a character vitals
/// </summary>

public class Vital : ModifiedStat {
    private int _curValue;                //this is the current value of this vital

    /// <summary>
    /// Initializes a new instance of the <see cref="Vital"/> class.
    /// </summary>
    public Vital(){
        UnityEngine.Debug.Log ("Vital Created");
        _curValue = 0;
        ExpToLevel = 40;
        LevelModifier = 1.1f;
    }

    /// <summary>
    /// When getting the _curValue, make sure that it is not greater than our AdjustedBaseValue
    /// If it is, make it the same as our AdjustedBaseValue
    /// </summary>
    /// <value>The current value.</value>
    public int CurValue{
        get{
            if(_curValue > AdjustedBaseValue)
                _curValue = AdjustedBaseValue;
           
            return _curValue;
        }
        set{ _curValue = value; }
    }
}

/// <summary>
/// This enumerations is just a list of the vitals our character will have
/// </summary>
public enum VitalName{
    Health,
    Energy,
    Mana
}

No comments:

Post a Comment