using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; namespace DisComputer { /// /// 置顶箭头控制器 /// 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(); } /// /// 启动箭头动画 /// /// 寄存单元下标 /// 指向终点单元下标 /// 箭头方向 -1向左 1向右 /// 完成事件 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); } } }