Пример #1
0
        private Vector3 GenerateValidDashDirection()
        {
            float   predictedDashDistance = AIUtil.GetRandomPredictedDashDistance();
            Vector3 playerPosition        = StateMachine_.Player.transform.position;

            Vector3 lastDashDirection = Vector3.zero;

            for (int i = 0; i < GameConstants.Instance.AIPositionRetries; i++)
            {
                Vector3 dashDirection   = UnityEngine.Random.insideUnitCircle.normalized;
                Vector3 dashEndPosition = playerPosition + (dashDirection * predictedDashDistance);

                lastDashDirection = dashDirection;

                if (!AIUtil.IsXZPositionOnPlatform(dashEndPosition) || AIUtil.DoesWallExistBetweenXZPoints(playerPosition, dashEndPosition))
                {
                    continue;
                }

                return(dashDirection);
            }

            Debug.LogWarning("Using invalid dash direction!", context: StateMachine_.Player);
            return(lastDashDirection);
        }
Пример #2
0
        private Vector3 GenerateRandomNearbyPosition()
        {
            Vector3 lastNearbyPosition = Vector3.zero;

            for (int i = 0; i < GameConstants.Instance.AIPositionRetries; i++)
            {
                Quaternion randomDirection = Quaternion.Euler(new Vector3(0.0f, UnityEngine.Random.Range(0.0f, 360.0f), 0.0f));
                Vector3    nearbyPosition  = stateMachine_.Player.transform.position + (randomDirection * Vector3.forward * UnityEngine.Random.Range(kNearDistanceMin, kNearDistanceMax));

                lastNearbyPosition = nearbyPosition;

                if (!AIUtil.IsXZPositionOnPlatform(nearbyPosition))
                {
                    continue;
                }

                return(nearbyPosition);
            }

            Debug.LogWarning("Using invalid nearby position!", context: stateMachine_.Player);
            return(lastNearbyPosition);
        }