Example #1
0
        public int AddFirefly(bool destroyOnReachTarget, Vector3 spawnPoint, Transform target = null)
        {
            if (target == null)
            {
                target = GetRandomTransformPoint();
            }

            if (ExtensionFunctions.IsVectorZero(spawnPoint))
            {
                spawnPoint = GetRandomTransformPoint().position;
            }

            _currentIndex += 1;

            GameObject         fireflyInstance    = SpawnFirefly(spawnPoint);
            FloatyFollowTarget followTarget       = fireflyInstance.GetComponent <FloatyFollowTarget>();
            FireflyInformation fireflyInformation = new FireflyInformation
            {
                destroyOnReachTarget = destroyOnReachTarget,
                fireflyIndex         = _currentIndex,
                fireflyInstance      = followTarget
            };

            followTarget.UpdateTarget(target);
            _fireflies.Add(fireflyInformation);

            return(_currentIndex);
        }