| | |
| | | public class ReikiRootWin : Window
|
| | | {
|
| | | [SerializeField] List<PropertyBehaviour> m_Propertys;
|
| | | [SerializeField] ReikiRootPointBehaviour[] m_ReikiRootPoints;
|
| | | [SerializeField] List<ReikiRootPointBehaviour> m_ReikiRootPoints;
|
| | | [SerializeField] RectTransform m_Container;
|
| | | [SerializeField] NumKeyBoard m_NumKeyboard;
|
| | | [SerializeField] Text m_FreePoint;
|
| | | [SerializeField] Button m_Recommend;
|
| | | [SerializeField] Button m_Confirm;
|
| | |
| | |
|
| | | Dictionary<int, int> currentPropertyDict = new Dictionary<int, int>();
|
| | | Dictionary<int, int> upPropertyDict = new Dictionary<int, int>();
|
| | |
|
| | | int openKeyboardId = 0;
|
| | |
|
| | | bool propertyRefreshDirty = false;
|
| | |
|
| | | ReikiRootModel model { get { return ModelCenter.Instance.GetModel<ReikiRootModel>(); } }
|
| | |
|
| | |
| | | m_Recommend.AddListener(OnRecommend);
|
| | | m_Confirm.AddListener(Confirm);
|
| | | m_Close.AddListener(CloseClick);
|
| | |
|
| | | m_NumKeyboard.onValueChange.AddListener(OnPointValChange);
|
| | | m_NumKeyboard.onConfirm.AddListener((bool isOk) =>
|
| | | {
|
| | | if (isOk)
|
| | | {
|
| | | m_NumKeyboard.gameObject.SetActive(false);
|
| | | }
|
| | | });
|
| | | }
|
| | |
|
| | | protected override void OnPreOpen()
|
| | | {
|
| | | model.cacheFreePoint = model.freePoint;
|
| | | for (int i = 0; i < m_ReikiRootPoints.Length; i++)
|
| | | for (int i = 0; i < m_ReikiRootPoints.Count; i++)
|
| | | {
|
| | | if (i < model.reikiRoots.Count)
|
| | | {
|
| | | m_ReikiRootPoints[i].Display(model.reikiRoots[i]);
|
| | | m_ReikiRootPoints[i].Display(this, model.reikiRoots[i]);
|
| | | }
|
| | | }
|
| | |
|
| | | m_NumKeyboard.gameObject.SetActive(false);
|
| | |
|
| | | model.onCacheFreePointRefresh += OnCacheFreePointRefresh;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent += PlayerDataRefreshEvent;
|
| | | GlobalTimeEvent.Instance.secondEvent += PerSecond;
|
| | |
|
| | | Display();
|
| | | }
|
| | |
| | | {
|
| | | model.onCacheFreePointRefresh -= OnCacheFreePointRefresh;
|
| | | PlayerDatas.Instance.playerDataRefreshEvent -= PlayerDataRefreshEvent;
|
| | | for (int i = 0; i < m_ReikiRootPoints.Length; i++)
|
| | | GlobalTimeEvent.Instance.secondEvent -= PerSecond;
|
| | | for (int i = 0; i < m_ReikiRootPoints.Count; i++)
|
| | | {
|
| | | m_ReikiRootPoints[i].Dispose();
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | public void OpenKeyboard(ReikiRootPointBehaviour behaviour)
|
| | | {
|
| | | openKeyboardId = behaviour.id;
|
| | | m_NumKeyboard.gameObject.SetActive(true);
|
| | | m_NumKeyboard.max = (uint)model.cacheFreePoint + (uint)behaviour.point;
|
| | | m_NumKeyboard.min = 0;
|
| | | var trans = behaviour.openKeyboardBottom;
|
| | | var worldpos = trans.TransformPoint(new Vector3(0, -trans.rect.height / 2, 0));
|
| | | var localpos = m_Container.InverseTransformPoint(worldpos);
|
| | | m_NumKeyboard.transform.localPosition = localpos;
|
| | | }
|
| | |
|
| | | private void OnPointValChange()
|
| | | {
|
| | | var behaviour = m_ReikiRootPoints.Find((x) =>
|
| | | {
|
| | | return x.id == openKeyboardId;
|
| | | });
|
| | |
|
| | | var cache = behaviour.point;
|
| | |
|
| | | int num = int.Parse(m_NumKeyboard.Value);
|
| | | if (model.cacheFreePoint + cache - num < 0)
|
| | | {
|
| | | num = model.cacheFreePoint + cache;
|
| | | }
|
| | |
|
| | | behaviour.point = num;
|
| | | model.cacheFreePoint = model.cacheFreePoint - num + cache;
|
| | |
|
| | | m_NumKeyboard.Value = num.ToString();
|
| | | }
|
| | |
|
| | | private void OnRecommend()
|
| | | {
|
| | | var recommends = model.GetReikiRootRecommendPoint(model.freePoint);
|
| | |
| | | {
|
| | | if (model.freePoint != model.cacheFreePoint)
|
| | | {
|
| | | var ids = new byte[m_ReikiRootPoints.Length];
|
| | | var values = new ushort[m_ReikiRootPoints.Length];
|
| | | for (int i = 0; i < m_ReikiRootPoints.Length; i++)
|
| | | var ids = new byte[m_ReikiRootPoints.Count];
|
| | | var values = new ushort[m_ReikiRootPoints.Count];
|
| | | for (int i = 0; i < m_ReikiRootPoints.Count; i++)
|
| | | {
|
| | | ids[i] = (byte)m_ReikiRootPoints[i].id;
|
| | | values[i] = (ushort)m_ReikiRootPoints[i].point;
|
| | | }
|
| | | model.SendAddPoint(ids, values);
|
| | | }
|
| | | }
|
| | |
|
| | | private void PerSecond()
|
| | | {
|
| | | if (propertyRefreshDirty)
|
| | | {
|
| | | DisplayProperty();
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | {
|
| | | reikiRootPoint.point = 0;
|
| | | }
|
| | | if (model.cacheFreePoint == model.freePoint)
|
| | | {
|
| | | OnCacheFreePointRefresh();
|
| | | }
|
| | | model.cacheFreePoint = model.freePoint;
|
| | | }
|
| | | else
|
| | | {
|
| | | propertyRefreshDirty = true;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|