/// --------------------------------------------- /// Behavior Designer /// Copyright (c) Opsive. All Rights Reserved. /// https://www.opsive.com /// --------------------------------------------- namespace Opsive.BehaviorDesigner.Samples { using Opsive.BehaviorDesigner.Runtime.Tasks; using Opsive.BehaviorDesigner.Runtime.Tasks.Actions; using Opsive.GraphDesigner.Runtime; using Opsive.GraphDesigner.Runtime.Variables; using UnityEngine; [Opsive.Shared.Utility.Description("Adjusts the health amount by a strength factor.")] [Shared.Utility.Category("Behavior Designer Samples")] public class StrengthOperator : Action { [Tooltip("The amount of damage to apply.")] [SerializeField] protected SharedVariable m_DamageAmount; [Tooltip("The agent's strength")] [SerializeField] protected SharedVariable m_Strength; [Tooltip("The variable to store the result.")] [RequireShared] [SerializeField] protected SharedVariable m_HealthResult; /// /// Deducts the health value. /// /// Success after the deduction is applied. public override TaskStatus OnUpdate() { m_HealthResult.Value -= m_DamageAmount.Value * Mathf.Max(1, m_Strength.Value); return TaskStatus.Success; } } }