using asap.core; using cfg; using DG.Tweening; using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class BarRoot : MonoBehaviour { public Image bar_green; public Image mid; public Transform _highlight; public Image bar_lianji; public GameObject arrow_guidance; float barShakeAmp = 1; List posAmp = new List() { 0, 0 }; List posPeriod = new List() { 0, 0 }; List scaleAmp = new List() { 0, 0 }; List scalePeriod = new List() { 0, 0 }; private void InitAmpAndPeriod() { posAmp = new List() { 0, 0 }; posPeriod = new List() { 0, 0 }; scaleAmp = new List() { 0, 0 }; scalePeriod = new List() { 0, 0 }; } public void ShowTensionBar() { InitAmpAndPeriod(); arrow_guidance.gameObject.SetActive(false); bar_green.DOKill(); UpdateTensionBar(0.5f); bar_lianji.fillAmount = 0; } public void UpdateTensionBar(float power) { power = (power * 86 + 2f) / 90; bar_green.fillAmount = power; _highlight.localEulerAngles = new Vector3(0, 0, (1 - power) * 90f); } public void SetBarCombo(float fillAmount) { bar_lianji.fillAmount = 0.3f + (fillAmount * 0.7f); } public void BarComboBack(float time) { bar_lianji.DOFillAmount(0.3f, time - 0.001f); } public void SetTensionBarScale(float MaxZoneScale) { mid.fillAmount = MaxZoneScale; } public void PlayAni(string aniName, float barShakeAmp) { this.barShakeAmp = barShakeAmp; //ani.Play(aniName); RodShakeParam rodShakeParam = GContext.container.Resolve().TbRodShakeParam.GetOrDefault(aniName); if (rodShakeParam == null) { InitAmpAndPeriod(); } else { posAmp = rodShakeParam.PosAmp; posPeriod = rodShakeParam.PosPeriod; scaleAmp = rodShakeParam.ScaleAmp; scalePeriod = rodShakeParam.ScalePeriod; } } private void Update() { float x = 0; float y = 0; if (posAmp[0] > 0.0001f) { x = Mathf.Sin(Time.time * 2 * Mathf.PI / posPeriod[0]) * posAmp[0] * barShakeAmp; } if (posAmp[1] > 0.0001f) { y = Mathf.Sin(Time.time * 2 * Mathf.PI / posPeriod[1]) * posAmp[1] * barShakeAmp; } transform.localPosition = new Vector3(x, y, 0); float sx = 1; float sy = 1; if (scaleAmp[0] > 0.0001f) { sx += Mathf.Sin(Time.time * 2 * Mathf.PI / scalePeriod[0]) * (scaleAmp[0] - 1) * barShakeAmp; } if (scaleAmp[1] > 0.0001f) { sy += Mathf.Sin(Time.time * 2 * Mathf.PI / scalePeriod[1]) * (scaleAmp[1] - 1) * barShakeAmp; } transform.localScale = new Vector3(sx, sy, 1); } }