Exemplo n.º 1
0
        /// <summary>
        /// 添加消除格的UI操作驱动
        /// </summary>
        /// <param name="grid"></param>
        private void AddGridOperateUI(ref ElimlnateGrid grid)
        {
            mOperateLayout = UI.GridOperateLayout;
            GameObject   prefab       = UnityEngine.Object.Instantiate(UI.OperateCellItemRenderer, mOperateLayout.transform);
            EventTrigger eventTrigger = prefab.GetComponent <EventTrigger>();

            //添加消除格UI驱动层的事件响应
            SetOperateEventTrigger(ref eventTrigger, EventTriggerType.PointerDown, OnGridPointerDown);
            SetOperateEventTrigger(ref eventTrigger, EventTriggerType.PointerUp, OnGridPointerUp);
            SetOperateEventTrigger(ref eventTrigger, EventTriggerType.PointerEnter, OnGridPointerEnter);
            SetOperateEventTrigger(ref eventTrigger, EventTriggerType.PointerClick, OnGridPointerClick);
            SetOperateEventTrigger(ref eventTrigger, EventTriggerType.PointerExit, OnGridPointerExit);

            Vector2Int pos   = grid.GridPos;
            int        index = ElimCore.BoardGrids.GetGridIndex(pos.y, pos.x);
            int        id    = prefab.GetInstanceID();

            mGridOperateMapper[id] = new GridOperateInfo()
            {
                gridPos   = grid.GridPos,
                prefabID  = id,
                prefab    = prefab,
                gridIndex = index,
                localPos  = (prefab.transform as RectTransform).position,
            };

            mGridsUIMapper[index] = id;
        }
Exemplo n.º 2
0
 /// <summary>
 /// 获取正在操作的消除格引用
 /// </summary>
 /// <param name="target"></param>
 private void GetGridPointerTarget(ref GameObject target)
 {
     mEliminateData.OperatingGrid = default;
     if (target != default)
     {
         int             id   = target != default ? target.GetInstanceID() : int.MaxValue;
         GridOperateInfo info = mGridOperateMapper[id];
         if (info != default)
         {
             Vector2Int pos = mGridOperateMapper[id].gridPos;
             mEliminateData.OperatingGrid = ElimCore.BoardGrids.GetGridByRowColumn(pos.x, pos.y);
         }
         else
         {
         }
     }
     else
     {
     }
 }