private IEnumerator WaitTimeAndCheckForDelay(List <Branch> candidates, float time)
    {
        float seconds;

        if (clampSpeedToOne && !instantMode)
        {
            seconds = time <= 1 ? 1 : time;
        }
        else
        {
            seconds = time;
        }
        yield return(new WaitForSeconds(seconds));

        float delay = Current.Template.PhraseFeature.delay;

        if (delay > 0)
        {
            var coroutine = new CoroutineObject <List <Branch>, float>(this, PlayWithDelay);
            coroutine.Start(candidates, delay);
            CurrentDelay = coroutine;
        }
        else
        {
            Play(candidates);
        }
    }
Beispiel #2
0
        public Effects(Entity newEntity)
        {
            entity      = newEntity;
            currEffects = entity.currentEffects;

            effectOnDelete += (x) => RemoveEffect(x);

            coroutineObject = new CoroutineObject(entity, EffectMonitoring);
            coroutineObject.Start();
        }
Beispiel #3
0
 /// <summary>
 /// Throttles the invoking of an action to the given time.
 /// Creates a game object, and runs on the Main thread within a coroutine.
 /// </summary>
 /// <param name="function">Action to invoke</param>
 /// <param name="wait">Time between invokes</param>
 /// <param name="invokeWhen">Time when to invoke. Trailing = end of wait, Leading = before the wait.</param>
 public void Run(Action function, float wait          = 2f, InvokeWhen invokeWhen = InvokeWhen.Trailing,
                 [CallerMemberName] string memberName = "",
                 [CallerFilePath] string filePath     = "",
                 [CallerLineNumber] int lineNumber    = -1)
 {
     if (m_CoroutineRunner == null)
     {
         m_CoroutineRunner = new GameObject($"ThrottleActionObject - {filePath} : {lineNumber} - {memberName}  ({this.GetHashCode()})").AddComponent <CoroutineObject>();
     }
     m_Value           = function;
     this.m_Wait       = wait;
     this.m_InvokeWhen = invokeWhen;
     if (m_Throttling)
     {
         return;
     }
     m_Coroutine = Invoker();
     this.m_CoroutineRunner.StartCoroutine(m_Coroutine);
 }
    public void LoadGame()
    {
        SpawnLog();

        InitializeGlobalVariables();

        XDocument xDoc = XDocument.Load(_savePath);

        var anyEndGame = xDoc.Element("save").Element("log").Elements("endGame").Any();

        if (anyEndGame)
        {
            Debug.Log("Game already ended.");
            _controller.GameEnded = true;
            return;
        }

        // set startOn
        var xExecute  = xDoc.Element("save").Element("execute");
        var executeId = xExecute.Attribute(Const.XmlAliases.ExecuteId).Value;

        _player.StartOn = ArticyDatabase.GetObject(executeId);

        // проверить дилей
        var result = CheckForDelay(xExecute);

        if (result.remainingInMinutes > 0)
        {
            var coroutine = new CoroutineObject <DateTime, float>(_controller, _controller.ExecuteWithDelay);
            coroutine.Finished += () =>
            {
                _controller.PlayerStandBy = false;
            };
            coroutine.Start(result.startTime, result.remainingInMinutes);
            _controller.CurrentDelay = coroutine;
        }
        else
        {
            _controller.PlayerStandBy = false;
        }
    }
Beispiel #5
0
 public void RunMoveTimer()
 {
     moveRoutine = new CoroutineObject(gameComponent, OnMove);
     moveRoutine.Start();
 }
 public void ConStruct()
 {
     coroutineObject = ConfactoryTools.CreateConGameObject(NAME_OBJECT).AddComponent <CoroutineObject>();
     UpdateName();
 }
Beispiel #7
0
 public virtual void Init(Entity newentity)
 {
     entity          = newentity;
     coroutineObject = new Help.CoroutineObject(entity, EffectExecution);
 }
Beispiel #8
0
 public IntListener(MonoBehaviour newowner)
 {
     unityEventResponse = new UnityIntEvent();
     owner           = newowner;
     coroutineObject = new CoroutineObject(owner, EffectExecution);
 }
Beispiel #9
0
 public IConfactory ConStruct(IConfactoryFinder confactoryFinder)
 {
     coroutineObject = ConfactoryTools.CreateConGameObject(NAME_OBJECT).AddComponent <CoroutineObject>();
     UpdateName();
     return(null);
 }