Esempio n. 1
0
    /// <summary>
    /// 打开外部的一个进行,eg:1.exe
    /// </summary>
    /// <param name="ralativePath">进程的路劲</param>
    /// <param name="callback">进程关闭的回调</param>
    public static void StartExternalApp(string ralativePath, Action callback)
    {
        string m_ralativePath          = ralativePath;
        Action m_extendAppQuitCallback = callback;

        System.Diagnostics.Process myProcess;

        myProcess = new System.Diagnostics.Process();
        myProcess.StartInfo.UseShellExecute = false;
        myProcess.StartInfo.FileName        = ralativePath;
        myProcess.StartInfo.CreateNoWindow  = false;
        myProcess.Start();
        //myProcess.WaitForExit();

        TimerManager.ITimer timer = null;
        timer = TimerManager.Add(-1, (x) =>
        {
            if (!myProcess.HasExited)//没有退出
            {
            }
            else
            {
                if (callback != null)
                {
                    callback();
                    TimerManager.Remove(timer);
                }
            }
        }, -1);
    }
Esempio n. 2
0
    /// <summary></summary>
    /// <param name="source"></param>
    /// <param name="dueTime"></param>
    public static void CancelAfter(this CancellationTokenSource source, int dueTime)
    {
        if (source == null)
        {
            throw new NullReferenceException();
        }
        if (dueTime < -1)
        {
            throw new ArgumentOutOfRangeException("dueTime");
        }
        Contract.EndContractBlock();
        Timer timer = null;

        timer = new Timer(delegate(object state)
        {
            timer.Dispose();
            TimerManager.Remove(timer);
            try
            {
                source.Cancel();
            }
            catch (ObjectDisposedException)
            {
            }
        }, null, -1, -1);
        TimerManager.Add(timer);
        timer.Change(dueTime, -1);
    }
Esempio n. 3
0
    private void StartExternalApp()
    {
        if (GlobalData.m_isFirstEntered)
        {
            PlayTimeMgr.Inst.StartRecord();
            GlobalData.m_isFirstEntered = false;
        }

        // StartHookWindows();
        RecordMgr.Inst.StartRecord(cfgGameList);
        string relativePath = cfgGameList._relativePath;
        string _appPath     = GlobalData.AppContentPath() + relativePath;

        Debug.Log("_appPath:" + _appPath);
        VRSettings.enabled = false;
        Assist.StartExternalApp(_appPath, () =>
        {
            VRSettings.enabled = true;
            RecordMgr.Inst.StopRecord(cfgGameList);
            // HookProcess.Kill();
            ActiveMainWindow("BlackHole");
            TimerManager.Add(1, (x) => { Camera.main.gameObject.GetComponent <RestVRState>().Rest(); });
            isOpening = false;
        });
    }
Esempio n. 4
0
        private void Start()
        {
            foreach (var component in components)
            {
                foreach (var data in datas)
                {
                    if (component.GetData(data))
                    {
                        break;
                    }
                }

                if (component is IStart)
                {
                    (component as IStart).StartGame();
                }

                if (component is ITick)
                {
                    UpdateManager.AddTick(component as ITick);
                }

                if (component is ITimer)
                {
                    TimerManager.Add((component as ITimer).Timer);
                }
            }
        }
Esempio n. 5
0
    private void Awake()
    {
        Debug.Log("add MenuView .");
        root       = transform.GetComponent <RectTransform>();
        title      = transform.FindChild("Title").GetComponent <RectTransform>();
        line1      = transform.FindChild("line1").GetComponent <RectTransform>();
        line2      = transform.FindChild("line2").GetComponent <RectTransform>();
        line3      = transform.FindChild("line3").GetComponent <RectTransform>();
        game       = transform.FindChild("Game").GetComponent <RectTransform>();
        journey    = transform.FindChild("VRJourney").GetComponent <RectTransform>();
        movie      = transform.FindChild("Movie").GetComponent <RectTransform>();
        quit       = transform.FindChild("Quit").GetComponent <RectTransform>();
        effect_row = transform.FindChild("effect_row").gameObject;
        effect_col = transform.FindChild("effect_col").gameObject;

        text_game    = game.transform.FindChild("Text").GetComponent <Text>();
        text_journey = journey.transform.FindChild("Text").GetComponent <Text>();
        text_moive   = movie.transform.FindChild("Text").GetComponent <Text>();
        text_quit    = quit.transform.FindChild("Text").GetComponent <Text>();

        TimerManager.Add(1, Move);

        EventTriggerAssist.Get(game.gameObject).LeftClick += (e) =>
        {
            if (ShowGameEvent != null)
            {
                ShowGameEvent();
            }
        };
        EventTriggerAssist.Get(journey.gameObject).LeftClick += (e) =>
        {
            if (ShowJourneyEvent != null)
            {
                ShowJourneyEvent();
            }
        };
        EventTriggerAssist.Get(movie.gameObject).LeftClick += (e) =>
        {
            if (ShowMovieEvent != null)
            {
                ShowMovieEvent();
            }
        };
        EventTriggerAssist.Get(quit.gameObject).LeftClick += (e) =>
        {
            if (ShowQuitEvent != null)
            {
                ShowQuitEvent();
            }
        };
    }
Esempio n. 6
0
 public IUIFrameEffect SetRotateSpeed(float rotateSpeed)
 {
     this.rotateSpeed = rotateSpeed;
     if (rotateTimer != null)
     {
         TimerManager.Remove(rotateTimer);
         rotateTimer = null;
     }
     if (rotateSpeed != 0)
     {
         rotateTimer = TimerManager.Add(-1, (arg) =>
         {
             FrameImage.transform.localEulerAngles += new Vector3(0, 0, rotateSpeed * Time.deltaTime);
         }, -1);
     }
     return(this);
 }
Esempio n. 7
0
        /// <summary></summary>
        /// <param name="dueTime"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public static Task Delay(Int32 dueTime, CancellationToken cancellationToken)
        {
            if (dueTime < -1)
            {
                throw new ArgumentOutOfRangeException("dueTime", "The timeout must be non-negative or -1, and it must be less than or equal to Int32.MaxValue.");
            }

            Contract.EndContractBlock();
            if (cancellationToken.IsCancellationRequested)
            {
                return(new Task(() => { }, cancellationToken));
            }

            if (dueTime == 0)
            {
                return(s_preCompletedTask);
            }

            var   tcs   = new TaskCompletionSource <Boolean>();
            var   ctr   = default(CancellationTokenRegistration);
            Timer timer = null;

            timer = new Timer(state =>
            {
                ctr.Dispose();
                timer.Dispose();
                tcs.TrySetResult(true);
                TimerManager.Remove(timer);
            }, null, -1, -1);
            TimerManager.Add(timer);
            if (cancellationToken.CanBeCanceled)
            {
                ctr = cancellationToken.Register(() =>
                {
                    timer.Dispose();
                    tcs.TrySetCanceled();
                    TimerManager.Remove(timer);
                });
            }
            timer.Change(dueTime, -1);
            return(tcs.Task);
        }
Esempio n. 8
0
    private void StartExternalApp()
    {
        if (GlobalData.m_isFirstEntered)
        {
            PlayTimeMgr.Inst.StartRecord();
            GlobalData.m_isFirstEntered = false;
        }
        string relativePath = @"大雄宝殿/Buddha.exe";
        string _appPath     = GlobalData.AppContentPath() + relativePath;

        Debug.Log("_appPath:" + _appPath);
        VRSettings.enabled = false;
        Assist.StartExternalApp(_appPath, () =>
        {
            VRSettings.enabled = true;
            ActiveMainWindow("BlackHole");
            TimerManager.Add(1, (x) => { Camera.main.gameObject.GetComponent <RestVRState>().Rest(); });
            isOpening = false;
        });
    }
Esempio n. 9
0
    public ITextTyper Start(int countPerSecond)
    {
        time           = 0;
        isActive       = true;
        words          = text.text;
        charsPerSecond = Mathf.Max(1, countPerSecond);

        if (timer != null)
        {
            TimerManager.Remove(timer);
        }

        timer = TimerManager.Add(-1, (e) =>
        {
            if (isActive)
            {
                try
                {
                    text.text = words.Substring(0, (int)(charsPerSecond * time));
                    time     += Time.deltaTime;
                }
                catch (Exception)
                {
                    isActive  = false;
                    time      = 0;
                    text.text = words;
                    TimerManager.Remove(timer);
                    timer = null;
                    if (done != null)
                    {
                        done();
                    }
                }
            }
        }, -1);
        return(this as ITextTyper);
    }
Esempio n. 10
0
    private void Move(int e)
    {
        TimerManager.Add(1f, (x) =>
        {
            effect_row.SetActive(true);
        });
        TimerManager.Add(2f, (x) =>
        {
            effect_col.SetActive(true);

            text_game.gameObject.GetComponent <TypeWordExample>().PlayTypeWordEffect();
            text_journey.gameObject.GetComponent <TypeWordExample>().PlayTypeWordEffect();
            text_moive.gameObject.GetComponent <TypeWordExample>().PlayTypeWordEffect();
            text_quit.gameObject.GetComponent <TypeWordExample>().PlayTypeWordEffect();
        });


        title.Moveto(new Vector3(-360, 336, 0), 0.3f).setEase(LeanTweenType.easeInCirc);
        line1.Moveto(new Vector3(-720, 334, 0), 0.3f).setDelay(0.2f);
        line2.Moveto(new Vector3(-300, 365, 0), 0.3f).setDelay(0.2f);
        line3.Moveto(new Vector3(-300, 317, 0), 0.3f).setDelay(0.2f);
        line1.Alpha(1, 0.3f);
        line2.Alpha(1, 0.3f);
        line3.Alpha(1, 0.3f);

        game.Moveto(new Vector3(-271, 155, 0), 0.3f).setDelay(0.3f).setEase(LeanTweenType.easeInCubic);
        journey.Moveto(new Vector3(-271, 87, 0), 0.3f).setDelay(0.6f).setEase(LeanTweenType.easeInCubic);
        movie.Moveto(new Vector3(-271, 21, 0), 0.3f).setDelay(0.9f).setEase(LeanTweenType.easeInCubic);
        quit.Moveto(new Vector3(-271, -45, 0), 0.3f).setDelay(1.2f).setEase(LeanTweenType.easeInCubic);
        game.Alpha(1, 0.3f).setDelay(0.3f);
        journey.Alpha(1, 0.3f).setDelay(0.6f);
        movie.Alpha(1, 0.3f).setDelay(1.2f).onComplete = () =>
        {
            root.Rotatey(330, 0.3f);
            root.Moveto(new Vector3(-380, 0, 0), 0.3f);
        };
    }
Esempio n. 11
0
 public void Play(int index = -1)
 {
     if (sprites.Count < 1)
     {
         Stop();
         return;
     }
     TimerManager.Remove(curTimer);
     FrameImage.enabled       = true;
     FrameImage.raycastTarget = false;
     this.index        = index <0 || index> sprites.Count - 1 ? this.index : index;
     FrameImage.sprite = sprites[this.index];
     FrameImage.SetNativeSize();
     if (IndexEvent.ContainsKey(this.index) && this.index == 0)
     {
         IndexEvent[this.index](this);
     }
     curTimer = TimerManager.Add(speed, (arg) =>
     {
         this.index++;
         this.index = this.index > sprites.Count - 1 ? 0 : this.index;
         if (this.index == 0 && !loop) // 第二轮第一帧且非循环播放,结束特效
         {
             Stop();
         }
         else
         {
             FrameImage.sprite = sprites[this.index];
             FrameImage.SetNativeSize();
             if (IndexEvent.ContainsKey(this.index))
             {
                 IndexEvent[this.index](this);
             }
         }
     }, -1);
 }
        /// <summary>Starts a Task that will complete after the specified due time.</summary>
        /// <param name="dueTime">The delay in milliseconds before the returned task completes.</param>
        /// <param name="cancellationToken">A CancellationToken that may be used to cancel the task before the due time occurs.</param>
        /// <returns>The timed Task.</returns>
        /// <exception cref="System.ArgumentOutOfRangeException">
        /// The <paramref name="dueTime"/> argument must be non-negative or -1 and less than or equal to Int32.MaxValue.
        /// </exception>
        public static Task Delay(int dueTime, CancellationToken cancellationToken)
        {
            // Validate arguments
            if (dueTime < -1)
            {
                throw new ArgumentOutOfRangeException("dueTime", ArgumentOutOfRange_TimeoutNonNegativeOrMinusOne);
            }
            Contract.EndContractBlock();

            // Fast-paths if the timeout has expired or the token has had cancellation requested
            if (cancellationToken.IsCancellationRequested)
            {
                return(new Task(() => { }, cancellationToken));
            }
            if (dueTime == 0)
            {
                return(s_preCompletedTask);
            }

            // Create the timed task
            var tcs = new TaskCompletionSource <bool>();
            var ctr = default(CancellationTokenRegistration);

            Timer timer = null;

            // Create the timer but don't start it yet.  If we start it now,
            // it might fire before ctr has been set to the right registration.
            timer = new Timer(state =>
            {
                // Clean up both the cancellation token and the timer, and try to transition to completed
                ctr.Dispose();
                timer.Dispose();
                tcs.TrySetResult(true);

                TimerManager.Remove(timer);
            }, null, Timeout.Infinite, Timeout.Infinite);

            // Make sure the timer stays rooted.  The full Framework
            // does this automatically when constructing a timer with the simple
            // overload that doesn't take state, in which case the timer itself
            // is the state.  But Compact Framework doesn't root, so we need to.
            TimerManager.Add(timer);

            // Register with the cancellation token if a cancelable one was provided.  This must be
            // done after initializing timer, as we call timer.Dispose from within the callback
            // and that callback will fire synchronously if the token has already been canceled
            // by the time we call Register.
            if (cancellationToken.CanBeCanceled)
            {
                // When cancellation occurs, cancel the timer and try to transition to canceled.
                // There could be a race, but it's benign.
                ctr = cancellationToken.Register(() =>
                {
                    timer.Dispose();
                    tcs.TrySetCanceled();
                    TimerManager.Remove(timer);
                });
            }

            // Start the timer and hand back the task...
            timer.Change(dueTime, Timeout.Infinite);
            return(tcs.Task);
        }
Esempio n. 13
0
 public static void Create(float Interval, Action Trigger)
 {
     Timer Timer = new Timer() { Interval = Interval, Trigger = Trigger }
     TimerManager.Add(this);
 }