Exemplo n.º 1
0
        protected virtual BehaviorReturnCode SDSetFaceToTargetExec()
        {
            float originX = charDriver.GetPosition().x;
            float targetX = GetTargetFunc().x;

            // If target is to the right and we are not facing right.
            if ((((targetX >= originX) && !charDriver.IsFacingRight()) ||
                 // If target is to the left and we are facing right
                 (targetX < originX && charDriver.IsFacingRight())))
            {
                // If we entered in this block, the character isn't facing its target. So we need to check
                // if the reverse flag is set (which means that we don't need to face the target.
                if (!reverse)
                {
                    charDriver.Flip();
                }
            }

            return(BehaviorReturnCode.Success);
        }