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); }
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); }
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); }
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; //} } }
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(); }
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); }
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); }
/// <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); }
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(); } }
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; }
public void HandleMainMenuInterstitial(string scene) { if (scene == "Main Menu") { HideBanner(); if (mainMenuInterstitialTimer != null && mainMenuInterstitialTimer.m_Timer >= MathfUtil.MinutesToSeconds(mainMenuCD)) { ShowInterstitial(); mainMenuInterstitialTimer.ResetTimer(true); } } }
public void HandleDeckBanner(string scene) { if ((scene == "DeckBuilder" || scene == "Cards shop") && deckBannerTimer.m_Timer >= MathfUtil.MinutesToSeconds(deckCD)) { ShowBanner(AdPosition.TopRight); deckBannerTimer.ResetTimer(true); } }