Пример #1
0
    public void NewRandomChess(Vector2Int pos)
    {
        ChessShapeType shape     = (ChessShapeType)Random.Range(1, 6);
        int            direction = Random.Range(0, 4);
        List <int>     color     = GetChessColor();

        InitChess(pos, shape, direction, color);
    }
Пример #2
0
    public void InitChess(Vector2Int pos, ChessShapeType shape, int direction, List <int> color)
    {
        m_shape     = shape;
        m_direction = direction;
        m_color     = new List <int>(color);
        m_pos       = new List <Vector2Int>();
        m_pos.Add(pos);
        List <Vector2Int> temp = CalcAttachChessOffset(CalcAttachChessId(shape, direction), pos);

        m_pos.AddRange(temp);
    }
Пример #3
0
    private List <int> CalcAttachChessId(ChessShapeType shape, int direction)
    {
        List <int> attachChess = new List <int>();

        switch (shape)
        {
        case ChessShapeType.CST_Grid2:
            attachChess.Add((0 + direction) % 4);
            break;

        case ChessShapeType.CST_Grid3_L:
            attachChess.Add((0 + direction) % 4);
            attachChess.Add((1 + direction) % 4);
            break;

        case ChessShapeType.CST_Grid3_I:
            attachChess.Add((0 + direction) % 4);
            attachChess.Add((2 + direction) % 4);
            break;

        case ChessShapeType.CST_Grid4_T:
            attachChess.Add((0 + direction) % 4);
            attachChess.Add((1 + direction) % 4);
            attachChess.Add((2 + direction) % 4);
            break;

        case ChessShapeType.CST_Grid5_Plus:
            attachChess.Add((0 + direction) % 4);
            attachChess.Add((1 + direction) % 4);
            attachChess.Add((2 + direction) % 4);
            attachChess.Add((3 + direction) % 4);
            break;

        default:
            break;
        }
        return(attachChess);
    }