Exemplo n.º 1
0
        private void Update()
        {
            RaycastHit hit;

            if (Physics.Raycast(_camera.ScreenPointToRay(Input.mousePosition), out hit))
            {
                Vector2Int selectedCellT = Grid.GetCellByWorldPos(hit.point);
                Vector2Int selectedCell;
                if (selectedCellT != new Vector2Int(-1, -1))
                {
                    selectedCell = selectedCellT;
                    _cursorPos   = Grid.GetCellCenterWorldPosByCell(selectedCell);
                    if (Input.GetButtonDown("Fire1"))
                    {
                        Grid.Cells[selectedCell.x, selectedCell.y].AddMoveValue(10);
                    }

                    if (Input.GetButtonDown("Fire2"))
                    {
                        Grid.GetCell(selectedCell).Iswall = true;
                        Grid.Cells[selectedCell.x, selectedCell.y].AddMoveValue(500);
                    }

                    if (Input.GetButtonDown("Jump"))
                    {
                        Grid.originePos = selectedCell;
                        Grid.CalculateFlowField();
                    }

                    if (Input.GetKey("a"))
                    {
                        MoveActor MA = Instantiate(prefabCube, hit.point + new Vector3(0, 0.5f, 0), quaternion.identity);
                        MA.grid = Grid;
                    }
                }
            }
            _cursor.position = Vector3.Lerp(_cursor.position, _cursorPos, cursorSmoothFactor * Time.deltaTime);
        }