Exemple #1
0
        /// <summary>
        /// Starts or unpause the coroutine.
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public void Start()
        {
            switch (Status)
            {
            case CoroutineStatus.NotStarted:
                if (!Application.isPlaying)
                {
                    BulletStormLogger.LogError("Can't start coroutine in editor.");
                    return;
                }
                Status    = CoroutineStatus.Running;
                coroutine = Root.StartCoroutine(Wrapper());
                break;

            case CoroutineStatus.Paused:
                Status = CoroutineStatus.Running;
                break;

            case CoroutineStatus.Running:
                BulletStormLogger.Log("Coroutine already started.");
                break;

            case CoroutineStatus.Finished:
                BulletStormLogger.LogError("Coroutine is finished. Call 'Restart' if you want to start it again.");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #2
0
        /// <summary>
        /// Stops the coroutine.
        /// </summary>
        /// <param name="callback">Still send a callback if coroutine finished by this.</param>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        private void Stop(bool callback)
        {
            switch (Status)
            {
            case CoroutineStatus.Running:
            case CoroutineStatus.Paused:
                Root.StopCoroutine(coroutine);
                Status = CoroutineStatus.Finished;
                if (callback)
                {
                    OnFinish();
                }
                break;

            case CoroutineStatus.NotStarted:
                BulletStormLogger.LogWarning("Coroutine not started.");
                break;

            case CoroutineStatus.Finished:
                BulletStormLogger.Log("Coroutine already finished.");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
 /// <summary>
 /// Get stored value. Log error if value conflicts with given type.
 /// </summary>
 /// <typeparam name="T">Value type.</typeparam>
 /// <returns></returns>
 public T GetValue <T>()
 {
     if (TryGetValue(out T variable))
     {
         return(variable);
     }
     if (IsEmpty)
     {
         BulletStormLogger.LogError("Variable is empty.");
     }
     else
     {
         BulletStormLogger.LogError("Can't convert " + Type + " to " + typeof(T));
     }
     return(default);
        /// <summary>
        /// Initiate and check if target is valid.
        /// </summary>
        /// <returns></returns>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public bool Check()
        {
            if (AsTransform)
            {
                return(true);
            }
            switch (findBy)
            {
            case FindMethod.Transform:
                AsTransform = transform;
                return(AsTransform);

            case FindMethod.Name:
                var go = GameObject.Find(info);
                if (!go)
                {
                    BulletStormLogger.LogError("Can't find game object '" + info + "'.");
                    return(false);
                }
                else
                {
                    AsTransform = go.transform;
                    return(true);
                }

            case FindMethod.Tag:
                go = GameObject.FindWithTag(info);
                if (!go)
                {
                    BulletStormLogger.LogError("Can't find game object with tag '" + info + "'.");
                    return(false);
                }
                else
                {
                    AsTransform = go.transform;
                    return(true);
                }

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemple #5
0
        /// <summary>
        /// Pauses the coroutine.
        /// </summary>
        /// <exception cref="ArgumentOutOfRangeException"></exception>
        public void Pause()
        {
            switch (Status)
            {
            case CoroutineStatus.Running:
                Status = CoroutineStatus.Paused;
                break;

            case CoroutineStatus.NotStarted:
                BulletStormLogger.LogWarning("Coroutine not started.");
                break;

            case CoroutineStatus.Paused:
                BulletStormLogger.Log("Coroutine already paused.");
                break;

            case CoroutineStatus.Finished:
                BulletStormLogger.LogWarning("Coroutine is finished.");
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }