Esempio n. 1
0
    public void increaseConditionValue(string condition_name, float additional_value)
    {
        PetCondition condition = getConditionFromString(condition_name);

        if (condition != null)
        {
            condition.incrementValue(additional_value);
        }
        else
        {
            throw new KeyNotFoundException("Undefined condition name " + condition_name);
        }
    }
Esempio n. 2
0
    public float getConditionValue(string condition_name)
    {
        PetCondition condition = getConditionFromString(condition_name);

        if (condition != null)
        {
            return(condition.getValue());
        }
        else
        {
            throw new KeyNotFoundException("Undefined condition name " + condition_name);
        }
    }
Esempio n. 3
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;
    }
Esempio n. 4
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);
    }
Esempio n. 5
0
        internal AbstractCondition LoadConditions(XmlNode xmlNode)
        {
            AbstractCondition condition;

            switch (xmlNode.Name)
            {
            case "HealthPowerCondition":
                condition = new HealthPowerCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "BuffCondition":
                condition = new BuffCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "CombatCountCondition":
                condition = new CombatCountCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "DistanceToTargetCondition":
                condition = new DistanceToTarget();
                condition.LoadData(xmlNode);
                return(condition);

            case "SoulShardCountCondition":
                condition = new SoulShardCountCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "HealthStoneCountCondition":
                condition = new HealthStoneCount();
                condition.LoadData(xmlNode);
                return(condition);

            case "ComboPointsCondition":
                condition = new ComboPointsCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "MageWaterCondition":
                condition = new MageWaterCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "MageFoodCondition":
                condition = new MageFoodCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "TempEnchantCondition":
                condition = new TempEnchantCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "RuneCondition":
                condition = new RuneCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "PotentialAddsCondition":
                condition = new PotentialAddsCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "FunctionCondition":
                condition = new FunctionsCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "TickerCondition":
                condition = new TickerCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "PetCondition":
                condition = new PetCondition();
                condition.LoadData(xmlNode);
                return(condition);

            case "SpellCondition":
                condition = new SpellCondition();
                condition.LoadData(xmlNode);
                return(condition);
            }
            return(null);
        }