using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; using UnityEngine.UI; namespace DisComputer { /// /// 面板指令控制器 /// public class CommandControl : MonoBehaviour { public GameObject buttonRootGo; public Button command_btn; //加载按钮 public Button load_btn; //加号 public Button add_btn; //减号 public Button sub_btn; //乘号 public Button mul_btn; //除号 public Button div_btn; //选项 public OptionsView optionsView; //指令集 public ProgressView progressView; //硬盘 public GameObject yingPanGo; // Start is called before the first frame update void Start() { command_btn.onClick.AddListener(OnClickCommand); add_btn.onClick.AddListener(OnClickAdd); sub_btn.onClick.AddListener(OnClickSub); mul_btn.onClick.AddListener(OnClickMul); div_btn.onClick.AddListener(OnClickDiv); load_btn.onClick.AddListener(OnClickLoadCommand); HideLoadCommandBtn(); } private bool isOnshow; public void OnClickCommand() { isOnshow = !isOnshow; if (isOnshow) { buttonRootGo.transform.DOLocalMoveX(0,0.58f); VonNeumann.data = new CommandData(); progressView.ClearItem(); HideLoadCommandBtn(); } else { buttonRootGo.transform.DOLocalMoveX(155, 0.58f); optionsView.OnHide(); } } public void OnHideButtonRoot() { buttonRootGo.transform.DOLocalMoveX(155, 0.58f); isOnshow = false; } /// /// 显示加载按钮 /// public void ShowLoadCommandBtn() { load_btn.gameObject.SetActive(true); } /// /// 隐藏加载按钮 /// public void HideLoadCommandBtn() { load_btn.gameObject.SetActive(false); } void OnClickAdd() { VonNeumann.data.command = CommandType.Add; optionsView.OnShow(); } void OnClickSub() { VonNeumann.data.command = CommandType.Sub; optionsView.OnShow(); } void OnClickDiv() { VonNeumann.data.command = CommandType.Div; optionsView.OnShow(); } void OnClickMul() { VonNeumann.data.command = CommandType.Mul; optionsView.OnShow(); } //点击加载指令 void OnClickLoadCommand() { HideLoadCommandBtn(); yingPanGo.transform.DOPunchScale(new Vector3(0.5f,.5f,.5f),0.5f,2,0.25f).OnComplete(()=> { VonNeumannControll.Instance.InitCommandMap(); }); } } }