You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
129 lines
2.7 KiB
129 lines
2.7 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using System;
|
|
|
|
namespace DisComputer
|
|
{
|
|
/// <summary>
|
|
/// 延申指向箭头
|
|
/// </summary>
|
|
public class ProgressArrow : MonoBehaviour
|
|
{
|
|
//箭头进度延申
|
|
private List<Image> arrowImgs;
|
|
|
|
[SerializeField]
|
|
private Color init_color = new Color(67.0f/255.0f,123.0f/255.0f,171.0f/255.0f,1);
|
|
|
|
[SerializeField]
|
|
private Color shake_color = new Color(245.0f/255.0f,244.0f/255.0f,38.0f/255.0f,1);
|
|
|
|
|
|
public bool isInitColor = true;
|
|
|
|
|
|
|
|
|
|
[Header("初始隐藏")]
|
|
public bool isInitHide = false;
|
|
|
|
private float speed = 1.2f;
|
|
|
|
private void Awake()
|
|
{
|
|
arrowImgs = new List<Image>(GetComponentsInChildren<Image>());
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
if(isInitHide)
|
|
SetArrowZero();
|
|
|
|
}
|
|
|
|
|
|
public void PlayArrow(bool isShake,Action finish=null)
|
|
{
|
|
SetArrowZero();
|
|
StartCoroutine(Play(isShake,finish));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnDisable()
|
|
{
|
|
SetArrowZero();
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 设置箭头归零
|
|
/// </summary>
|
|
public void SetArrowZero()
|
|
{
|
|
if ( arrowImgs == null||arrowImgs.Count < 0)
|
|
return;
|
|
foreach(var item in arrowImgs)
|
|
{
|
|
item.fillAmount = 0;
|
|
if(isInitColor)
|
|
item.color = init_color;
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置箭头归一
|
|
/// </summary>
|
|
void SetArrowOne()
|
|
{
|
|
if (arrowImgs == null || arrowImgs.Count < 0)
|
|
return;
|
|
|
|
foreach (var item in arrowImgs)
|
|
{
|
|
item.fillAmount = 1;
|
|
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 播放箭头动效
|
|
/// </summary>
|
|
IEnumerator Play(bool isShake,Action finish=null)
|
|
{
|
|
int i = 0;
|
|
float fillamount = .0f;
|
|
while (true)
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
|
|
Image image = arrowImgs[i];
|
|
if (isShake)
|
|
image.color = shake_color;
|
|
|
|
fillamount += Time.deltaTime * speed;
|
|
image.fillAmount = fillamount;
|
|
|
|
if (fillamount >= 1.0f)
|
|
{
|
|
i++;
|
|
fillamount = .0f;
|
|
}
|
|
|
|
if (i >= arrowImgs.Count)
|
|
break;
|
|
}
|
|
finish?.Invoke();
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|