コード例 #1
0
ファイル: GameManager.cs プロジェクト: power911/puzzle15
    public PazzleElement FindPuzzle(int X, int Y)
    {
        PazzleElement puzzle = null;

        foreach (var item in _elementsForRandom)
        {
            if (item.GridX == X && item.GridY == Y)
            {
                puzzle = item.GetComponentInChildren <PazzleElement>();
            }
        }
        return(puzzle);
    }
コード例 #2
0
ファイル: GameManager.cs プロジェクト: power911/puzzle15
    public void PazzleMoving(int x, int y, PazzleElement element)
    {
        for (int X = 0; X < _elements; X++)
        {
            if (_grid[X, y].Free)
            {
                if (element.X + 2 == _grid[X, y].GridX || element.X - 2 == _grid[X, y].GridX)
                {
                    return;
                }

                if (element.X + 3 == _grid[X, y].GridX || element.X - 3 == _grid[X, y].GridX)
                {
                    return;
                }
                if (_developerMode)
                {
                    if (element.X + 1 == _grid[X, y].GridX)
                    {
                        _randomEnum.Types.Add(Action.DOWN);
                    }
                    if (element.X - 1 == _grid[X, y].GridX)
                    {
                        _randomEnum.Types.Add(Action.UP);
                    }
                }

                element.gameObject.transform.SetParent(_grid[X, y].transform);
                element.transform.position = _grid[X, y].transform.position;
                element.X = X;
                element.Y = y;
                CheckGrid();
                return;
            }
        }
        for (int Y = 0; Y < _elements; Y++)
        {
            if (_grid[x, Y].Free)
            {
                if (element.Y + 2 == _grid[x, Y].GridY || element.Y - 2 == _grid[x, Y].GridY)
                {
                    return;
                }

                if (element.Y + 3 == _grid[x, Y].GridY || element.Y - 3 == _grid[x, Y].GridY)
                {
                    return;
                }

                if (_developerMode)
                {
                    if (element.Y + 1 == _grid[x, Y].GridY)
                    {
                        _randomEnum.Types.Add(Action.RIGHT);
                    }
                    if (element.Y - 1 == _grid[x, Y].GridY)
                    {
                        _randomEnum.Types.Add(Action.LEFT);
                    }
                }

                element.gameObject.transform.SetParent(_grid[x, Y].transform);
                element.transform.position = _grid[x, Y].transform.position;
                element.X = x;
                element.Y = Y;
                CheckGrid();
                return;
            }
        }
    }