private void HandleMouseUp(Vector2 pos, int dir)
        {
            if (b_IsInputActive && WindowManager.Instance.IsMainCanvasActive())
            {
                Vector2Int cellIndex = GetCellIndexFromScreenPos(pos);
                if (cellIndex == c_InvalidIndex)
                {
                    return;
                }                                            //exit if invalid position

                //if the click down is in the same cell as the click up
                if ((m_OnLeftMouseDownCellIndex == cellIndex && dir == CAMath.LEFT) ||
                    (m_OnRightMouseDownCellIndex == cellIndex && dir == CAMath.RIGHT))
                {
                    //get next/previous color int
                    int newColor = CAColor.ChangeColorInt(m_CellGrid.At(cellIndex), dir, b_includeClear: false);

                    //set int color id in data
                    m_CellGrid.SetColor(cellIndex, newColor);

                    SyncZoomTexture();
                }
                //otherwise nothing needs to be done,
            }
        }
Ejemplo n.º 2
0
        public int OnThenColorChange(RuleBehavior ruleBehavior, int direction)
        {
            int rbIndex = ruleBehavior.transform.GetSiblingIndex();

            //then color cannot be transparent
            SaveLoadManager.Instance.SetThenColor(rbIndex,
                                                  CAColor.ChangeColorInt(SaveLoadManager.Instance.CurrentRuleset[rbIndex].m_ThenColor, direction));
            return(SaveLoadManager.Instance.CurrentRuleset[rbIndex].m_ThenColor);
        }
Ejemplo n.º 3
0
        public int OnIfColorChange(RuleBehavior ruleBehavior, int direction)
        {
            int rbIndex = ruleBehavior.transform.GetSiblingIndex();

            //concerning cells of color 'any' is fine here
            SaveLoadManager.Instance.SetIfColor(rbIndex,
                                                CAColor.ChangeColorInt(SaveLoadManager.Instance.CurrentRuleset[rbIndex].m_IfColor, direction, b_includeClear: true));

            return(SaveLoadManager.Instance.CurrentRuleset[rbIndex].m_IfColor);
        }
        //1 = increase, -1 = decrease, 0 = unchanged
        public void ChangeClearToColor(int direction)
        {
            m_ClearToColor = CAColor.ChangeColorInt(m_ClearToColor, direction, true);

            //update rule button background
            m_ClearToColorButton.texture = m_ClearToColor == 0 ? WindowManager.Instance.m_AnyColorBgTex : null;
            m_ClearToColorButton.color   = m_ClearToColor == 0 ? Color.white : CAColor.colors[m_ClearToColor];

            m_ClearToColorButtonText.text = CAColor.GetColorText(m_ClearToColor);
        }
        private void HandleWhileLeftMouse(Vector2 pos)
        {
            if (b_IsInputActive && WindowManager.Instance.IsMainCanvasActive())
            {
                Vector2Int cellIndex = GetCellIndexFromScreenPos(pos);
                if (cellIndex == c_InvalidIndex)
                {
                    return;
                }                                            //exit if invalid position

                //if this cellindex is not the same as the down cellindex, draw
                if (cellIndex != m_OnLeftMouseDownCellIndex)
                {
                    //get next/previous color int
                    int newColor = CAColor.ChangeColorInt(m_CellGrid.At(m_OnLeftMouseDownCellIndex), 0, b_includeClear: false);

                    //set int color id in data
                    m_CellGrid.SetColor(cellIndex, newColor);

                    SyncZoomTexture();
                }
            }
        }