Ejemplo n.º 1
0
 public void Start(int levelTimeSec,Action OnPortalOpen)
 {
     this.OnPortalOpen = OnPortalOpen;
     timer = MainController.Instance.TimerManager.MakeTimer(new TimeSpan(levelTimeSec/2));
     timer.OnTimer += OnMiddleGame;
     deltaPortalTime = PortalOpenTime/10;
 }
Ejemplo n.º 2
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);
    }
Ejemplo n.º 3
0
    private void OpenNewPortalAction()
    {
        OpenPortal();
        nextPortalOpenTime -= deltaPortalTime;
        timer = MainController.Instance.TimerManager.MakeTimer(new TimeSpan(nextPortalOpenTime));
        timer.OnTimer += OpenNewPortalAction;

    }
Ejemplo n.º 4
0
 public void Dispose()
 {
     if (timer != null)
     {
         timer.Stop();
         timer = null;
     }
 }
Ejemplo n.º 5
0
 public void Init(float power, TalismanTrapDamage talic)
 {
     base.Init();
     timer2 = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromSeconds(LIFE_TIME2),true);
     timer2.OnTimer += OnCheck;
     this.talic = talic;
     this.power = power;
 }
Ejemplo n.º 6
0
 public StayAction(BaseMonster owner, Action<EndCause> endCallback) 
     : base(owner, endCallback)
 {
     timer = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromSeconds(UnityEngine.Random.Range(2, 10)));
     timer.OnTimer += () =>
     {
         endCallback(EndCause.no);
     };
 }
Ejemplo n.º 7
0
 public TimeEffect(Unit targetUnit)
 {
     this.targetUnit = targetUnit;
     timer = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromSeconds(totalTime));
     timer.OnTimer += OnTimer;
     MainController.Instance.level.OnEndLevel += OnEndLevel;
     targetUnit.OnDead += OnTargetDead;
     endEffect = new IEndEffect();
 }
Ejemplo n.º 8
0
 public void Add()
 {
     Count++;
     if (Timer != null)
     {
         //PublicWorld.TimerManager.RemoveTimer(Timer);
         Timer = null;
     }
 }
Ejemplo n.º 9
0
 public BulletEffect(Unit unit,float leightMS,Action setAction,Action undoAction)
 {
     trg = unit;
     this.undoAction = undoAction;
     unit.OnDead += OnDead;
     timer = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromMilliseconds(leightMS));
     timer.OnTimer += OnEnd;
     setAction();
 }
Ejemplo n.º 10
0
 public ITextTyper Stop()
 {
     if (timer != null)
     {
         TimerManager.Remove(timer);
         timer = null;
     }
     return(this as ITextTyper);
 }
Ejemplo n.º 11
0
 private void OnTimer()
 {
     if (gameObject != null)
     {
         if (dieEffect != null)
         {
             Map.Instance.LeaveEffect(dieEffect,transform);
             dieEffect.Play();
         }
         timer = null;
         Destroy(gameObject);
     }
 }
Ejemplo n.º 12
0
 public void Init(TalismanChain sourseItem, Hero hero,int targetsCount)
 {
     power = sourseItem.Power;
     transform.position = hero.transform.position;
     if (hitEffect != null)
     {
         hitEffect.Stop();
     }
     maxTargets = targetsCount;
     timer = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromMilliseconds(800), true);
     timer.OnTimer += OnTimer;
     StartCoroutine(Wait1Frame());
 }
Ejemplo n.º 13
0
    private void StartReborn()
    {
        if (!isReborned)
        {
            int sec = UnityEngine.Random.Range(15, 30);
//            Debug.Log("Start reborn in " + sec);
            if (UnityEngine.Random.Range(0, 100) < 95)
            {
                Debug.Log("Start reborn in " + sec);
                timer = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromSeconds(sec));
                timer.OnTimer += OnReborn;
            }
            isReborned = true;
        }
    }
Ejemplo n.º 14
0
    private void OnMonsterGetHit(BaseMonster obj)
    {
        MonsterSliderHP.gameObject.SetActive(true);
        if (animator != null && !isOpen)
        {
            animator.SetTrigger(KEY_OPEN);
//            Debug.Log("SetTrigger(KEY_OPEN)");
            isOpen = true;
        }
        MonsterSliderHP.value = obj.CurHp / obj.Parameters[ParamType.Heath];
        if (timer != null)
        {
            timer.Stop();
        }
        timer = MainController.Instance.TimerManager.MakeTimer(span);
        timer.OnTimer += OnTimer;
    }
Ejemplo n.º 15
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);
 }
Ejemplo n.º 16
0
 public void Stop()
 {
     if (rotateTimer != null)
     {
         TimerManager.Remove(rotateTimer);
         rotateTimer = null;
     }
     if (curTimer != null)
     {
         TimerManager.Remove(curTimer);
         curTimer = null;
     }
     if (PlayEndEvent != null)
     {
         PlayEndEvent(this);
         PlayEndEvent = null;
     }
     FrameImage.enabled = false;
     DestroyedEvent     = null;
     IndexEvent.Clear();
 }
Ejemplo n.º 17
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);
    }
Ejemplo n.º 18
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);
 }
Ejemplo n.º 19
0
 public virtual void Init()
 {
     timer = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromSeconds(LIFE_TIME));
     timer.OnTimer += OnTimer;
 }
Ejemplo n.º 20
0
    private void StartReborn()
    {
        if (!isReborned)
        {
            int sec = UnityEngine.Random.Range(60*2, 60*3);
#if UNITY_EDITOR
            if (DebugController.Instance.RESPAWN_TIME_CREEPS_FAST)
            {
                sec = 15;
            }
#endif
            timer = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromSeconds(sec));
            timer.OnTimer += OnReborn;

            isReborned = true;
        }
    }
Ejemplo n.º 21
0
 protected virtual void Use()
 {
     Debug.Log("Use!!! " + sourseItem.TalismanType);
     isUnderCooldown = true;
     timer = MainController.Instance.TimerManager.MakeTimer(TimeSpan.FromMilliseconds(1500));
     timer.OnTimer += OnTimerCome;
     AddEnergy(sourseItem.costShoot,true);
     if (CastEffect != null)
     {
         CastEffect.SetAndPlay(hero);
     }
     DoCallback();
 }
Ejemplo n.º 22
0
 private void OnTimerCome()
 {
     isUnderCooldown = false;
     if (CastEffect != null)
     {
         CastEffect.Stop();
     }
     DoCallback();
     timer = null;
 }
Ejemplo n.º 23
0
 private void OnReborn()
 {
     timer = null;
     if (work)
     {
         BornMosters();
     }
 }