Пример #1
0
    /* Uncomment this if you want to be able to add conditions in the editor
     * [ContextMenuItem("Add Condition", "debugAddCondition")]
     * public string newDebugConditionName;
     * public void debugAddCondition()
     * {
     *  addNewCondition(newDebugConditionName, -1);
     * }
     */

    // Start is called before the first frame update
    void Start()
    {
        current_health = new PetCondition(MAX_HEALTH, getHungerDelta);
        current_health.setBounds(0, MAX_HEALTH);
        current_neediness = new PetCondition(0, default_neediness_decay);
        current_neediness.setMinimum(0);

        current_conditions = new List <PetCondition>();
        condition_indices  = new Dictionary <string, int>();

        rend          = GetComponentInChildren <Renderer>();
        rend.material = neutralSprite;
        isInanimate   = false;
    }
Пример #2
0
    /// <summary>
    /// Creates a new condition for the pet. It will have a range of 0 to 100, and it
    /// will start out at 100.
    /// </summary>
    /// <param name="condition_name">The name for the condition.</param>
    /// <param name="value_delta">A function that returns the amount by which the
    /// value should change between calls to Update, generally used for the
    /// condition's natural decay.</param>
    public void addNewCondition(string condition_name, Func <float> value_delta)
    {
        if (condition_indices.ContainsKey(condition_name))
        {
            Debug.LogWarning("Warning: conditions with repeated names created");
        }

        PetCondition new_condition = new PetCondition(100, value_delta);

        new_condition.setBounds(0, 100);

        int new_index = current_conditions.Count;

        current_conditions.Add(new_condition);
        condition_indices.Add(condition_name, new_index);
    }