bool IsCorrect()
        {
            List <PartModel> startParts = model.CurrentLvl().StartParts();

            foreach (PartModel startPart in startParts)
            {
                int newRow = startPart.row;
                int newCol = startPart.col;

                Direction dir = startPart.direction;

                while (true)
                {
                    newRow = DirectionPlusRow(dir, newRow);
                    newCol = DirectionPlusCol(dir, newCol);

                    RompecabezasSlot slot = tiles[TileNumber(newRow, newCol)].GetComponent <RompecabezasSlot>();

                    if (slot.IsEnd())
                    {
                        break;
                    }

                    Part currentPart = slot.GetCurrent();

                    if (currentPart == null)
                    {
                        return(false);
                    }

                    PartModel m = currentPart.Model();
                    if (m.isDouble)
                    {
                        if (!m.isCross)
                        {
                            dir = NotCrossDouble(dir, m.isLeftUp);
                        }
                    }
                    else
                    {
                        dir = GetNextDirection(m, dir);

                        if (dir == Direction.NULL)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
        Direction GetNextDirection(PartModel m, Direction dir)
        {
            //if(m.direction == m.previousDir && (m.direction == dir || m.direction == OppositeDir(dir))) return dir;

            if (m.previousDir == dir)
            {
                return(m.direction);
            }
            else if (OppositeDir(m.direction) == dir)
            {
                return(OppositeDir(m.previousDir));
            }
            else
            {
                return(Direction.NULL);
            }
        }
Exemplo n.º 3
0
        public void SetModel(PartModel partModel, List <Sprite> parts)
        {
            model = partModel;

            this.GetComponent <Image>().sprite = partModel.GetSprite(parts);
        }