Ejemplo n.º 1
0
        public void StartCountDown(PlayerManager killer, int time)
        {
            if (killer == null)
            {
                return;
            }

            stopDeathCamTime   = time - playerDeathCamTime;
            countDownText.text = time.ToString();

            GameObject deathCamObject    = playerDeathCam.gameObject;
            Transform  deathCamTransform = deathCamObject.transform;
            Transform  playerTransform   = playerManager.transform;

            deathCamTransform.position = playerTransform.position;
            deathCamTransform.rotation = playerTransform.rotation;
            deathCamObject.SetActive(true);

            killedByPanel.SetActive(true);
            if (killer == playerManager)
            {
                killedByText.text = yourselfText.Value;
                int messageIndex = Random.Range(0, killedYourSelfText.Length - 1);
                killedByHealthText.text = killedYourSelfText[messageIndex].Value;
            }
            else
            {
                killedByText.text       = killer.User.UserName;
                killedByHealthText.text = string.Format(hpLeftText.Value, killer.Health.ToString());
            }

            killedByProfileImage.texture = killer.User.UserProfilePicture;

            if (killer != playerManager)
            {
                playerDeathCam.StartTrackingPlayer(killer);
            }

            if (cancellationTokenSource != null)
            {
                cancellationTokenSource.Cancel();
                cancellationTokenSource.Dispose();
            }

            cancellationTokenSource = new CancellationTokenSource();

            TimeHelper.CountDown(time, OnCountdownTick, cancellationTokenSource.Token).ContinueWith(
                () =>
            {
                cancellationTokenSource.Dispose();
                cancellationTokenSource = null;
            });
        }
Ejemplo n.º 2
0
        public void CountDownTest()
        {
            const int time = 5;

            TimeHelper.CountDown(time, tick => Debug.Log($"Tick: {tick}"));
        }