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.

72 lines
1.9 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using System;
namespace DisComputer
{
/// <summary>
/// 置顶箭头控制器
/// </summary>
public class TopProgressArrow : MonoBehaviour
{
//左起点 -470 右七点 470
//间距 100
//单位长度 135
[SerializeField]
private TopCenterItem left_top_item;
[SerializeField]
private TopCenterItem right_top_item;
// Start is called before the first frame update
void Start()
{
}
public void RewindTopArrow()
{
left_top_item.Reset();
right_top_item.Reset();
}
/// <summary>
/// 启动箭头动画
/// </summary>
/// <param name="reg_index">寄存单元下标</param>
/// <param name="end_index">指向终点单元下标</param>
/// <param name="dir_id">箭头方向 -1向左 1向右</param>
/// <param name="finish">完成事件</param>
public void PlayTopCenter(int reg_index, int end_index,int dir_id, Action finish = null)
{
left_top_item.Reset();
right_top_item.Reset();
float start_x = -570 * dir_id;
TopCenterItem centerItem = dir_id == 1 ? left_top_item : right_top_item;
int start_index = dir_id == 1 ? reg_index : 11 - end_index;
int offset = Mathf.Abs(end_index - reg_index) ;
int distance = 35 + 100 * offset;
start_x = start_x + (100 * dir_id) * start_index;
Debug.LogFormat("reg_index {0} end_index {1} dir_id {2} start_index {3} offset {4} distance {5} start_x {6}"
, reg_index, end_index, dir_id, start_index, offset, distance, start_x);
centerItem.Play(start_x, distance, finish);
}
}
}