Ejemplo n.º 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();
            }
        }
Ejemplo n.º 2
0
 /// <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);
Ejemplo n.º 3
0
        /// <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();
            }
        }