Ejemplo n.º 1
0
        private void AddBoxToChainAndTraverseForMore(int boxID, ref Chain fillChain, ref List <int> chainIDTracker)
        {
            if (boxID != GameConstants.INVALID_ID)
            {
                Box box = levelCreator.GetListOfBoxes()[boxID];

                if (box.GetScore() < 2 || box.GetScore() == 4 || fillChain.chainData.Contains(boxID))
                {
                    return;
                }

                GameStructs.NodeData          nodeData      = levelCreator.GetLevelNodeData()[boxID];
                GameStructs.NeighbouringBoxes neighbourData = levelCreator.GetNeighbouringBoxesList()[boxID];

                if (!fillChain.chainData.Contains(boxID))
                {
                    fillChain.chainData.Add(boxID);

                    if (box.HasChainID() && !chainIDTracker.Contains(box.GetChainID()))
                    {
                        chainIDTracker.Add(box.GetChainID());
                    }
                }

                if (levelCreator.GetHorizontalListOfLines()[nodeData.topLineID].IsLineOpen())
                {
                    AddBoxToChainAndTraverseForMore(neighbourData.topBoxID, ref fillChain, ref chainIDTracker);
                }

                if (levelCreator.GetVerticalListOfLines()[nodeData.rightLineID].IsLineOpen())
                {
                    AddBoxToChainAndTraverseForMore(neighbourData.rightBoxID, ref fillChain, ref chainIDTracker);
                }

                if (levelCreator.GetHorizontalListOfLines()[nodeData.bottomLineID].IsLineOpen())
                {
                    AddBoxToChainAndTraverseForMore(neighbourData.bottomBoxID, ref fillChain, ref chainIDTracker);
                }

                if (levelCreator.GetVerticalListOfLines()[nodeData.leftLineID].IsLineOpen())
                {
                    AddBoxToChainAndTraverseForMore(neighbourData.leftBoxID, ref fillChain, ref chainIDTracker);
                }
            }
        }
        //this should only be called once when this AI is initialized
        private void GatherAndGenerateRequiredData()
        {
            listOfBoxesOfScoreLessThan2.Clear();

            List <Box> boxesList = m_levelCreator.GetListOfBoxes();

            foreach (Box item in boxesList)
            {
                if (item.GetScore() < 2)
                {
                    listOfBoxesOfScoreLessThan2.Add(item.GetBoxID());
                }
            }

            Dictionary <int, GameStructs.NodeData> nodeData = m_levelCreator.GetLevelNodeData();

            foreach (var item in listOfBoxesOfScoreLessThan2)
            {
                relevantNodeData.Add(item, nodeData[item]);
            }
        }