public static void TriggerLinePlaced(GameStructs.LineID lineID)
 {
     if (LinePlaced != null)
     {
         LinePlaced(lineID);
     }
 }
        public void Initialize(Vector3 position, Vector2 size, Vector2 anchorMin, Vector2 anchorMax, GameStructs.LineID lineID, GameObject panel)
        {
            m_ClickableButton = gameObject.GetComponent <Button>();
            m_ClickableButton.onClick.AddListener(() => OnClick());
            m_ClickableButton.gameObject.transform.SetParent(panel.transform);

            m_PressedImage = gameObject.GetComponent <Image>();

            m_ClickableButton.GetComponent <RectTransform>().anchorMin = anchorMin;
            m_ClickableButton.GetComponent <RectTransform>().anchorMax = anchorMax;

            m_ClickableButton.GetComponent <RectTransform>().anchoredPosition = position;
            m_ClickableButton.GetComponent <RectTransform>().sizeDelta        = size;
            m_ClickableButton.GetComponent <RectTransform>().localScale       = new Vector3(1, 1, 1);

            m_lineID = lineID;

            if (m_lineID.rotation == GameEnums.ELineRotationCode.HORIZONTAL_ROTATION_CODE)
            {
                m_ClickableButton.GetComponent <RectTransform>().localRotation = Quaternion.Euler(0, 0, 0);
                m_ClickableButton.tag = GameConstants.TAG_HORIZONTAL;
            }
            else if (m_lineID.rotation == GameEnums.ELineRotationCode.VERTICAL_ROTATION_CODE)
            {
                m_ClickableButton.GetComponent <RectTransform>().localRotation = Quaternion.Euler(0, 0, 90);
                m_ClickableButton.tag = GameConstants.TAG_VERTICAL;
            }


            //debugText.text = m_lineID.ToString();
        }
        private void IncrementAffectedBoxScores(GameStructs.LineID lineID)
        {
            int        boxActivatedCounter  = 0;
            List <Box> freshlyAffectedBoxes = new List <Box>();

            switch (lineID.rotation)
            {
            case GameEnums.ELineRotationCode.HORIZONTAL_ROTATION_CODE:

                for (int i = 0; i < m_AffectedBoxesHorizontal[lineID].Length; i++)
                {
                    Box temp = m_ListOfBoxes[m_AffectedBoxesHorizontal[lineID][i]];
                    temp.AddScore();

                    if (temp.GetScore() == 4)
                    {
                        boxActivatedCounter++;
                    }

                    freshlyAffectedBoxes.Add(temp);
                }

                break;

            case GameEnums.ELineRotationCode.VERTICAL_ROTATION_CODE:

                for (int i = 0; i < m_AffectedBoxesVertical[lineID].Length; i++)
                {
                    Box temp = m_ListOfBoxes[m_AffectedBoxesVertical[lineID][i]];
                    temp.AddScore();

                    if (temp.GetScore() == 4)
                    {
                        boxActivatedCounter++;
                    }

                    freshlyAffectedBoxes.Add(temp);
                }

                break;
            }



            if (boxActivatedCounter >= 1)
            {
                GameEventManager.TriggerBoxScoredToFour();
            }
            else
            {
                GameEventManager.TriggerSwitchPlayers();
            }

            foreach (Box box in freshlyAffectedBoxes)
            {
                GameEventManager.TriggerBoxScoreValidForChain(box.GetBoxID());
            }
        }
        private void ArrangeLines()
        {
            int j = 0, k = 0;

            for (int i = 0; i < GetNoOfLines(NoOfRowsOrColumns) / 2; i++)
            {
                if (j < NoOfRowsOrColumns - 1)
                {
                    GameStructs.LineID lineID = new GameStructs.LineID {
                        ID = i, rotation = GameEnums.ELineRotationCode.HORIZONTAL_ROTATION_CODE
                    };

                    Line lineHorizontal = MonoObjectFactory <Line> .CreateInstance(new MonoObjectConstructMaterials()
                    {
                        prefab     = linePrefab,
                        parameters = new object[] { new Vector3((j + 0.5f) * (m_lineWidth + m_dotWidth), -k * (m_lineHeight + m_dotHeight), 1),
                                                    new Vector2(m_lineWidth, m_dotHeight),
                                                    new Vector2(((1 - BoardPercentage) / 2), ((1 + BoardPercentage) / 2)),
                                                    new Vector2(((1 - BoardPercentage) / 2), ((1 + BoardPercentage) / 2)),
                                                    lineID,
                                                    boardPanel }
                    });

                    m_ListOfLinesHorizontal.Add(lineID, lineHorizontal);

                    lineID.rotation = GameEnums.ELineRotationCode.VERTICAL_ROTATION_CODE;

                    Line lineVertical = MonoObjectFactory <Line> .CreateInstance(new MonoObjectConstructMaterials()
                    {
                        prefab     = linePrefab,
                        parameters = new object[] { new Vector3(k * (m_lineWidth + m_dotWidth), -(j + 0.5f) * (m_lineHeight + m_dotHeight), 1),
                                                    new Vector2(m_lineHeight, m_dotWidth),
                                                    new Vector2(((1 - BoardPercentage) / 2), ((1 + BoardPercentage) / 2)),
                                                    new Vector2(((1 - BoardPercentage) / 2), ((1 + BoardPercentage) / 2)),
                                                    lineID,
                                                    boardPanel }
                    });

                    m_ListOfLinesVertical.Add(lineID, lineVertical);


                    j++;
                    if (j == NoOfRowsOrColumns - 1)
                    {
                        j = 0;
                        k++;
                    }
                }
            }
        }
        private void GenerateAffectedBoxesData()
        {
            int row = 0, column = 0;

            for (int i = 0; i < m_ListOfLinesHorizontal.Count; i++)
            {
                GameStructs.LineID horizontalID = new GameStructs.LineID {
                    ID = i, rotation = GameEnums.ELineRotationCode.HORIZONTAL_ROTATION_CODE
                };
                GameStructs.LineID verticalID = new GameStructs.LineID {
                    ID = i, rotation = GameEnums.ELineRotationCode.VERTICAL_ROTATION_CODE
                };

                if (row == 0)
                {
                    m_AffectedBoxesHorizontal.Add(horizontalID, new int[] { i });
                    m_AffectedBoxesVertical.Add(verticalID, new int[] { row + (NoOfRowsOrColumns - 1) * column });
                }
                else if (row > 0 && row < NoOfRowsOrColumns - 1)
                {
                    m_AffectedBoxesHorizontal.Add(horizontalID, new int[] { i, i - (NoOfRowsOrColumns - 1) });
                    m_AffectedBoxesVertical.Add(verticalID, new int[] { row + ((NoOfRowsOrColumns - 1) * column) - 1, row + ((NoOfRowsOrColumns - 1) * column) });
                }
                else if (row == NoOfRowsOrColumns - 1)
                {
                    m_AffectedBoxesHorizontal.Add(horizontalID, new int[] { i - (NoOfRowsOrColumns - 1) });
                    m_AffectedBoxesVertical.Add(verticalID, new int[] { row + ((NoOfRowsOrColumns - 1) * column) - 1 });
                }

                column++;

                if (column >= NoOfRowsOrColumns - 1)
                {
                    column = 0;
                    row++;
                }
            }
        }
 private void LinePlacedDoStuff(GameStructs.LineID lineID)
 {
     LinePlacedDeactivateOldLine();
     IncrementAffectedBoxScores(lineID);
 }