예제 #1
0
    void Update()
    {
        //Debug.Log(Mathf.Sin(Time.time));
        float fixedSin = MathfUtil.Map(-1f, 1f, 0f, 1f, Mathf.Sin(Time.time * moveSpeed));

        transform.position = Vector3.Lerp(startingPos + transform.right * slideExtent, startingPos + transform.right * -1f * slideExtent, fixedSin);
    }
예제 #2
0
 private void HandleBar()
 {
     valueText.text     = "Health : " + Mathf.Clamp(player.playerStats.currentHealth, 0, player.playerStats.baseHealth);
     fillAmount         = Mathf.Lerp(content.fillAmount, MathfUtil.Map(player.playerStats.currentHealth, 0, player.playerStats.baseHealth, 0, 1), Time.deltaTime * lerpSpeed);
     content.fillAmount = fillAmount;
     content.color      = Color.Lerp(lowColor, fullColor, fillAmount);
 }
예제 #3
0
 private void HandleBar()
 {
     //if (currentEnemyFacingDirection != enemy.enemyMovementInfo.FacingDirection)
     //    Debug.Log("changednadhr");
     //GameObject canvas = transform.parent.gameObject;
     //canvas.GetComponent<RectTransform>().localScale = new Vector2 (Mathf.Abs(canvas.GetComponent<RectTransform>().localScale.x), canvas.GetComponent<RectTransform>().localScale.y) ;
     valueText.text     = Mathf.Clamp(enemy.enemyStats.currentHealth, 0, enemy.enemyStats.baseHealth).ToString();
     fillAmount         = Mathf.Lerp(content.fillAmount, MathfUtil.Map(enemy.enemyStats.currentHealth, 0, enemy.enemyStats.baseHealth, 0, 1), Time.deltaTime * lerpSpeed);
     content.fillAmount = fillAmount;
     content.color      = Color.Lerp(lowColor, fullColor, fillAmount);
 }
예제 #4
0
 private void Update()
 {
     if (Player.Instance != null && finishPoint != null && spawnPoint != null)
     {
         playerLevelProgress       = Mathf.Abs(Vector2.Distance(player.gameObject.transform.position, finishPoint.position)) - 2; //-1 for the win flag trigger size/2
         levelProgressSlider.value = Mathf.Lerp(levelProgressSlider.value, MathfUtil.Map(-playerLevelProgress, -initialDistance, 0, 0, 100), Time.deltaTime * lerpSpeed);
         //if ((-playerLevelProgress >= -initialDistance / 2) && !hasReachedHalfTheLevel)
         //{
         //    AdMobManager.Instance.ShowBanner();
         //    hasReachedHalfTheLevel = true;
         //}
     }
 }
예제 #5
0
 private void Start()
 {
     mainMenuInterstitialTimer = gameObject.AddComponent <Timer>();
     deckBannerTimer           = gameObject.AddComponent <Timer>();
     deckBannerTimer.m_Timer   = (int)Mathf.Floor(MathfUtil.MinutesToSeconds(deckCD + 1));
     if (Application.platform == RuntimePlatform.Android)
     {
         bannerView = new BannerView(bannerId, AdSize.Banner, AdPosition.TopRight);
     }
     else if (Application.platform == RuntimePlatform.IPhonePlayer)
     {
         bannerView = new BannerView(bannerId_IOS, AdSize.Banner, AdPosition.TopRight);
     }
     LoadInterstitial();
 }
예제 #6
0
    private void DOBezierCurve(Transform trans, Vector3[] points, float duration)
    {
        ulong n = (ulong)(points.Length - 1);
        float t = 0;

        poslist = new List <Vector3>();
        var handler = DOTween.To(() => t, dt =>
        {
            t = dt;
            trans.position = MathfUtil.BezierCurve(points, t);
            poslist.Add(trans.position);
        }, 1, duration);

        handler.SetEase(Ease.Linear);
    }
예제 #7
0
    public IEnumerator StartCountDown(float duration)
    {
        float timeLeft   = duration;
        float percentage = 100f;

        while (timeLeft > 0)
        {
            string temp = string.Format("{0:0.0}", timeLeft);
            countDownText.text  = temp;
            percentage          = MathfUtil.Map(timeLeft, 0, duration, 0, 1);
            countDownText.color = Color.Lerp(lowTextColor, fullTextColor, percentage);
            timeLeft           -= Time.deltaTime;
            yield return(new WaitForFixedUpdate());
        }
        Destroy(gameObject);
    }
예제 #8
0
        /// <summary>
        /// 对象做贝塞尔曲线运动
        /// </summary>
        /// <param name="trans"></param>
        /// <param name="points"></param>
        /// <param name="duration"></param>
        public static TweenerCore <float, float, FloatOptions> DOBezierCurve(this Transform trans, Vector3[] points, float duration, Action <float> cb = null)
        {
            ulong n       = (ulong)(points.Length - 1);
            float t       = 0;
            var   handler = DOTween.To(() => t, dt =>
            {
                t           = dt;
                Vector3 pos = MathfUtil.BezierCurve(points, t);
                var forward = (pos - trans.position).normalized;
                if (forward != Vector3.zero)
                {
                    trans.forward = forward;
                }
                trans.position = pos;
                cb?.Invoke(dt);
            }, 1, duration);

            handler.SetEase(Ease.Linear);
            return(handler);
        }
예제 #9
0
 private void Update()
 {
     t += Time.unscaledDeltaTime;
     if (t <= duration)
     {
         Vector3 pos     = MathfUtil.BezierCurve(points, t);
         var     forward = (pos - transform.position).normalized;
         if (forward != Vector3.zero)
         {
             transform.forward = forward;
         }
         transform.position = pos;
         points.Add(transform.position);
     }
     else
     {
         t = 0;
         points.Clear();
         CreateNewTween();
     }
 }
예제 #10
0
 private void HandleBar()
 {
     valueText.text     = Mathf.Clamp(enemy.enemyStats.currentHealth, 0, enemy.enemyStats.baseHealth) + " / " + enemy.enemyStats.baseHealth;
     fillAmount         = Mathf.Lerp(content.fillAmount, MathfUtil.Map(enemy.enemyStats.currentHealth, 0, enemy.enemyStats.baseHealth, 0, 1), Time.deltaTime * lerpSpeed);
     content.fillAmount = fillAmount;
 }
예제 #11
0
 public void HandleMainMenuInterstitial(string scene)
 {
     if (scene == "Main Menu")
     {
         HideBanner();
         if (mainMenuInterstitialTimer != null && mainMenuInterstitialTimer.m_Timer >= MathfUtil.MinutesToSeconds(mainMenuCD))
         {
             ShowInterstitial();
             mainMenuInterstitialTimer.ResetTimer(true);
         }
     }
 }
예제 #12
0
 public void HandleDeckBanner(string scene)
 {
     if ((scene == "DeckBuilder" || scene == "Cards shop") && deckBannerTimer.m_Timer >= MathfUtil.MinutesToSeconds(deckCD))
     {
         ShowBanner(AdPosition.TopRight);
         deckBannerTimer.ResetTimer(true);
     }
 }