Example #1
0
        private static string m_TargetTag; // same for all.


        /// <inheritdoc/>
        public override void Initialize()
        {
            m_Bullets = FindObjectOfType <BulletPool>();
            m_Stats   = Academy.Instance.StatsRecorder;

            m_Ship = GetComponentInChildren <Spaceship>();
            m_Ship.BulletHitEvent += OnBulletHitSuffered;
            m_Ship.CollisionEvent += OnCollision;

            m_Asteroids = FindObjectOfType <AsteroidField>();
            if (m_Asteroids != null)
            {
                m_Asteroids.ScansCompleteEvent += OnAsteroidsScanned;
                m_Ship.EnvironmentRadius        = m_Asteroids.FieldRadius;
            }
            else
            {
                m_Ship.EnvironmentRadius = 100; // TBD
                AddDecisionRequester();
            }

            s_TargetCache ??= CreateTargetCache();
            m_TargetTag ??= m_Ship.tag;
            m_Targets = new List <GameObject>(10);

            m_TargetFollowDistanceSqr = m_TargetFollowDistance * m_TargetFollowDistance;
            m_TargetLockDistanceSqr   = m_TargetLockDistance * m_TargetLockDistance;
        }
Example #2
0
        public override void Initialize()
        {
            m_Asteroids = FindObjectOfType <AsteroidField>();
            m_Bullets   = FindObjectOfType <BulletPool>();
            m_Stats     = Academy.Instance.StatsRecorder;

            m_Ship = GetComponentInChildren <Spaceship>();
            m_Ship.BulletHitEvent   += OnBulletHitSuffered;
            m_Ship.CollisionEvent   += OnCollision;
            m_Ship.EnvironmentRadius = m_Asteroids.FieldRadius;
        }