示例#1
0
    public void OnEndDrag(PointerEventData eventData)
    {
        transform.position = new Vector3(transform.position.x, transform.position.y, originalPosition.z);

        foreach (var puzzle in gameManager.puzzleElement)
        {
            currentCell = puzzle.GetComponent <PuzzleCell>();

            if (Vector3.Distance(currentCell.originalPosition, transform.position) < 0.5f)
            {
                if (currentCell.cellVacant)
                {
                    transform.position     = currentCell.originalPosition;
                    currentCell.cellVacant = false;
                    returnCell             = puzzle.GetComponent <PuzzleCell>();
                    break;
                }
                else
                {
                    transform.position = startDragPos;

                    if (returnCell.originalPosition == transform.position)
                    {
                        returnCell.cellVacant = false;
                        break;
                    }
                }
            }
        }
    }
示例#2
0
    CellController _clickedCellController; // выделеная яечкйка
    void Start()
    {
        _puzzle = PuzzleGame.Instance.GetNewGame(1);

        for (int x = 0; x < 9; x++)
        {
            for (int y = 0; y < 9; y++)
            {
                PuzzleCell cell = _puzzle.GetCell(x, y);
                cell.OnCellOpen += OnCellOpened;
                var cellButton = GameObject.Find($"{x}_{y}");

                CellController controller = cellButton.GetComponent <CellController>();
                controller.Cell         = cell;
                controller.X            = x; //колонка
                controller.Y            = y; //строка
                controller.CellName     = cellButton.name;
                controller.CellClicked += OnCellClicked;
                _cells[x, y]            = controller;
                controller.DrawCell();
            }
        }

        //Find keypad buttons
        for (int i = 1; i < 10; i++)
        {
            var keyPadButton = GameObject.Find($"Num{i}").GetComponent <Button>();
            int number       = i;
            keyPadButton.onClick.AddListener(() => OnKeyPadButtonClicked(number));
        }
    }
示例#3
0
    public void OnItmClick(PuzzleCellBlock objBlock)
    {
        if (currentBlock != null)
        {
            Destroy(currentBlock.gameObject);
        }

        GameObject obj = Instantiate(objBlock.gameObject, Vector3.zero, Quaternion.identity) as GameObject;

        obj.transform.SetParent(transform);
        obj.transform.localPosition = Vector3.zero;
        obj.transform.localScale    = Vector3.one;
        PuzzleCellBlock pzCellBlock = obj.GetComponent <PuzzleCellBlock> ();

        foreach (Transform child in obj.transform)
        {
            PuzzleCell          puzzleCell = child.gameObject.GetComponent <PuzzleCell> ();
            PuzzleCell.CellType cellType   = objBlock.cells.Find(k => k.transform.name == child.name).type;
            pzCellBlock.cells.Add(new PuzzleCellBlock.PuzzleCellBlockType(cellType, child.GetComponent <RectTransform> ()));
        }
        CanvasGroup canvasGroup = obj.AddComponent <CanvasGroup> ();

        canvasGroup.interactable   = false;
        canvasGroup.blocksRaycasts = false;
        currentBlock = obj.GetComponent <RectTransform> ();
    }
        private void MarkCells(Map <PuzzleCell> map, List <V> points, PuzzleCell type)
        {
            var toAdd = points.ToList();

            if (toAdd.Any() && type == PuzzleCell.Inside)
            {
                map[toAdd[0]] = type;
                toAdd.RemoveAt(0);
            }

            while (toAdd.Any())
            {
                var pathBuilder = new PathBuilder(map, type);

                var best = 0;
                for (int i = 1; i < toAdd.Count; i++)
                {
                    if (pathBuilder.Distance(toAdd[i]) < pathBuilder.Distance(toAdd[best]))
                    {
                        best = i;
                    }
                }

                var to   = toAdd[best];
                var path = pathBuilder.GetPath(to);
                foreach (var x in path)
                {
                    map[x] = type;
                }

                toAdd.RemoveAt(best);
            }
        }
示例#5
0
    public void SwapCellValue(PuzzleCell cell)
    {
        if (m_CurrentCell == null)
        {
            m_CurrentCell = cell;
        }
        else
        {
            // if user clicked on a cell twice, doesn't need to proceed
            if (m_CurrentCell == cell)
            {
                m_CurrentCell = null;
                return;
            }

            string temp = m_CurrentCell.m_CellText.text;
            m_CurrentCell.m_CellText.text = cell.m_CellText.text;
            cell.m_CellText.text          = temp;

            Utilities.Swap(ref m_CurrentCell.m_CellNumber, ref cell.m_CellNumber);

            m_CurrentCell = null;

            UpdatePuzzle();
        }
    }
示例#6
0
    private void Start()
    {
        int childCount = transform.childCount;
        int index      = 0;

        for (int i = 0; i < Utilities.s_PuzzleDimension; i++)
        {
            for (int j = 0; j < Utilities.s_PuzzleDimension; j++)
            {
                // filling m_Puzzle cells information
                transform.GetChild(index).gameObject.AddComponent <PuzzleCell>();
                PuzzleCell cell = transform.GetChild(index).gameObject.GetComponent <PuzzleCell>();

                cell.m_Row    = i;
                cell.m_Column = j;

                if (index < Utilities.Pow(Utilities.s_PuzzleDimension, 2) - 1)
                {
                    cell.m_CellNumber    = index + 1;
                    cell.m_CellText.text = (index + 1).ToString();
                }
                else
                {
                    cell.m_CellNumber    = 0;
                    cell.m_CellText.text = "";
                }

                index++;
            }
        }

        UpdatePuzzle();
    }
示例#7
0
        public void StartConfig(string config)
        {
            switch (config)
            {
            case "Trial":                    //use the trial configuration
            {
                _puzzleLogic.Config_Trial(); //Call the trial configuration
                short cellNumber = 1;
                foreach (Button b in this.Children)
                {
                    PuzzleCell location = _puzzleLogic.FindCell(cellNumber++);
                    b.SetValue(Grid.ColumnProperty, location.Col);
                    b.SetValue(Grid.RowProperty, location.Row);
                }
            } break;

            case "ConfigA":              //use the trial configuration
            {
                _puzzleLogic.Config_A(); //Call the trial configuration
            } break;

            case "ConfigB":              //use the trial configuration
            {
                _puzzleLogic.Config_B(); //Call the trial configuration
            } break;
            }
        }
示例#8
0
 void Awake()
 {
     originalPosition = transform.position;
     gameManager      = Camera.main.GetComponent <GameManager>();
     currentCell      = this;
     returnCell       = this;
 }
示例#9
0
    public void StepBack(int move)
    {
        int qty = myCells.Length;

        if (onGoal && positionHistory[move] != this.transform.position)
        {
            onGoal = false;
            this.gameObject.SetActive(true);
        }
        if (horizontal && !onGoal)
        {
            firstCell = cellHistory[move];
            for (int i = 0; i < qty; i++)
            {
                if (i == 0)
                {
                    myCells[i] = firstCell;
                    myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
                    myCells[i].occupied = true;
                }
                else
                {
                    myCells[i] = firstCell.CheckRightAmmount(i);
                    myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
                    myCells[i].occupied = true;
                }
                if (i == (qty - 1))
                {
                    lastCell = myCells[i];
                }
            }
        }
        else if (vertical && !onGoal)
        {
            firstCell = cellHistory[move];
            for (int i = 0; i < qty; i++)
            {
                if (i == 0)
                {
                    myCells[i] = firstCell;
                    myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
                    myCells[i].occupied = true;
                }
                else
                {
                    myCells[i] = firstCell.CheckUpAmmount(i);
                    myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
                    myCells[i].occupied = true;
                }
                if (i == (qty - 1))
                {
                    lastCell = myCells[i];
                }
            }
        }
        nextPos = iniPos = currentPos = positionHistory[move];
        this.transform.position = positionHistory[move];
        movingToGoal            = false;
    }
示例#10
0
 // m_Puzzle will be set here
 public void UpdatePuzzle()
 {
     for (int i = 0; i < transform.childCount; i++)
     {
         PuzzleCell cell = transform.GetChild(i).gameObject.GetComponent <PuzzleCell>();
         m_Puzzle[cell.m_Row, cell.m_Column] = cell.m_CellNumber;
     }
 }
示例#11
0
 public void SetUpItem()
 {
     this.gameObject.SetActive(true);
     for (int i = 0; i < startCells.Length; i++)
     {
         myCells[i] = startCells[i];
     }
     if (horizontal)
     {
         float maxX = -1000;
         float minX = 1000;
         foreach (PuzzleCell cell in myCells)
         {
             if (cell.gameObject.transform.position.x > maxX)
             {
                 lastCell = cell;
                 maxX     = cell.gameObject.transform.position.x;
             }
             if (cell.gameObject.transform.position.x < minX)
             {
                 firstCell = cell;
                 minX      = cell.gameObject.transform.position.x;
             }
         }
     }
     else if (vertical)
     {
         float maxY = -1000;
         float minY = 1000;
         foreach (PuzzleCell cell in myCells)
         {
             if (cell.gameObject.transform.position.y > maxY)
             {
                 lastCell = cell;
                 maxY     = cell.gameObject.transform.position.y;
             }
             if (cell.gameObject.transform.position.y < minY)
             {
                 firstCell = cell;
                 minY      = cell.gameObject.transform.position.y;
             }
         }
     }
     this.transform.position = startPos;
     active       = true;
     onGoal       = false;
     movingToGoal = false;
     foreach (PuzzleCell cell in myCells)
     {
         cell.occupied = true;
         cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
     }
     maxX = iniMaxX = 4 - (myCells.Length * 0.5f);
     minX = iniMinX = (myCells.Length * 0.5f) - 4;
     maxY = iniMaxY = 3 - (myCells.Length * 0.5f);
     minY = iniMinY = (myCells.Length * 0.5f) - 3;
 }
 public void ResetItem()
 {
     currentCell = initialCell;
     currentCell.gameObject.GetComponent <HatShopCell>().myItem = this;
     this.transform.position = initialCell.transform.position;
     moving = false;
     timer  = 0;
     verify = false;
     CheckGoal();
 }
示例#13
0
        public void MixUpPuzzle()
        {
            _puzzleLogic.MixUpPuzzle();

            short cellNumber = 1;

            foreach (KinectTileButton b in this.Children)
            {
                PuzzleCell location = _puzzleLogic.FindCell(cellNumber++);
                b.SetValue(Grid.ColumnProperty, location.Col);
                b.SetValue(Grid.RowProperty, location.Row);
            }
        }
示例#14
0
        public void MixUpPuzzle()
        {                               //*** SCRAMBLE THE PUZZLE ***
            _puzzleLogic.MixUpPuzzle(); //Call MixUpPuzzle to shuffle and move the puzzles

            short cellNumber = 1;

            foreach (Button b in this.Children)
            {
                PuzzleCell location = _puzzleLogic.FindCell(cellNumber++);
                b.SetValue(Grid.ColumnProperty, location.Col);
                b.SetValue(Grid.RowProperty, location.Row);
            }
        }
示例#15
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && isStart)
     {
         if (setColor)
         {
             if (currentItem != null)
             {
                 // blockText = currentItem.letter.text;
                 currentItem.SetColor(currentColor, colors[currentColor]);
             }
             if (currentBlock != null && downItem != null)
             {
                 if (downItem.blockIndex != -1)
                 {
                     currentBlock.SetText(downItem.letter.text);
                     currentBlock.SetColor(downItem.blockIndex, colors[downItem.blockIndex]);
                     downItem = null;
                 }
             }
         }
         else
         {
             if (currentItem != null)
             {
                 currentItem.SetText(letter);
             }
         }
     }
     if (Input.GetMouseButtonDown(1))
     {
         if (setColor)
         {
             if (currentBlock != null)
             {
                 currentBlock.ClearColor();
             }
             if (currentItem != null)
             {
                 currentItem.ClearColor();
             }
         }
         else
         {
             if (currentItem != null)
             {
                 currentItem.SetText("");
             }
         }
     }
 }
示例#16
0
    void parseLevelFile()
    {
        StreamReader reader = File.OpenText(Application.dataPath + "/Data/1.txt");
        JSONObject   j      = new JSONObject(reader.ReadToEnd());
        JSONObject   target = j.GetField("game");

        foreach (JSONObject jsonObj in target.list)
        {
            GameObject obj = Instantiate(cellPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            obj.transform.SetParent(targetContainer);
            obj.transform.localScale = Vector3.one;
            RectTransform reTrans = obj.GetComponent <RectTransform> ();
            reTrans.anchoredPosition = new Vector2(jsonObj.GetField("x").f, jsonObj.GetField("y").f);
            reTrans.eulerAngles      = new Vector3(0f, 0f, jsonObj.GetField("rot").f);
            PuzzleCell pc = obj.GetComponent <PuzzleCell> ();
            pc.SetType((PuzzleCell.CellType)Enum.Parse(typeof(PuzzleCell.CellType), jsonObj.GetField("type").str));
            cells.Add(pc);
        }

        JSONObject objects = j.GetField("objects");

        foreach (JSONObject jsonObj in objects.list)
        {
            GameObject obj = Instantiate(cellBlockPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            obj.transform.SetParent(cellBlockContainer);
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = Vector3.zero;

            JSONObject tmp = jsonObj.GetField("obj");
            int        i   = 0;
            foreach (JSONObject jsonObjFigure in tmp.list)
            {
                GameObject obj1 = Instantiate(cellPrefab, Vector3.zero, Quaternion.identity) as GameObject;
                obj1.transform.SetParent(obj.transform);
                obj1.transform.localScale = Vector3.one;
                obj1.name = i.ToString();
                RectTransform rcTrans = obj1.GetComponent <RectTransform> ();
                rcTrans.anchoredPosition = new Vector2(jsonObjFigure.GetField("x").f, jsonObjFigure.GetField("y").f);
                rcTrans.eulerAngles      = new Vector3(0f, 0f, jsonObjFigure.GetField("rot").f);
                PuzzleCell pc = obj1.GetComponent <PuzzleCell> ();
                pc.img.color = cellColor;
                PuzzleCell.CellType t = (PuzzleCell.CellType)Enum.Parse(typeof(PuzzleCell.CellType), jsonObjFigure.GetField("type").str);
                pc.SetType(t);
                obj.GetComponent <PuzzleCellBlock> ().cells.Add(new PuzzleCellBlock.PuzzleCellBlockType(t, obj1.GetComponent <RectTransform> ()));
                pc.enabled = false;
                i++;
            }
        }
    }
示例#17
0
        // Assumed to be a valid move.
        private void MovePiece(KinectTileButton b, int row, int col)
        {
            PuzzleCell newPosition = _puzzleLogic.MovePiece(row, col);

            b.SetValue(Grid.ColumnProperty, newPosition.Col);
            b.SetValue(Grid.RowProperty, newPosition.Row);

            if (_puzzleLogic.CheckForWin())
            {
                if (PuzzleWon != null)
                {
                    PuzzleWon(this, EventArgs.Empty);
                }
            }
        }
示例#18
0
    //克隆方格
    private PuzzleCell CloneCell(int i, int j, int index)
    {
        PuzzleCell cell = Instantiate(wordCell, wordGroup);

        cell.name = "word" + i.ToString() + j.ToString();
        cell.GetComponent <RectTransform> ().anchoredPosition = new Vector2(cellOri.x + (min + 2) * j, cellOri.y - (min + 2) * i);
        cell.pos.x = i;
        cell.pos.y = j;
        cell.SetText("");
        cell.ClearColor();
        cell.SetSize(min);
        cell.transform.SetSiblingIndex(index);
        cell.gameObject.SetActive(true);

        return(cell);
    }
示例#19
0
        /// <summary>
        ///     Moves the piece
        /// </summary>
        /// <param name="row"></param>
        /// <param name="col"></param>
        /// <returns>The cell of the newly opened position</returns>
        public PuzzleCell MovePiece(int row, int col)
        {
            Debug.Assert(GetMoveStatus(row, col) != MoveStatus.BadMove);

            var cell = new PuzzleCell(_emptyRow, _emptyCol, EmptyCellId);

            var origCell = _cells[row, col];

            _cells[_emptyRow, _emptyCol] = origCell;
            _cells[row, col] = EmptyCellId;

            _emptyCol = col;
            _emptyRow = row;


            return cell;
        }
示例#20
0
    private void CalculateWord()
    {
        int index = 0;

        for (int i = 0; i < row; i++)
        {
            List <string> letters   = new List <string> ();
            List <string> hintInfo  = new List <string> ();
            List <int>    loadColor = new List <int> ();
            for (int j = 0; j < col; j++)
            {
                List <CellInfo> list = new List <CellInfo> ();
                CellInfo        info = new CellInfo();
                PuzzleCell      cell = wordGroup.GetChild(index).GetComponent <PuzzleCell> ();
                letters.Add(cell.letter.text);
                hintInfo.Add(hintGroup.GetChild(index).GetComponent <InputField>().text);
                //loadData相关

                loadColor.Add(cell.blockIndex);
                //end

                if (cell.blockIndex != -1 && !string.IsNullOrEmpty(cell.letter.text))
                {
                    info.pos    = cell.pos;
                    info.letter = cell.letter.text;
                    if (wordPosDic.ContainsKey(cell.blockIndex))
                    {
                        list = wordPosDic[cell.blockIndex];
                        list.Add(info);
                        wordPosDic[cell.blockIndex] = list;
                    }
                    else
                    {
                        list.Add(info);
                        wordPosDic.Add(cell.blockIndex, list);
                    }
                }
                index++;
            }
            data.wordInfo.Add(letters);
            data.hintInfo.Add(hintInfo);
            loadData.wordInfo.Add(letters);
            loadData.hintInfo.Add(hintInfo);
            loadData.wordColorIndex.Add(loadColor);
        }
    }
示例#21
0
    public void OnTargetClick()
    {
        if (currentBlock == null)
        {
            return;
        }
        PuzzleCellBlock   block         = currentBlock.GetComponent <PuzzleCellBlock> ();
        List <PuzzleCell> cellsOnTarget = new List <PuzzleCell> ();

        foreach (PuzzleCellBlock.PuzzleCellBlockType bCell in block.cells)
        {
            float      dist       = Mathf.Infinity;
            PuzzleCell findedCell = null;
            foreach (PuzzleCell puzzleCell in cells)
            {
                if (cellsOnTarget.Contains(puzzleCell))
                {
                    continue;
                }
                float val = Vector2.Distance(bCell.transform.position, puzzleCell.rectTransform.position);
                if (val < dist)
                {
                    dist       = val;
                    findedCell = puzzleCell;
                }
            }

            if (findedCell != null && findedCell.typeCell == bCell.type && findedCell.IsActive &&
                allowInsert(findedCell.rectTransform.eulerAngles.z, bCell.transform.eulerAngles.z, reverseTypes [findedCell.typeCell]))
            {
                cellsOnTarget.Add(findedCell);
            }
            else
            {
                Debug.Log("Inappropriate block");
                return;
            }
        }

        for (int i = 0; i < cellsOnTarget.Count; i++)
        {
            cellsOnTarget [i].GetComponent <Image> ().color = cellColor;
            cellsOnTarget [i].IsActive = false;
        }
        Destroy(currentBlock.gameObject);
    }
 void Update()
 {
     if (moving)
     {
         myLevel.movingItem = true;
         timer += Time.deltaTime / moveDur;
         this.transform.position = Vector3.Lerp(currentCell.transform.position, nextCell.transform.position, timer);
         if (timer >= 1)
         {
             timer       = 0f;
             currentCell = nextCell;
             moving      = false;
             currentCell.gameObject.GetComponent <HatShopCell>().myItem = this;
             verify = true;
             CheckGoal();
         }
     }
 }
示例#23
0
 private void Awake()
 {
     instance       = this;
     levelText.text = string.Format(levelText.text, "Puzzle");
     cellOri        = wordCell.GetComponent <RectTransform> ().anchoredPosition;
     min            = wordCell.GetComponent <RectTransform> ().sizeDelta.x;
     blockOri       = block.GetComponent <RectTransform> ().anchoredPosition;
     InitColor();
     SetColor();
     saveBtn.onClick.AddListener(() => {
         Save();
         modifierWord.gameObject.SetActive(false);
         startSetBlock.gameObject.SetActive(false);
     });
     modifierWord.onClick.AddListener(() => {
         currentBlock = null;
         currentItem  = null;
         downItem     = null;
         //blockText = "";
         blockGroup.gameObject.SetActive(false);
         wordGroup.gameObject.SetActive(true);
         opGroup.SetActive(true);
         letterGroup.SetActive(true);
         colorGroup.SetActive(false);
         modifierWord.gameObject.SetActive(false);
         startSetBlock.gameObject.SetActive(true);
         saveBtn.gameObject.SetActive(false);
         setColor = false;
     });
     startSetBlock.onClick.AddListener(() => {
         modifierWord.gameObject.SetActive(true);
         blockGroup.gameObject.SetActive(true);
         SetHintCell();
         SetBlockGrid();
         setColor = true;
         opGroup.SetActive(false);
         letterGroup.SetActive(false);
         colorGroup.SetActive(true);
         currentItem = null;
         letter      = "";
         startSetBlock.gameObject.SetActive(false);
         saveBtn.gameObject.SetActive(true);
     });
 }
            public PathBuilder(Map <PuzzleCell> map, PuzzleCell type)
            {
                this.map = map;
                var queue = new LinkedList <V>();

                for (int x = -1; x <= map.SizeX; x++)
                {
                    for (int y = -1; y <= map.SizeY; y++)
                    {
                        var v = new V(x, y);
                        if (type == PuzzleCell.Inside && v.Inside(map) && map[v] == type ||
                            type == PuzzleCell.Outside && (!v.Inside(map) || map[v] == type))
                        {
                            queue.AddLast(v);
                        }
                    }
                }

                distance = new Map <int>(map.SizeX, map.SizeY);
                parent   = new Map <V>(map.SizeX, map.SizeY);

                while (queue.Any())
                {
                    var v = queue.First();
                    queue.RemoveFirst();

                    for (var direction = 0; direction < 4; direction++)
                    {
                        var u = v.Shift(direction);
                        if (!u.Inside(map) || parent[u] != null || map[u] != PuzzleCell.Unknown)
                        {
                            continue;
                        }

                        parent[u]   = v;
                        distance[u] = (v.Inside(map) ? distance[v] : 0) + 1;
                        queue.AddLast(u);
                    }
                }
            }
示例#25
0
    //设置单词格子
    private void SetWordGrid()
    {
        Calculate();
        int index = 0;

        for (int i = 0; i < row; i++)
        {
            for (int j = 0; j < col; j++)
            {
                if (i == 0 && j == 0)
                {
                    wordCell.ClearColor();
                    wordCell.pos.x = i;
                    wordCell.pos.y = j;
                    wordCell.gameObject.SetActive(true);
                    wordCell.SetSize(min);
                    if (loadData.wordInfo.Count != 0 && loadData.wordColorIndex[i][j] != -1)
                    {
                        wordCell.SetText(loadData.wordInfo[i][j]);
                        wordCell.SetColor(loadData.wordColorIndex[i][j], colors[loadData.wordColorIndex[i][j]]);
                    }
                }
                else
                {
                    PuzzleCell cell = CloneCell(i, j, index);

                    if (loadData.wordInfo.Count != 0 && loadData.wordColorIndex[i][j] != -1)
                    {
                        cell.SetText(loadData.wordInfo[i][j]);
                        cell.SetColor(loadData.wordColorIndex[i][j], colors[loadData.wordColorIndex[i][j]]);
                    }
                }
                index++;
            }
        }
        isStart = true;
    }
示例#26
0
        private void MovePiece(GazeAgumentedButton b, int row, int col)
        {         //*** MOVE THE TILE, ASSUMING THE MOVE IS VALID***
            //Identify the cell to move

            PuzzleCell newPosition = _puzzleLogic.MovePiece(row, col);

            try
            {
                //change the position of the tile in the grid
                b.SetValue(Grid.ColumnProperty, newPosition.Col);
                b.SetValue(Grid.RowProperty, newPosition.Row);

                //increment moves by 1
                _moves++;

                //Once the piece has been moved, then allow the next piece to be moved
                _isProcessingButton = false;
                //this.IsEnabled = true;//enable the grid
            }
            catch (Exception ex)
            {
                MessageBox.Show("Movement error !!!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#27
0
    public bool CheckOnClimax(PuzzleCell cell)
    {
        int count = 0;

        foreach (PuzzleCell.PlantType p in cell.plantsToGrow)
        {
            Debug.Log("Iterou");
            if (cell.progressToWin.Contains(p))
            {
                Debug.Log("Count++");
                count++;
            }
        }

        if (count >= cell.plantsToGrow.Count)
        {
            Debug.Log("Alcançou");
            return(true);
        }
        else
        {
            return(false);
        }
    }
示例#28
0
    public void MoveVertical(float curPos, float prevPos)
    {
        if (lastCell.CheckUp().goalCell)
        {
            maxY = iniMaxY + cellDistance;
        }
        else
        {
            maxY = iniMaxY;
        }
        if (firstCell.CheckDown().goalCell)
        {
            minY = iniMinY - cellDistance;
        }
        else
        {
            minY = iniMinY;
        }

        if (!selected)
        {
            iniPos   = this.gameObject.transform.position;
            selected = true;
            nextPos  = iniPos;
        }
        float Diff = Mathf.Abs(curPos - prevPos);

        if (Diff > maxDiff)
        {
            Diff = maxDiff;
        }
        if (curPos > prevPos)
        {
            //moving UP
            nextPos.y    += Diff;
            pushingPos.y += Diff;
            if (nextPos.y > iniPos.y)
            {
                //Is moving UP from the starting point
                if (!directionController)
                {
                    directionController = true;
                    SetPushedBaguette();
                    pushing = false;
                    if (movingToGoal)
                    {
                        movingToGoal = false;
                    }
                }
                if (!lastCell.edgeUp)
                {
                    //no board edge up
                    if (!lastCell.cellUp.occupied)
                    {
                        //no baguette in the next up cell
                        canMove = true;
                        if (lastCell.cellUp.goalCell)
                        {
                            //code for checking goal
                            if (lastCell.cellUp.gameObject.GetComponent <BakeryGoalCell>().myColor.ToString() == myColor.ToString())
                            {
                                canMove      = true;
                                movingToGoal = true;
                            }
                            else
                            {
                                canMove = false;
                            }
                        }
                    }
                    else
                    {
                        if (!baguetteToPush)
                        {
                            baguetteToPush = lastCell.cellUp.gameObject.GetComponent <BakeryCellConn>().mybaguette;
                            BTPcurrentPos  = baguetteToPush.transform.position;
                            float adjustedY = nextPos.y + ((myCells.Length * 0.5f) + 0.5f);
                            baguetteToPush.transform.position = new Vector3(baguetteToPush.transform.position.x, adjustedY, baguetteToPush.transform.position.z);
                            pushingPos = baguetteToPush.transform.position;
                        }
                        if (baguetteToPush.CheckAllUp())
                        {
                            //can push UP
                            pushing = true;
                            canMove = true;
                        }
                        else
                        {
                            // cant push UP
                            SetPushedBaguette();
                            baguetteToPush = null;
                            canMove        = false;
                            maxY           = iniPos.y;
                            this.gameObject.transform.position = iniPos;
                        }
                    }
                }
                else
                {
                    canMove = false;
                    maxY    = iniPos.y;
                    this.gameObject.transform.position = iniPos;
                }
            }
            else if (nextPos.y > this.gameObject.transform.position.y)
            {
                //Is moving UP towards the starting point
                canMove = true;
            }
            if (Mathf.Abs(nextPos.y - iniPos.y) >= minDistance && canMove)
            {
                List <PuzzleCell> tempCells = new List <PuzzleCell>();
                if (baguetteToPush)
                {
                    foreach (PuzzleCell cell in baguetteToPush.myCells)
                    {
                        tempCells.Add(cell.CheckUpAmmount(1));
                        cell.occupied = false;
                        cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                    }
                    for (int i = 0; i < tempCells.Count; i++)
                    {
                        //occupie (hmmm pie I want pie, give me pie X if you are reading this, I know is written occupy but whatever) new baguette cells and assign baguette
                        baguetteToPush.myCells[i]          = tempCells[i];
                        baguetteToPush.myCells[i].occupied = true;
                        baguetteToPush.myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = baguetteToPush;
                    }
                    baguetteToPush.firstCell = baguetteToPush.firstCell.CheckUpAmmount(1);
                    baguetteToPush.lastCell  = baguetteToPush.lastCell.CheckUpAmmount(1);
                    tempCells.Clear();
                    BTPcurrentPos.y          += cellDistance;
                    baguetteToPush.iniPos     = BTPcurrentPos;
                    baguetteToPush.currentPos = BTPcurrentPos;
                }

                foreach (PuzzleCell cell in myCells)
                {
                    //free current baguette cells and get new cells
                    tempCells.Add(cell.CheckUpAmmount(1));
                    cell.occupied = false;
                    cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                }
                for (int i = 0; i < tempCells.Count; i++)
                {
                    //occupie (hmmm pie I want pie, give me pie X if you are reading this, I know is written occupy but whatever) new baguette cells and assign baguette
                    myCells[i]          = tempCells[i];
                    myCells[i].occupied = true;
                    myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
                }
                //update edge cells
                firstCell = firstCell.CheckUpAmmount(1);
                lastCell  = lastCell.CheckUpAmmount(1);
                tempCells.Clear();
                currentPos.y += cellDistance;
                iniPos        = currentPos;
                if (movingToGoal)
                {
                    foreach (PuzzleCell cell in myCells)
                    {
                        //free current baguette cells and get new cells
                        cell.occupied = false;
                        cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                        onGoal = true;
                        this.gameObject.SetActive(false);
                        canMove = false;
                    }
                }
            }
        }
        else
        {
            //moving DOWN
            nextPos.y    -= Diff;
            pushingPos.y -= Diff;
            if (nextPos.y < iniPos.y)
            {
                //Is moving DOWN from the starting point
                if (directionController)
                {
                    directionController = false;
                    SetPushedBaguette();
                    pushing = false;
                    if (movingToGoal)
                    {
                        movingToGoal = false;
                    }
                }
                if (!firstCell.edgeDown)
                {
                    if (!firstCell.cellDown.occupied)
                    {
                        //no baguette in the next down cell
                        canMove = true;
                        if (firstCell.cellDown.goalCell)
                        {
                            //code for checking goal
                            if (firstCell.cellDown.gameObject.GetComponent <BakeryGoalCell>().myColor.ToString() == myColor.ToString())
                            {
                                canMove      = true;
                                movingToGoal = true;
                            }
                            else
                            {
                                canMove = false;
                            }
                        }
                    }
                    else
                    {
                        if (!baguetteToPush)
                        {
                            baguetteToPush = firstCell.cellDown.gameObject.GetComponent <BakeryCellConn>().mybaguette;
                            //baguetteToPush.transform.position = new Vector3(baguetteToPush.transform.position.x,(baguetteToPush.transform.position.y - (this.transform.position.y - iniPos.y)),baguetteToPush.transform.position.z);
                            BTPcurrentPos = baguetteToPush.transform.position;
                            float adjustedY = nextPos.y - ((myCells.Length * 0.5f) + 0.5f);
                            baguetteToPush.transform.position = new Vector3(baguetteToPush.transform.position.x, adjustedY, baguetteToPush.transform.position.z);
                            pushingPos = baguetteToPush.transform.position;
                            //pushingPos.y += (this.transform.position.y - iniPos.y);
                        }
                        if (baguetteToPush.CheckAllDown())
                        {
                            //can push down
                            pushing = true;
                            canMove = true;
                        }
                        else
                        {
                            // cant push down
                            SetPushedBaguette();
                            baguetteToPush = null;
                            minY           = iniPos.y;
                            canMove        = false;
                            this.gameObject.transform.position = iniPos;
                        }
                    }
                }
                else
                {
                    canMove = false;
                    minY    = iniPos.y;
                    this.gameObject.transform.position = iniPos;
                }
            }
            else if (nextPos.y < this.gameObject.transform.position.y)
            {
                //Is moving DOWN towards the starting point
                canMove = true;
            }
            if (Mathf.Abs(nextPos.y - iniPos.y) >= minDistance && canMove)
            {
                List <PuzzleCell> tempCells = new List <PuzzleCell>();
                if (baguetteToPush)
                {
                    foreach (PuzzleCell cell in baguetteToPush.myCells)
                    {
                        tempCells.Add(cell.CheckDownAmmount(1));
                        cell.occupied = false;
                        cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                    }
                    for (int i = 0; i < tempCells.Count; i++)
                    {
                        //occupie (hmmm pie I want pie, give me pie X if you are reading this, I know is written occupy but whatever) new baguette cells and assign baguette
                        baguetteToPush.myCells[i]          = tempCells[i];
                        baguetteToPush.myCells[i].occupied = true;
                        baguetteToPush.myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = baguetteToPush;
                    }
                    baguetteToPush.firstCell = baguetteToPush.firstCell.CheckDownAmmount(1);
                    baguetteToPush.lastCell  = baguetteToPush.lastCell.CheckDownAmmount(1);
                    tempCells.Clear();
                    BTPcurrentPos.y          -= cellDistance;
                    baguetteToPush.iniPos     = BTPcurrentPos;
                    baguetteToPush.currentPos = BTPcurrentPos;
                }

                foreach (PuzzleCell cell in myCells)
                {
                    //free current baguette cells and get new cells
                    tempCells.Add(cell.CheckDownAmmount(1));
                    cell.occupied = false;
                    cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                }
                for (int i = 0; i < tempCells.Count; i++)
                {
                    //occupie (hmmm pie I want pie, give me pie X if you are reading this, I know is written occupy but whatever) new baguette cells and assign baguette
                    myCells[i]          = tempCells[i];
                    myCells[i].occupied = true;
                    myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
                }
                //update edge cells
                firstCell = firstCell.CheckDownAmmount(1);
                lastCell  = lastCell.CheckDownAmmount(1);
                tempCells.Clear();
                currentPos.y -= cellDistance;
                iniPos        = currentPos;
                if (movingToGoal)
                {
                    foreach (PuzzleCell cell in myCells)
                    {
                        //free current baguette cells and get new cells
                        cell.occupied = false;
                        cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                        onGoal = true;
                        this.gameObject.SetActive(false);
                        canMove = false;
                    }
                }
            }
        }

        if (canMove)
        {
            if (nextPos.y > maxY)
            {
                nextPos.y = maxY;
            }
            if (nextPos.y < minY)
            {
                nextPos.y = minY;
            }
            this.gameObject.transform.position = nextPos;
            if (baguetteToPush)
            {
                baguetteToPush.gameObject.transform.position = pushingPos;
            }
        }
    }
示例#29
0
    public void MoveHorizontal(float curPos, float prevPos)
    {
        if (lastCell.CheckRight().goalCell)
        {
            maxX = iniMaxX + cellDistance;
        }
        else
        {
            maxX = iniMaxX;
        }
        if (firstCell.CheckLeft().goalCell)
        {
            minX = iniMinX - cellDistance;
        }
        else
        {
            minX = iniMinX;
        }
        if (!selected)
        {
            iniPos   = this.gameObject.transform.position;
            selected = true;
            nextPos  = iniPos;
        }
        float Diff = Mathf.Abs(curPos - prevPos);

        if (Diff > maxDiff)
        {
            Diff = maxDiff;
        }
        if (curPos > prevPos)
        {
            //moving right
            nextPos.x    += Diff;
            pushingPos.x += Diff;
            if (nextPos.x > iniPos.x)
            {
                //Is moving right from the starting point
                if (!directionController)
                {
                    directionController = true;
                    SetPushedBaguette();
                    pushing = false;
                    if (movingToGoal)
                    {
                        movingToGoal = false;
                    }
                }
                if (!lastCell.edgeRight)
                {
                    //no board edge right
                    if (!lastCell.cellRight.occupied)
                    {
                        //no baguette in the next right cell
                        canMove = true;
                        if (lastCell.cellRight.goalCell)
                        {
                            //code for checking goal
                            if (lastCell.cellRight.gameObject.GetComponent <BakeryGoalCell>().myColor.ToString() == myColor.ToString())
                            {
                                canMove      = true;
                                movingToGoal = true;
                            }
                            else
                            {
                                canMove = false;
                            }
                        }
                    }
                    else
                    {
                        if (!baguetteToPush)
                        {
                            baguetteToPush = lastCell.cellRight.gameObject.GetComponent <BakeryCellConn>().mybaguette;
                            BTPcurrentPos  = baguetteToPush.transform.position;
                            float adjustedX = nextPos.x + ((myCells.Length * 0.5f) + 0.5f);
                            baguetteToPush.transform.position = new Vector3(adjustedX, baguetteToPush.transform.position.y, baguetteToPush.transform.position.z);
                            pushingPos = baguetteToPush.transform.position;
                        }
                        if (baguetteToPush.CheckAllRight())
                        {
                            //can push right
                            pushing = true;
                            canMove = true;
                        }
                        else
                        {
                            // cant push right
                            SetPushedBaguette();
                            baguetteToPush = null;
                            maxX           = iniPos.x;
                            canMove        = false;
                            this.gameObject.transform.position = iniPos;
                        }
                    }
                }
                else
                {
                    maxX    = iniPos.x;
                    canMove = false;
                    this.gameObject.transform.position = iniPos;
                }
            }
            else if (nextPos.x > this.gameObject.transform.position.x)
            {
                //Is moving right towards the starting point
                canMove = true;
            }
            if (Mathf.Abs(nextPos.x - iniPos.x) >= minDistance && canMove)
            {
                List <PuzzleCell> tempCells = new List <PuzzleCell>();
                if (baguetteToPush)
                {
                    foreach (PuzzleCell cell in baguetteToPush.myCells)
                    {
                        tempCells.Add(cell.CheckRightAmmount(1));
                        cell.occupied = false;
                        cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                    }
                    for (int i = 0; i < tempCells.Count; i++)
                    {
                        //occupie (hmmm pie I want pie, give me pie X if you are reading this, I know is written occupy but whatever) new baguette cells and assign baguette
                        baguetteToPush.myCells[i]          = tempCells[i];
                        baguetteToPush.myCells[i].occupied = true;
                        baguetteToPush.myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = baguetteToPush;
                    }
                    baguetteToPush.firstCell = baguetteToPush.firstCell.CheckRightAmmount(1);
                    baguetteToPush.lastCell  = baguetteToPush.lastCell.CheckRightAmmount(1);
                    tempCells.Clear();
                    BTPcurrentPos.x          += cellDistance;
                    baguetteToPush.iniPos     = BTPcurrentPos;
                    baguetteToPush.currentPos = BTPcurrentPos;
                }

                foreach (PuzzleCell cell in myCells)
                {
                    //free current baguette cells and get new cells
                    tempCells.Add(cell.CheckRightAmmount(1));
                    cell.occupied = false;
                    cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                }
                for (int i = 0; i < tempCells.Count; i++)
                {
                    //occupie (hmmm pie I want pie, give me pie X if you are reading this, I know is written occupy but whatever) new baguette cells and assign baguette
                    myCells[i]          = tempCells[i];
                    myCells[i].occupied = true;
                    myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
                }
                //update edge cells
                firstCell = firstCell.CheckRightAmmount(1);
                lastCell  = lastCell.CheckRightAmmount(1);
                tempCells.Clear();
                currentPos.x += cellDistance;
                iniPos        = currentPos;
                if (movingToGoal)
                {
                    foreach (PuzzleCell cell in myCells)
                    {
                        //free current baguette cells and get new cells
                        cell.occupied = false;
                        cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                        onGoal = true;
                        this.gameObject.SetActive(false);
                        canMove = false;
                    }
                }
            }
        }
        else
        {
            //moving left
            nextPos.x    -= Diff;
            pushingPos.x -= Diff;
            if (nextPos.x < iniPos.x)
            {
                //Is moving left from the starting point
                if (directionController)
                {
                    directionController = false;
                    SetPushedBaguette();
                    pushing = false;
                    if (movingToGoal)
                    {
                        movingToGoal = false;
                    }
                }
                if (!firstCell.edgeLeft)
                {
                    //no board edge up
                    if (!firstCell.cellLeft.occupied)
                    {
                        //no baguette in the next up cell
                        canMove = true;
                        if (firstCell.cellLeft.goalCell)
                        {
                            //code for checking goal
                            if (firstCell.cellLeft.gameObject.GetComponent <BakeryGoalCell>().myColor.ToString() == myColor.ToString())
                            {
                                canMove      = true;
                                movingToGoal = true;
                            }
                            else
                            {
                                canMove = false;
                            }
                        }
                    }
                    else
                    {
                        // next left cell is occupied
                        if (!baguetteToPush)
                        {
                            baguetteToPush = firstCell.cellLeft.gameObject.GetComponent <BakeryCellConn>().mybaguette;
                            BTPcurrentPos  = baguetteToPush.transform.position;
                            float adjustedX = nextPos.x - ((myCells.Length * 0.5f) + 0.5f);
                            baguetteToPush.transform.position = new Vector3(adjustedX, baguetteToPush.transform.position.y, baguetteToPush.transform.position.z);
                            pushingPos = baguetteToPush.transform.position;
                        }
                        if (baguetteToPush.CheckAllLeft())
                        {
                            //can push left
                            pushing = true;
                            canMove = true;
                        }
                        else
                        {
                            // cant push left
                            SetPushedBaguette();
                            baguetteToPush = null;
                            minX           = iniPos.x;
                            canMove        = false;
                            this.gameObject.transform.position = iniPos;
                        }
                    }
                }
                else
                {
                    minX    = iniPos.x;
                    canMove = false;
                    this.gameObject.transform.position = iniPos;
                }
            }
            else if (nextPos.x < this.gameObject.transform.position.x)
            {
                //Is moving left towards the starting point
                canMove = true;
            }

            if (Mathf.Abs(nextPos.x - iniPos.x) >= minDistance && canMove)
            {
                List <PuzzleCell> tempCells = new List <PuzzleCell>();
                if (baguetteToPush)
                {
                    foreach (PuzzleCell cell in baguetteToPush.myCells)
                    {
                        tempCells.Add(cell.CheckLeftAmmount(1));
                        cell.occupied = false;
                        cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                    }
                    for (int i = 0; i < tempCells.Count; i++)
                    {
                        //occupie (hmmm pie I want pie, give me pie X if you are reading this, I know is written occupy but whatever) new baguette cells and assign baguette
                        baguetteToPush.myCells[i]          = tempCells[i];
                        baguetteToPush.myCells[i].occupied = true;
                        baguetteToPush.myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = baguetteToPush;
                    }
                    baguetteToPush.firstCell = baguetteToPush.firstCell.CheckLeftAmmount(1);
                    baguetteToPush.lastCell  = baguetteToPush.lastCell.CheckLeftAmmount(1);
                    tempCells.Clear();
                    BTPcurrentPos.x          -= cellDistance;
                    baguetteToPush.iniPos     = BTPcurrentPos;
                    baguetteToPush.currentPos = BTPcurrentPos;
                }

                foreach (PuzzleCell cell in myCells)
                {
                    //free current baguette cells and get new cells
                    tempCells.Add(cell.CheckLeftAmmount(1));
                    cell.occupied = false;
                    cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                }
                for (int i = 0; i < tempCells.Count; i++)
                {
                    //occupie (hmmm pie I want pie, give me pie X if you are reading this, I know is written occupy but whatever) new baguette cells and assign baguette
                    myCells[i]          = tempCells[i];
                    myCells[i].occupied = true;
                    myCells[i].gameObject.GetComponent <BakeryCellConn>().mybaguette = this;
                }
                //update edge cells
                firstCell = firstCell.CheckLeftAmmount(1);
                lastCell  = lastCell.CheckLeftAmmount(1);
                tempCells.Clear();
                currentPos.x -= cellDistance;
                iniPos        = currentPos;
                if (movingToGoal)
                {
                    foreach (PuzzleCell cell in myCells)
                    {
                        //free current baguette cells and get new cells
                        cell.occupied = false;
                        cell.gameObject.GetComponent <BakeryCellConn>().mybaguette = null;
                        onGoal = true;
                        this.gameObject.SetActive(false);
                        canMove = false;
                    }
                }
            }
        }

        if (canMove)
        {
            if (nextPos.x > maxX)
            {
                nextPos.x = maxX;
            }
            if (nextPos.x < minX)
            {
                nextPos.x = minX;
            }
            this.gameObject.transform.position = nextPos;
            if (baguetteToPush)
            {
                baguetteToPush.gameObject.transform.position = pushingPos;
            }
        }
    }
示例#30
0
    void parseLevelMass()
    {
        float xPos   = 0f;
        float yPos   = 0f;
        float offset = cellPrefab.GetComponent <RectTransform>().rect.width;

        for (int i = 0; i < ySize; i++)
        {
            for (int j = 0; j < xSize; j++)
            {
                xPos += offset / 4f;
                PuzzleCell.CellType cellType = levelMass[i, j].type;
                if (cellType == PuzzleCell.CellType.none)
                {
                    continue;
                }

                float      rot = levelMass[i, j].angle;
                GameObject obj = Instantiate(cellPrefab, Vector3.zero, Quaternion.identity) as GameObject;
                obj.transform.SetParent(targetContainer);
                obj.transform.localScale = Vector3.one;
                RectTransform reTrans = obj.GetComponent <RectTransform> ();
                reTrans.anchoredPosition = new Vector2(xPos, yPos);
                reTrans.eulerAngles      = new Vector3(0f, 0f, rot);
                PuzzleCell pc = obj.GetComponent <PuzzleCell> ();
                pc.SetType(cellType);
                cells.Add(pc);
            }
            xPos  = 0f;
            yPos -= offset / 4f;
        }
        targetContainer.anchoredPosition = new Vector2(targetContainer.anchoredPosition.x - (xSize * offset / 8f), targetContainer.anchoredPosition.y + (ySize * offset / 8f));

        for (int i = 0; i < levelMassItems.Count; i++)
        {
            GameObject obj = Instantiate(cellBlockPrefab, Vector3.zero, Quaternion.identity) as GameObject;
            obj.transform.SetParent(cellBlockContainer);
            obj.transform.localScale    = Vector3.one;
            obj.transform.localPosition = Vector3.zero;
            xPos = -((offset / 4f) * 2f);
            yPos = offset / 4f;
            for (int k = 0; k < 3; k++)
            {
                for (int d = 0; d < 3; d++)
                {
                    xPos += offset / 4f;
                    if (levelMassItems[i][k, d].type == PuzzleCell.CellType.none)
                    {
                        continue;
                    }
                    GameObject obj1 = Instantiate(cellPrefab, Vector3.zero, Quaternion.identity) as GameObject;
                    obj1.transform.SetParent(obj.transform);
                    obj1.transform.localScale = Vector3.one;
                    obj1.name = k.ToString() + d.ToString();
                    RectTransform rcTrans = obj1.GetComponent <RectTransform> ();
                    rcTrans.anchoredPosition = new Vector2(xPos, yPos);
                    rcTrans.eulerAngles      = new Vector3(0f, 0f, levelMassItems[i][k, d].angle);
                    PuzzleCell pc = obj1.GetComponent <PuzzleCell> ();
                    pc.img.color = cellColor;
                    pc.SetType(levelMassItems[i][k, d].type);
                    obj.GetComponent <PuzzleCellBlock> ().cells.Add(new PuzzleCellBlock.PuzzleCellBlockType(levelMassItems[i][k, d].type, obj1.GetComponent <RectTransform> ()));
                    pc.enabled = false;
                }
                xPos  = -((offset / 4f) * 2f);
                yPos -= offset / 4f;
            }
        }
    }