using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using System; namespace DisComputer { /// /// 置顶箭头控制器 /// public class TopProgressArrow : MonoBehaviour { //左起点 -570 右七点 570 //间距 100 //单位长度 135 [SerializeField] private TopCenterItem left_top_item; [SerializeField] private TopCenterItem right_top_item; //条件指令调整箭头 [SerializeField] private TopCenterItem jz_top_item; //无条件指令调整箭头 [SerializeField] private TopCenterItem jmp_top_item; // Start is called before the first frame update void Start() { } public void RewindTopArrow() { left_top_item.Reset(); right_top_item.Reset(); if(jz_top_item!=null) jz_top_item.Reset(); if(jmp_top_item!=null) jmp_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; if(reg_index == 0 && dir_id == 1) { start_x = -624; distance = distance + 55 ; } if(dir_id == -1) { distance = distance + 55; } if(dir_id == -1 && end_index == 10) { distance = distance - 55; } if(dir_id == -1 && end_index == 11) { start_x = 530; distance = distance - 100 + 5; } if(dir_id == 1 && end_index == 10) { distance = distance + 1; } if(dir_id ==1 && end_index == 11) { distance = distance - 35; } 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); } /// /// 播放指令跳转箭头 /// /// public void PlayCmdJmpTopCenter(Action finish = null) { if(VonNeumann.data.command == CommandType.Jmp) { jmp_top_item.Play(568.3f, finish); } else if(VonNeumann .data.command == CommandType.Jz) { jz_top_item.Play(921.33f, finish); } } } }