void Update()
    {
        PhysicalResourceModel prm = GetComponent <PhysicalResourceModel>();
        float hunger    = prm.GetPhysicalValue(PhysicalRef.Hunger) + 1.0f;
        float tiredness = prm.GetPhysicalValue(PhysicalRef.Tiredness) + 1.0f;
        float total     = hunger + tiredness;

        if (total <= 1)
        {
            total = 1;
        }
        Speed = fixedSpeed / total;
    }
Esempio n. 2
0
    void Update()
    {
        if (targetCharacter != null && stat != StatName.None)
        {
            epm = targetCharacter.GetComponent <EmotionalPersonalityModel>();
            prm = targetCharacter.GetComponent <PhysicalResourceModel>();

            float value = float.MinValue;
            if ((int)stat > 0 && (int)stat < Precondition.physicalIndex)
            {
                value = epm.GetEmotionValue(stat.ToString());
            }
            else if ((int)stat >= Precondition.physicalIndex && (int)stat < Precondition.limitIndex)
            {
                value = prm.GetPhysicalValue(stat.ToString());
            }

            GetComponent <TextMeshProUGUI>().text = stat.ToString() + " = " + value.ToString("0.00");
        }
    }
Esempio n. 3
0
    private bool IsStatCorrect(GameObject target)
    {
        if (Stat == StatName.None)
        {
            return(true);
        }
        GameObject targetCharacter = GameObject.Find(target.name);

        if (targetCharacter.tag == "Character")
        {
            float value = 0;
            if ((int)Stat > 0 && (int)Stat < physicalIndex)
            {
                EmotionalPersonalityModel epm = targetCharacter.GetComponent <EmotionalPersonalityModel>();
                value = (float)epm.GetEmotionValue(Stat.ToString());
            }
            else if ((int)Stat >= physicalIndex && (int)Stat < limitIndex)
            {
                PhysicalResourceModel prm = targetCharacter.GetComponent <PhysicalResourceModel>();
                value = (float)prm.GetPhysicalValue(Stat.ToString());
            }
            if (BoolCondition == BooleanCondition.LessThan)
            {
                if (value < Value)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (BoolCondition == BooleanCondition.LessThanOrEqualTo)
            {
                if (value <= Value)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (BoolCondition == BooleanCondition.EqualTo)
            {
                if (value == Value)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (BoolCondition == BooleanCondition.GreaterThanOrEqualTo)
            {
                if (value >= Value)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else if (BoolCondition == BooleanCondition.GreaterThan)
            {
                if (value > Value)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
        }
        return(false);
    }
    private bool SatisfiesStat(Action action, Precondition goalCondition, GameObject targetCharacter)
    {
        if (goalCondition.Stat == StatName.None)
        {
            return(true);
        }
        if (action.TargetObject == targetCharacter)
        {
            StatName         stat       = goalCondition.Stat;
            StatName         actionStat = action.TargetEffect.Stat;
            BooleanCondition condition  = goalCondition.BoolCondition;
            float            change     = action.TargetEffect.Change;

            if (goalCondition.Stat != StatName.None && stat == actionStat)
            {
                EmotionalPersonalityModel epm = action.TargetObject.GetComponent <EmotionalPersonalityModel>();
                PhysicalResourceModel     prm = action.TargetObject.GetComponent <PhysicalResourceModel>();

                if (condition == BooleanCondition.LessThan)
                {
                    if (change < 0.0f)
                    {
                        return(true);
                    }
                }
                else if (condition == BooleanCondition.GreaterThan)
                {
                    if (change > 0.0f)
                    {
                        return(true);
                    }
                }
                else if (condition == BooleanCondition.GreaterThanOrEqualTo)
                {
                    if ((int)stat > 0 && (int)stat < Precondition.physicalIndex)
                    {
                        if (change > 0.0f || ((float)epm.GetEmotionValue(stat.ToString()) + change == goalCondition.Value))
                        {
                            return(true);
                        }
                    }
                    else if ((int)stat >= Precondition.physicalIndex && (int)stat < Precondition.limitIndex)
                    {
                        if (change > 0.0f || ((float)prm.GetPhysicalValue(stat.ToString()) + change == goalCondition.Value))
                        {
                            return(true);
                        }
                    }
                }
                else if (condition == BooleanCondition.LessThanOrEqualTo)
                {
                    if ((int)stat > 0 && (int)stat < Precondition.physicalIndex)
                    {
                        if (change < 0.0f || ((float)epm.GetEmotionValue(stat.ToString()) + change == goalCondition.Value))
                        {
                            return(true);
                        }
                    }
                    else if ((int)stat >= Precondition.physicalIndex && (int)stat < Precondition.limitIndex)
                    {
                        if (change < 0.0f || ((float)prm.GetPhysicalValue(stat.ToString()) + change == goalCondition.Value))
                        {
                            return(true);
                        }
                    }
                }
                else if (condition == BooleanCondition.EqualTo)
                {
                    if ((int)stat > 0 && (int)stat < Precondition.physicalIndex)
                    {
                        if ((float)epm.GetEmotionValue(stat.ToString()) + change == goalCondition.Value)
                        {
                            return(true);
                        }
                    }
                    else if ((int)stat >= Precondition.physicalIndex && (int)stat < Precondition.limitIndex)
                    {
                        if ((float)prm.GetPhysicalValue(stat.ToString()) + change == goalCondition.Value)
                        {
                            return(true);
                        }
                    }
                }
            }
        }
        return(false);
    }