Beispiel #1
0
 //子弹生命周期结束时调用
 private void LifeEnd(TimerElement element)
 {
     if (_bulletParser.trigger == 2 || _bulletParser.trigger == 3) //子弹生命周期结束时生效
     {
         BulletValid();
     }
 }
Beispiel #2
0
        protected override void OnInitPlayerElements()
        {
            CreateRoleCard(true, true, true, false);

            timerElPlayer = new TimerElement(GetButton("timer_button"), Duration, TimerType.Think);
            Elements.Add("timer", timerElPlayer);
        }
Beispiel #3
0
        void DeclineExtraTime(NetMessage msg)
        {
            // Update player timers
            if (!IsDecider)
            {
                TimerElement timer = GetScreenElement <TimerElement> ("timer");
                timer.Text = GetButton(IsNextPitcher ? "pitching" : "listening");
                timer.Type = IsNextPitcher ? TimerType.Pitch : TimerType.Listen;
                timer.Reset();
                return;
            }

            // Decider logic
            state = State.Pitch;
            Game.Controller.NextPitch();
            if (CurrentPitcher != "")
            {
                AllGotoView("pitch");
                SetDeciderInstructionsText("next_up");
                TimerButton.Reset(Duration);
            }
            else
            {
                AllGotoView("deliberate_instructions");
            }
        }
Beispiel #4
0
    /// <summary>
    /// 每隔多长时间执行一次
    /// </summary>
    /// <param name="key">注册key</param>
    /// <param name="duration">间隔时间</param>
    /// <param name="callBack">事件回调</param>
    /// <param name="isTimeScale">是否受TimeScale影响</param>
    /// <param name="loopCount">循环次数,小于0为无限循环</param>
    /// <param name="life">生命周期,如果同时指定loopCount,谁先到执行finish</param>
    /// <param name="endCB">结束回调</param>
    /// <param name="immRun">立即执行</param>
    public void RegisterCDTimer(object key, float duration, TimerEleCallBack callBack, bool isTimeScale = true, bool immRun = false,
                                int loopCount = 1, float life = -1, TimerEleCallBack endCB = null)
    {
        if (callBack == null)
        {
            return;
        }
        TimerElement element = GetFreeElement();

        element.type           = 0;
        element.key            = key;
        element.duration       = duration;
        element.isTimeScale    = isTimeScale;
        element.callback       = callBack;
        element.loopCountLimit = loopCount;
        element.life           = life;
        element.endCB          = endCB;

        if (immRun)
        {
            element.Execute();
        }

        if (!element.isFinish)
        {
            _timerList.Add(element);
        }
        else
        {
            element.OnDestroy();
        }
    }
Beispiel #5
0
    /// <summary>
    /// 每帧执行回调函数
    /// </summary>
    public object RegisterFrameTimer(TimerEleCallBack callBack, int loopCount = -1, bool isTimeScale = true, bool immRun = false,
                                     float life = -1, TimerEleCallBack endCB = null)
    {
        TimerElement element = GetFreeElement();

        element.type           = 1;
        element.key            = GetUid();
        element.isTimeScale    = isTimeScale;
        element.loopCountLimit = loopCount;
        element.callback       = callBack;
        element.life           = life;
        element.endCB          = endCB;

        if (immRun)
        {
            element.Execute();
        }

        if (!element.isFinish)
        {
            _timerList.Add(element);
        }
        else
        {
            element.OnDestroy();
        }

        return(element.key);
    }
Beispiel #6
0
        /// <summary>
        /// Starts the timer with the specified interval.
        /// </summary>
        public void Start(int interval)
        {
            Stop ();
            element = new TimerElement (raise_timer);

            element.running = true;
            GLib.Timeout.Add ((uint) interval, element.timer_count);
        }
Beispiel #7
0
 /// <summary>
 /// Stops the timer.
 /// </summary>
 public void Stop()
 {
     if (element != null)
     {
         element.running = false;
         element = null;
     }
 }
 public void Show(TimerElement timerElement)
 {
     this.timerElement = timerElement;
     timerElement.SetButton(button, fill, text);
     timer.SetActive(true);
     timer.transform.SetSiblingIndex(timerElement.Position);
     timerButton.Set(timerElement);
     Enabled = true;
 }
Beispiel #9
0
 public override void Dispose()
 {
     base.Dispose();
     luaExpressionProperty.Dispose();
     if (timer != null)
     {
         timeService.RemoveGlobalTimer(timer);
         timer = null;
     }
 }
Beispiel #10
0
        /**
         * ismi verilen saatin en son kontrolünden bu yana ne kadar zaman geçtiðini
         * milisaniye cinsinden döndürür.
         *
         * @param name :  saatin adý
         * @return :Bir önceki tick'ten bu yana geçen süre (milisaniye cinsinden)
         */
        public static long getTimeDelta(String name)
        {
            TimerElement timer = (TimerElement)users[name];

            if (timer == null)
            {
                return(-1);
            }
            timer.refresh();
            return(timer.getDiff());
        }
Beispiel #11
0
        /**
         * @param name : saatin adý
         * @return : Bir önceki tick'ten bu yana geçen süre (milisaniye cinsinden)
         */
        public static String getElapsedTimeStringAsMillis(String name)
        {
            TimerElement timer = (TimerElement)users[name];

            if (timer == null)
            {
                return("Geçersiz Kronometre: " + name);
            }
            timer.refresh();
            return("Delta: " + timer.getDiff() + "ms. Elapsed: " + timer.getElapsedTime() + "ms.");
        }
Beispiel #12
0
        /**
         * ismi verilen saat için baþlangýçtan bu yana bu yana ne kadar zaman
         * geçtiðini milisaniye cinsinden döndürür.
         *
         * @param name : saatin adý
         * @return :Bir önceki tick'ten bu yana geçen süre (milisaniye cinsinden)
         */
        public static long getElapsedTime(String name)
        {
            TimerElement timer = (TimerElement)users[name];

            if (timer == null)
            {
                return(-1);
            }
            timer.refresh();
            return(timer.getElapsedTime());
        }
    void UpdateScreen()
    {
        SetScrollbarActive(false);

        labelManager.RemoveLabels();
        textFieldManager.Hide();
        timerManager.Hide();
        imageManager.Hide();
        scoreboardPoolManager.Hide();
        scoreboardPotManager.Hide();
        buttonManager.RemoveButtons();

        foreach (ScreenElement element in elements)
        {
            if (element is LabelElement)
            {
                LabelElement l = element as LabelElement;
                labelManager.SetLabel(l);
            }
            if (element is TextFieldElement)
            {
                TextFieldElement t = element as TextFieldElement;
                textFieldManager.Show(t);
            }
            if (element is ButtonElement && !(element is BottomButtonElement) && !(element is TimerElement))
            {
                ButtonElement b = element as ButtonElement;
                buttonManager.SetButton(b);
            }
            if (element is TimerElement)
            {
                TimerElement t = element as TimerElement;
                timerManager.Show(t);
            }
            if (element is ImageElement)
            {
                ImageElement i = element as ImageElement;
                imageManager.Show(i);
            }
            if (element is ScoreboardPoolElement)
            {
                ScoreboardPoolElement s = element as ScoreboardPoolElement;
                scoreboardPoolManager.Show(s);
            }
            if (element is ScoreboardPotElement)
            {
                ScoreboardPotElement s = element as ScoreboardPotElement;
                scoreboardPotManager.Show(s);
            }
        }

        CoroutineManager.Instance.WaitForFrame(OnWaitForFrame);
    }
Beispiel #14
0
        /**
         * Saati durdurur ve baþlangýçtan bu yana geçen süreyi saniye ve ms
         * cinsinden döndürür. Ayrýca saati listeden siler.
         *
         * @param name Saat ismi
         * @return baþlangýçtan bu yana geçen süre
         */
        public static String stopClock(String name)
        {
            TimerElement timer = (TimerElement)users[name];

            if (timer == null)
            {
                return(name + " : Geçersiz Kronometre");
            }
            timer.refresh();
            users.Remove(name);
            return("" + (float)timer.getElapsedTime() / 1000 + "sn."
                   + "(" + timer.getElapsedTime() + " ms.)");
        }
Beispiel #15
0
 void Update()
 {
     for (int i = 0; i < _timerList.Count; i++)
     {
         TimerElement element = _timerList[i];
         element.Execute();
         if (element.isFinish)
         {
             RemoveTimer(i);
             i--;
         }
     }
 }
Beispiel #16
0
        public void SetInterval(float f)
        {
            updateRateInSeconds = f;

            if (timer == null)
            {
                timer = timeService.CreateGlobalTimer(f, () => {
                    UpdateExpression();
                }, 0);
            }
            timer.interval = f;
            timer.timeLeft = f;
        }
Beispiel #17
0
        void StartTimer(NetMessage msg)
        {
            if (HasElement("timer"))
            {
                float duration = msg.str1 == "deliberate"
                                        ? Duration
                                        : ExtraTimeDuration;

                TimerElement timer = GetScreenElement <TimerElement> ("timer");
                timer.Reset(duration);
                timer.StartTimer();
            }
            state = State.Extra;
        }
Beispiel #18
0
    /// <summary>
    /// 得到一个可复用的对象
    /// </summary>
    /// <returns></returns>
    private TimerElement GetFreeElement()
    {
        TimerElement element;

        if (_elementPool.Count > 0)
        {
            element = _elementPool.Pop();
        }
        else
        {
            element = new TimerElement();
        }
        return(element);
    }
Beispiel #19
0
 /**
  * Yeni bir saat oluþturur ve listeye register eder.
  * @param name : saat adý
  */
 public static void startClock(String name)
 {
     if (users.Count > MAX_TIMETRACKER_USERS)
     {
         logger.Error("Max Saat izleyici sayýsý aþýldý. (" + MAX_TIMETRACKER_USERS + ")");
         return;
     }
     if (users[name] != null)
     {
         logger.Error(name + " isminde bir zaman izleyici zaten var.");
         return;
     }
     TimerElement timer = new TimerElement(name);
     users.Add(name, timer);
 }
Beispiel #20
0
 //更新方法:更新子弹位置等信息、检查碰撞
 private void Update(TimerElement element)
 {
     //更新子弹位置
     if (!Mathf.Approximately(_bulletParser.speed, 0))
     {
     }
     //检查碰撞
     if (_bulletParser.trigger == 1 || _bulletParser.trigger == 3)
     {
         bool result = true;//碰撞结果
         if (result)
         {
             BulletValid();
         }
     }
 }
Beispiel #21
0
        /**
         * Yeni bir saat oluþturur ve listeye register eder.
         * @param name : saat adý
         */
        public static void startClock(String name)
        {
            if (users.Count > MAX_TIMETRACKER_USERS)
            {
                logger.Error("Max Saat izleyici sayýsý aþýldý. (" + MAX_TIMETRACKER_USERS + ")");
                return;
            }
            if (users[name] != null)
            {
                logger.Error(name + " isminde bir zaman izleyici zaten var.");
                return;
            }
            TimerElement timer = new TimerElement(name);

            users.Add(name, timer);
        }
Beispiel #22
0
        void StartTimer(NetMessage msg)
        {
            if (IsDecider)
            {
                return;
            }

            float duration = msg.str2 == "pitch"
                                ? Duration
                                : ExtraTimeDuration;

            // Start the timer
            TimerElement timer = GetScreenElement <TimerElement> ("timer");

            timer.Reset(duration);
            timer.StartTimer();
        }
Beispiel #23
0
        /**
         * @param name      : saatin adý
         * @param itemCount : sure zarfýnda islenen nesne sayisi
         * @return : baslangictan bu yana islenen saniyedeki eleman sayisi
         */
        public static long getItemsPerSecond(String name, long itemCount)
        {
            TimerElement timer = (TimerElement)users[name];

            if (timer == null)
            {
                return(-1);
            }
            timer.refresh();
            long items = 0;

            if (timer.getElapsedTime() > 0)
            {
                items = (1000 * itemCount) / timer.getElapsedTime();
            }
            return(items);
        }
Beispiel #24
0
    //CD周期:产生子弹
    private void SpawnBullet(TimerElement element)
    {
        int type = _skill.skillParser.type;

        for (int i = 0; i < _launcherParser.num; i++)
        {
            Bullet bullet = PoolMgr.Inst.SpawnObj <Bullet>();
            if (type == 1) //指向性技能:直接将产生的子弹放在目标位置
            {
                bullet.Init(_launcherParser.bulletSn, _skill.targetUnit.pos, _skill);
            }
            else if (type == 2) //非指向性技能:在发射器位置产生子弹
            {
                bullet.Init(_launcherParser.bulletSn, _skill.activeUnit.pos, _skill);
            }
        }
    }
Beispiel #25
0
        /// <summary>
        /// On a screen with timers, checks how much time has elapsed
        /// </summary>
        /// <returns>The amount of time that has elapsed</returns>
        protected int GetElapsedTime()
        {
            float e;

            if (IsDecider)
            {
                TimerButtonElement t = GetScreenElement <TimerButtonElement> ("timer_button");
                e = t.Progress * t.Duration;
            }
            else
            {
                TimerElement t = GetScreenElement <TimerElement> ("timer");
                e = t.Progress * t.Duration;
            }

            return((int)e);
        }
Beispiel #26
0
    protected void InitStageScreen(float timerDuration)
    {
        Events.instance.AddListener <AllReceiveMessageEvent> (OnAllReceiveMessageEvent);
        Events.instance.AddListener <HostReceiveMessageEvent> (OnHostReceiveMessageEvent);
        Events.instance.AddListener <RoundStartEvent> (OnRoundStartEvent);

        this.timerDuration = timerDuration;
        timer = CreateTimer("Timer", 1, name);

        round      = state as RoundState;
        playerName = round.PlayerName;

        ScreenElements.AddEnabled("topLabel", new LabelElement(round.Question, 0, new WhiteTextStyle()));
        ScreenElements.AddEnabled("timer", CreateTimer("Timer", 1, TimerText));
        ScreenElements.AddEnabled("pool", new BeanPoolElement());
        ScreenElements.AddEnabled("pot", new BeanPotElement());
        ScreenElements.AddDisabled("roleCard", CreateButton("View Role Card", 3));
        ScreenElements.AddDisabled("timesUp", new LabelElement("", 4, new CenteredWhiteItalicsStyle()));
        ScreenElements.AddDisabled("next", CreateBottomButton("Next", "", "bottomPink", Side.Right));
        timer = ScreenElements.Get <TimerElement> ("timer");
    }
Beispiel #27
0
        protected void SyncElapsedTime()
        {
            float e;

            if (IsDecider)
            {
                TimerButtonElement t = GetScreenElement <TimerButtonElement> ("timer_button");
                e = t.Remaining;
                Debug.Log(t.Progress);
            }
            else
            {
                TimerElement t = GetScreenElement <TimerElement> ("timer");
                e = t.Remaining;
                Debug.Log(t.Progress);
            }

            Debug.Log("SyncElapsedTime: " + e);

            Game.Multiplayer.SyncDuration(e);
        }
Beispiel #28
0
 //生命周期结束
 private void LifeEnd(TimerElement element)
 {
     //回收Launcher对象。注:计时器对象不需要回收,当生命周期达到后,TimerMgr会自己回收
     PoolMgr.Inst.DespawnObj(this);
 }
Beispiel #29
0
 private void TimerElementRelease(TimerElement element)
 {
     element.OnDestroy();
     _elementPool.Push(element);
 }
Beispiel #30
0
		protected override void OnInitPlayerElements () {
			CreateRoleCard (true, true, true, false);

			timerElPlayer = new TimerElement (GetButton ("timer_button"), Duration, TimerType.Think);
			Elements.Add ("timer", timerElPlayer);
		}