예제 #1
0
        private void FireRandomSentinel()
        {
            var sentinels = SentinelPool.Where(x => SpaceUtil.SpriteIsInBounds(x));

            if (RandomUtil.TryGetRandomElement(sentinels, out PlayerBullet bullet))
            {
                FireSentinelForward(bullet);
            }
        }
예제 #2
0
        /// <summary>
        /// Fires the Sentinel currently directly in front of the player.
        /// </summary>
        private void FireBestSentinel()
        {
            const float FullCircle        = 360f;
            const float RightAngle        = 90f;
            const float HalfSentinelAngle = FullCircle / NumSentinel * 0.5f;

            float angleDegrees = (FullCircle + RightAngle + HalfSentinelAngle);

            angleDegrees -= (Rotation.Angle * Mathf.Rad2Deg);
            angleDegrees %= FullCircle;

            int index = (int)(angleDegrees * NumSentinel / FullCircle);

            index = Mathf.Clamp(index, 0, NumSentinel - 1);

            PlayerBullet sentinel = SentinelPool[index];

            if (SpaceUtil.SpriteIsInBounds(sentinel))
            {
                FireSentinelForward(sentinel);
            }
        }