コード例 #1
0
    private void OnCreateLogFileUpdate()
    {
        WaitData data = new WaitData();

        data.waitTime  = 10;
        data.nextState = ePreloadState.CreateReplayFolder;
        SetNextState(ePreloadState.Wait, data);
    }
コード例 #2
0
        // Removes the Wait from the list, if it exists. Returns true if it found and removed it.
        public bool RemoveWaitData(WaitData inputData)
        {
            if (!speedModifyWaits.Contains(inputData))
            {
                return(false);
            }

            _UpdateSingleWait(inputData, true);
            speedModifyWaits.Remove(inputData);
            return(true);
        }
コード例 #3
0
ファイル: UIWaitComponent.cs プロジェクト: gucongyi/MyHot
        public void Awake()
        {
            ReferenceCollector rc = this.GetParent <UI>().GameObject.GetComponent <ReferenceCollector>();

            trans      = rc.Get <GameObject>("UIWait").transform;
            go_GoAwait = rc.Get <GameObject>("GoWait");
            go_GoAwait.SetActive(false);
            waitData           = new WaitData();
            waitData.transform = trans;
            waitData.InitUI();
        }
コード例 #4
0
    private void OnInitReplayUpdate()
    {
        ReplayManager.GetInstance().Init();
        WaitData data = new WaitData
        {
            waitTime  = 60,
            nextState = ePreloadState.PreloadFinish,
        };

        SetNextState(ePreloadState.Wait, data);
    }
コード例 #5
0
 // The game doesn't load FsmFloats at the same time as gameobjects so sometimes you have to wait a little bit
 // to get the float values.
 private IEnumerator _WaitForWaitTimeToBeLoaded(WaitData inputData)
 {
     while (inputData.CachedWait.time.Value <= epsilon)
     {
         yield return(null);
     }
     inputData.SetDefaultWaitTime(inputData.CachedWait.time.Value);
     speedModifyWaits.Add(inputData);
     if (active && speedModActive)
     {
         _UpdateSingleWait(inputData);
     }
 }
コード例 #6
0
    private void OnCreateReplayFolderUpdate()
    {
        string path = Application.dataPath + "/../Rep";

        if (!System.IO.Directory.Exists(path))
        {
            Directory.CreateDirectory(path);
        }
        WaitData data = new WaitData();

        data.waitTime  = 10;
        data.nextState = ePreloadState.PreloadAtlas;
        SetNextState(ePreloadState.Wait, data);
    }
コード例 #7
0
    private void OnPereloadAtlasUpdate()
    {
        string atlasName = _preloadAtlasList[_listCounter];

        ResourceManager.GetInstance().GetSpriteAtlas(atlasName);

        _listCounter++;
        if (_listCounter >= _preloadAtlasList.Count)
        {
            WaitData data = new WaitData
            {
                waitTime  = 10,
                nextState = ePreloadState.InitReplay,
            };
            SetNextState(ePreloadState.Wait, data);
        }
    }
コード例 #8
0
            void OpenPresentWait(Type presentType, LoadRuleData rule, object openArg, Action callback)
            {
                if (null != this.wait)
                {
                    Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:NEXT_DUPLICATED_EXCEPTION#1:{2}, RULE:{3}, ARG:{4}, CB{5}, WAIT:{6}, CURRENT:{7}",
                                                 this.CurrentPresentName,
                                                 (uint)this.CurrentPresentHashCode,
                                                 null != presentType ? presentType.Name : "null",
                                                 rule,
                                                 openArg,
                                                 callback,
                                                 this.wait,
                                                 this.presentType));
                    return;
                }

                this.wait = new WaitData(presentType, rule, openArg, callback);
            }
コード例 #9
0
        // Adds a Wait to the list, stored in the struct format WaitData. Use a constructor to build it.
        public void AddWaitData(WaitData inputData)
        {
            if (inputData.CustomGameObject == null)
            {
                inputData.CustomGameObject = gameObject;
            }

            if (inputData.CachedWait == null)
            {
                inputData.CachedWait =
                    _getOrCacheFSMWait(inputData.FSMStateName, inputData.FSMName,
                                       inputData.CustomGameObject, inputData.ElementIndex);
            }

            if (inputData.CachedWait == null)
            {
                throw new System.NullReferenceException("No Wait Action found on the FSM "
                                                        + inputData.FSMName + " in state " + inputData.FSMStateName);
            }

            float tVal = inputData.CachedWait.time.Value;

            if (tVal <= epsilon)
            {
                StartCoroutine(_WaitForWaitTimeToBeLoaded(inputData));
            }
            else
            {
                inputData.SetDefaultWaitTime(tVal);
                speedModifyWaits.Add(inputData);

                if (active && speedModActive)
                {
                    _UpdateSingleWait(inputData);
                }
            }
        }
コード例 #10
0
        private void _UpdateSingleWait(WaitData inputData, bool restoreOriginal = false)
        {
            if (inputData.CachedWait == null)
            {
                throw new NullReferenceException("No Wait Action found on the FSM "
                                                 + inputData.FSMName + " in state " + inputData.FSMStateName);
            }
            float realFactor = (float)(((danceSpeed - 1.0) * (inputData.WaitTimeInverseFactor - 1.0)) + 1.0);

            if (!active || !speedModActive || restoreOriginal)
            {
                realFactor = 1.0f;
            }
            // Stop divide by zero.
            else if (realFactor <= epsilon)
            {
                throw new Exception("To prevent Playmaker undefined behavior," +
                                    " your speed factor must be greater than " +
                                    epsilon + ". But a dance speed of " + danceSpeed +
                                    " set it to " + realFactor);
            }

            inputData.CachedWait.time = (inputData.DefaultWaitTime / realFactor);
        }
コード例 #11
0
 public EnemyWaitAction(WaitData _waitData)
 {
     time = _waitData.time;
     coroutine = null;
 }
コード例 #12
0
    public IEnumerator Timer(WaitData wait)
    {
        yield return(wait.Wait());

        timerEvent.Invoke();
    }
コード例 #13
0
 public void StartTimer(WaitData wait)
 {
     StartCoroutine(Timer(wait));
 }
コード例 #14
0
            internal void UpdatePresent()
            {
                if (this.isResumeStart)
                {
                    this.isSuspended   = false;
                    this.isResumeStart = false;

                    if (null != this.loadedPresent)
                    {
                        try
                        {
                            if (this.loadedPresent.isPresentSuspended)
                            {
                                this.loadedPresent.isPresentSuspended = false;
                                this.loadedPresent.OnResume();
                            }
                        }
                        catch (Exception e)
                        {
                            Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:ONRESUME_EXCEPT:{2}",
                                                         this.CurrentPresentName,
                                                         (uint)this.CurrentPresentHashCode,
                                                         e));
                        }
                    }
                }
                else if (this.isSuspended)
                {
                    return;
                }



                var loaded = false;

                if (null != this.preloadPresent)
                {
                    if (this.fastOpenWait)
                    {
                        if (this.preloadPresent.DoOpen)
                        {
                            this.fastOpenWait = false;
                            this.asyncOper    = SceneManager.LoadSceneAsync(this.presentType.Name);
                        }
                        else
                        {
                            return;
                        }
                    }
                    else if (null != this.asyncOperFakeOpenForGarbageCollect)
                    {
                        if (this.asyncOperFakeOpenForGarbageCollect.isDone && this.preloadPresent.DoOpen)
                        {
                            this.asyncOperFakeOpenForGarbageCollect = null;
                            this.asyncOper = SceneManager.LoadSceneAsync(this.presentType.Name);
                        }
                        else
                        {
                            return;
                        }
                    }

                    if (null != this.asyncOper)
                    {
                        if (!this.asyncOper.allowSceneActivation)
                        {
                            this.asyncOper.allowSceneActivation = true;
                        }

                        if (!this.asyncOper.isDone)
                        {
                            this.preloadPresent.loadingProgress = this.asyncOper.progress;
                            return;
                        }

                        this.asyncOper = null;
                        this.OpenPresent();

                        loaded = true;
                    }
                }

                if (loaded)
                {
                    var openCallback = this.openCallback;
                    this.openCallback = null;
                    if (null != openCallback)
                    {
                        openCallback();
                    }

                    if (null != this.openListener)
                    {
                        this.openListener();
                    }

                    this.isChanging = false;
                }

                if (null != this.loadedPresent)
                {
                    try
                    {
                        this.loadedPresent.OnUpdate();
                    }
                    catch (Exception e)
                    {
                        Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:ONUPDATE_EXCEPT:{2}",
                                                     this.CurrentPresentName,
                                                     (uint)this.CurrentPresentHashCode,
                                                     e));
                    }

                    var fsm = this.loadedPresent.fsm;
                    if (fsm.HasStateTasks())
                    {
                        try
                        {
                            fsm.RunStateTasks();
                        }
                        catch (Exception e)
                        {
                            Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:STATETASK_EXCEPT:{2}",
                                                         this.CurrentPresentName,
                                                         (uint)this.CurrentPresentHashCode,
                                                         e));
                        }
                    }

                    if (fsm.HasTasks())
                    {
                        try
                        {
                            fsm.RunTasks();
                        }
                        catch (Exception e)
                        {
                            Debug.LogError(string.Format("PRESENT<{0}={1:X8}>:TASK_EXCEPT:{2}",
                                                         this.CurrentPresentName,
                                                         (uint)this.CurrentPresentHashCode,
                                                         e));
                        }
                    }
                }

                if (loaded)
                {
                    if (null != this.wait)
                    {
                        var w = this.wait;
                        this.wait = null;
                        this.OpenNextPresent(w.PresentType, w.Rule, w.OpenArg, w.Callback);
                    }
                }

                if (Input.GetKeyDown(KeyCode.Escape))
                {
                    this.Back();
                }
            }
コード例 #15
0
ファイル: World.cs プロジェクト: tml/Scratch-Library
 /// <summary>
 /// Waits the specified amount of time.
 /// </summary>
 /// <param name="time">The amount of time to wait.</param>
 public void Wait(TimeSpan time)
 {
     waitdata = new WaitData(time);
     waitdata.Wait();
 }