Beispiel #1
0
    public override void OnPointerExit(PointerEventData eventData)
    {
        base.OnPointerExit(eventData);

        if (m_isHighlighted)
        {
            if (m_infoPopup != null)
            {
                m_infoPopup.PopText();
                m_isHighlighted = false;
            }
        }
    }
Beispiel #2
0
    public virtual new void OnPointerUp(PointerEventData _eventData)
    {
        if (_eventData.button == PointerEventData.InputButton.Left)
        {
            if (!m_wireManager.IsInWireEditMode())
            {
                DoStateTransition(currentSelectionState, false);
                m_isBeingDragged = false;

                if (m_infoPopup != null && m_isHighlighted)
                {
                    m_isHighlighted = false;
                    m_infoPopup.PopText();
                }

                Vector2Int      oGrid          = Vector2Int.zero;
                CellCoordinates oldCoordinates = m_cellCoordinates;

                if (m_visualGridManager.GetGridCoordinates(m_rectTransform.anchoredPosition, ref oGrid, false) &&
                    m_visualGridManager.IsGridObjectValid(m_rectTransform.anchoredPosition, m_visualGate, false))
                {
                    CellCoordinates cell = new CellCoordinates((uint)oGrid.x, (uint)oGrid.y);
                    m_cellCoordinates = cell;

                    if (m_isPlaced)
                    {
                        if (m_cellCoordinates != oldCoordinates)
                        {
                            m_gameplayManager.ClearCell(oldCoordinates, true);
                        }
                    }

                    if (m_visualGate != null)
                    {
                        VisualGate visualGate = GetComponent <VisualGate>();
                        if (visualGate != null)
                        {
                            if (visualGate.gateType != GateType.IncrementDecrement)
                            {
                                m_gameplayManager.AddGate(visualGate.gateType, cell, visualGate.objectOrientation, gameObject, 0, m_isPlaced);
                            }
                            else
                            {
                                m_gameplayManager.AddGate(visualGate.gateType, cell, visualGate.objectOrientation, gameObject, visualGate.value, m_isPlaced);
                            }

                            if (!m_isPlaced)
                            {
                                GameObject copy = Instantiate(gameObject, m_gameplayManager.scrollViewParent);
                                copy.GetComponent <VisualBase>().ResetBase();
                                copy.GetComponent <RectTransform>().anchoredPosition = visualGate.GetSpawnLocation();
                            }
                        }
                    }

                    //If we were on a space clear it
                    if (m_isPlaced)
                    {
                        m_gameplayManager.UpdateGiblets(m_cellCoordinates, true);
                    }

                    m_isPlaced = true;
                }
                else
                {
                    if (!m_isPlaced)
                    {
                        if (m_visualGate != null)
                        {
                            GetComponent <RectTransform>().SetParent(m_gameplayManager.scrollViewParent);
                            GetComponent <RectTransform>().anchoredPosition = m_visualGate.GetSpawnLocation();
                            GetComponent <VisualBase>().ResetBase();
                        }
                    }
                    else
                    {
                        //If we have already been placed. Kill yourself
                        m_gameplayManager.ClearCell(oldCoordinates, true);
                        Destroy(gameObject);
                    }
                }
            }
        }
    }