public object GetStatValue(string characterTarget, string statName) { GameObject target = GameObject.Find(characterTarget); if (target != null) { EmotionalPersonalityModel EPM = target.GetComponent <EmotionalPersonalityModel>(); Character character = target.GetComponent <Character>(); if (statName == EmotionRef.Disappointment.ToString()) { return((float)EPM.GetEmotionValue(EmotionRef.Disappointment)); } else if (statName == EmotionRef.Distress.ToString()) { return((float)EPM.GetEmotionValue(EmotionRef.Distress)); } else if (statName == EmotionRef.Fear.ToString()) { return((float)EPM.GetEmotionValue(EmotionRef.Fear)); } else if (statName == EmotionRef.Joy.ToString()) { return((float)EPM.GetEmotionValue(EmotionRef.Joy)); } else if (statName == EmotionRef.Anger.ToString()) { return((float)EPM.GetEmotionValue(EmotionRef.Anger)); } else if (statName == "inventory") { return(character.heldItem); } else if (statName == "location") { return(new int[2] { character.cX, character.cY }); } else if (statName == "hunger") { return(0.5f); } } return(null); }
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"); } }
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); }