Exemple #1
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_leftPropertyName, out T leftValue) &
                             blackboard.TryGetStructValue(m_rightPropertyName, out T rightValue);

            return(StateToStatusHelper.ConditionToStatus(leftValue.CompareTo(rightValue) > 0, hasValues));
        }
Exemple #2
0
        protected override Status Execute()
        {
            bool hasValue = blackboard.TryGetClassValue(m_propertyName, out T value);
            bool isLess   = m_value != null && m_value.CompareTo(value) > 0;

            return(StateToStatusHelper.ConditionToStatus(isLess, hasValue));
        }
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_fromPropertyName, out Vector2 from) &
                             blackboard.TryGetStructValue(m_toPropertyName, out Vector2 to);

            return(StateToStatusHelper.ConditionToStatus(Vector2.Angle(from, to) < m_angle, hasValues));
        }
Exemple #4
0
        protected override Status Execute()
        {
            bool hasValue = blackboard.TryGetStructValue(m_colorPropertyName, out Color color);
            bool isLess   = color.g < m_green;

            return(StateToStatusHelper.ConditionToStatus(isLess, hasValue));
        }
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_firstOperandPropertyName, out LayerMask firstOperand) &
                             blackboard.TryGetStructValue(m_secondOperandPropertyName, out LayerMask secondOperand);

            return(StateToStatusHelper.ConditionToStatus(firstOperand == secondOperand, hasValues));
        }
Exemple #6
0
        protected override Status Execute()
        {
            if (m_agent == null || m_sought == null)
            {
                return(StateToStatusHelper.ConditionToStatus(m_dataValid, Status.Error, Status.Failure));
            }

            Vector3 agentPosition  = m_agent.transform.position;
            Vector3 soughtPosition = m_sought.position;
            Vector3 soughtToAgent  = agentPosition - soughtPosition;

            if (soughtToAgent.sqrMagnitude < m_reachDistanceSqr)
            {
                return(Status.Success);
            }

            if (m_agent.pathPending || m_agent.hasPath)
            {
                if ((m_agent.destination - soughtPosition).sqrMagnitude < m_recalculateToleranceSqr)
                {
                    return(Status.Running);
                }
            }

            bool found = m_agent.SetDestination(soughtPosition);

            return(StateToStatusHelper.FailedToStatus(!found));
        }
Exemple #7
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_boundsPropertyName, out Bounds bounds) &
                             blackboard.TryGetStructValue(m_pointPropertyName, out Vector3 point);

            return(StateToStatusHelper.ConditionToStatus(bounds.Contains(point), hasValues));
        }
Exemple #8
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_boundsPropertyName, out Bounds bounds) &
                             blackboard.TryGetStructValue(m_rayPropertyName, out Ray ray);

            return(StateToStatusHelper.ConditionToStatus(bounds.IntersectRay(ray), hasValues));
        }
 protected override Status Execute()
 {
     return(blackboard.TryGetClassValue(m_animatorPropertyName, out Animator animator) & animator != null&
            blackboard.TryGetStructValue(m_valuePropertyName, out float value)
                                 ? StateToStatusHelper.ConditionToStatus(animator.GetFloat(m_propertyId) == value)
                                 : Status.Error);
 }
Exemple #10
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_fromPropertyName, out Vector3 from) &
                             blackboard.TryGetStructValue(m_toPropertyName, out Vector3 to);

            return(StateToStatusHelper.ConditionToStatus(Vector3.Dot(from, to) > m_dot, hasValues));
        }
Exemple #11
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_vectorPropertyName, out Vector2 vector) &
                             blackboard.TryGetStructValue(m_xPropertyName, out float x);

            return(StateToStatusHelper.ConditionToStatus(vector.x < x, hasValues));
        }
Exemple #12
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_firstOperandPropertyName, out Quaternion first) &
                             blackboard.TryGetStructValue(m_secondOperandPropertyName, out Quaternion second);

            return(StateToStatusHelper.ConditionToStatus(Quaternion.Angle(first, second) > m_angle, hasValues));
        }
Exemple #13
0
        public static void ConditionToStatusTest()
        {
            Assert.AreEqual(Status.Success, StateToStatusHelper.ConditionToStatus(true));
            Assert.AreEqual(Status.Failure, StateToStatusHelper.ConditionToStatus(false));

            Assert.AreEqual(Status.Success, StateToStatusHelper.ConditionToStatus(true, true));
            Assert.AreEqual(Status.Failure, StateToStatusHelper.ConditionToStatus(false, true));

            Assert.AreEqual(Status.Error, StateToStatusHelper.ConditionToStatus(true, false));
            Assert.AreEqual(Status.Error, StateToStatusHelper.ConditionToStatus(false, false));

            Assert.AreEqual(Status.Failure,
                            StateToStatusHelper.ConditionToStatus(false, Status.Failure, Status.Success));
            Assert.AreEqual(Status.Success,
                            StateToStatusHelper.ConditionToStatus(true, Status.Failure, Status.Success));

            Assert.AreEqual(Status.Running,
                            StateToStatusHelper.ConditionToStatus(false, Status.Running, Status.Success));
            Assert.AreEqual(Status.Success,
                            StateToStatusHelper.ConditionToStatus(true, Status.Running, Status.Success));

            Assert.AreEqual(Status.Error,
                            StateToStatusHelper.ConditionToStatus(false, Status.Error, Status.Failure));
            Assert.AreEqual(Status.Failure,
                            StateToStatusHelper.ConditionToStatus(true, Status.Error, Status.Failure));
        }
Exemple #14
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_hitPropertyName, out NavMeshHit hit) &
                             blackboard.TryGetStructValue(m_distancePropertyName, out float distance);

            return(StateToStatusHelper.ConditionToStatus(hit.distance < distance, hasValues));
        }
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_vectorPropertyName, out Vector2 vector) &
                             blackboard.TryGetStructValue(m_magnitudePropertyName, out float magnitude);

            return(StateToStatusHelper.ConditionToStatus(vector.sqrMagnitude > magnitude * magnitude, hasValues));
        }
        protected override Status Execute()
        {
            bool hasValue  = blackboard.TryGetStructValue(m_colorPropertyName, out Color color);
            bool isGreater = color.r > m_red;

            return(StateToStatusHelper.ConditionToStatus(isGreater, hasValue));
        }
Exemple #17
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_valuePropertyName, out LayerMask value) &
                             blackboard.TryGetStructValue(m_maskPropertyName, out LayerMask mask);

            return(StateToStatusHelper.ConditionToStatus((value & mask) != 0, hasValues));
        }
Exemple #18
0
        protected override Status Execute()
        {
            Status childStatus = child.Tick();
            int    midStatus   = (int)(childStatus & Status.Success) << 1 | (int)(childStatus & Status.Failure) >> 2;

            return(StateToStatusHelper.ConditionToStatus(midStatus == 0, (Status)midStatus, childStatus));
        }
Exemple #19
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_originPropertyName, out Vector3 origin) &
                             blackboard.TryGetStructValue(m_endPropertyName, out Vector3 end);

            return(StateToStatusHelper.ConditionToStatus(Physics.Linecast(origin, end, m_layerMask), hasValues));
        }
Exemple #20
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_quaternionPropertyName, out Quaternion quaternion) &
                             blackboard.TryGetStructValue(m_xPropertyName, out float x);

            return(StateToStatusHelper.ConditionToStatus(quaternion.x < x, hasValues));
        }
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_firstPropertyName, out T firstValue) &
                             blackboard.TryGetStructValue(m_secondPropertyName, out T secondValue);

            return(StateToStatusHelper.ConditionToStatus(firstValue.Equals(secondValue), hasValues));
        }
Exemple #22
0
        protected override Status Execute()
        {
            bool hasValue = blackboard.TryGetStructValue(m_raycastHitPropertyName, out RaycastHit raycastHit) &
                            blackboard.TryGetStructValue(m_distancePropertyName, out float distance);

            return(StateToStatusHelper.ConditionToStatus(raycastHit.distance < distance, hasValue));
        }
        protected override Status Execute()
        {
            Status childStatus = child.Tick();
            bool   isTimeOver  = childStatus == Status.Running & (Time.time - m_beginTime >= m_duration);

            return(StateToStatusHelper.ConditionToStatus(isTimeOver, childStatus, Status.Failure));
        }
Exemple #24
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_colorPropertyName, out Color color) &
                             blackboard.TryGetStructValue(m_alphaPropertyName, out float alpha);
            bool isLess = color.a < alpha;

            return(StateToStatusHelper.ConditionToStatus(isLess, hasValues));
        }
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_positionPropertyName, out Vector3 position) &
                             blackboard.TryGetStructValue(m_radiusPropertyName, out float radius);

            return(StateToStatusHelper.ConditionToStatus(Physics.CheckSphere(position, radius, m_layerMask),
                                                         hasValues));
        }
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetClassValue(m_leftPropertyName, out T leftValue) &
                             blackboard.TryGetClassValue(m_rightPropertyName, out T rightValue);
            bool isGreater = rightValue == null ? leftValue != null : rightValue.CompareTo(leftValue) < 0;

            return(StateToStatusHelper.ConditionToStatus(isGreater, hasValues));
        }
Exemple #27
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_colorPropertyName, out Color color) &
                             blackboard.TryGetStructValue(m_bluePropertyName, out float blue);
            bool isGreater = color.b > blue;

            return(StateToStatusHelper.ConditionToStatus(isGreater, hasValues));
        }
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_boundsPropertyName, out Bounds bounds) &
                             blackboard.TryGetStructValue(m_pointPropertyName, out Vector3 point);
            bool isless = bounds.SqrDistance(point) < m_sqrDistance;

            return(StateToStatusHelper.ConditionToStatus(isless, hasValues));
        }
Exemple #29
0
        protected override Status Execute()
        {
            bool hasValues = blackboard.TryGetStructValue(m_originPropertyName, out Vector3 origin) &
                             blackboard.TryGetStructValue(m_directionPropertyName, out Vector3 direction);

            return(StateToStatusHelper.ConditionToStatus(Physics.Raycast(origin, direction, m_maxDistance, m_layerMask),
                                                         hasValues));
        }
        protected override Status Execute()
        {
            if (blackboard.TryGetClassValue(m_colliderPropertyName, out Collider collider) & collider != null)
            {
                return(StateToStatusHelper.ConditionToStatus(collider.isTrigger));
            }

            return(Status.Error);
        }