コード例 #1
0
    // returns null if the system is considered "stable"
    // on the other hand, if settling is necessary, returns the
    // offending script after making one move towards a stable state
    public CandyScript SettleStep()
    {
        KeyValuePair <Vector2Int, Vector2Int> move = FindStablizingMove();

        if (move.Key.x == -1)
        {
            return(null);
        }

        candy_grid[move.Value.x][move.Value.y] = candy_grid[move.Key.x][move.Key.y];
        candy_grid[move.Key.x][move.Key.y]     = null;

        CandyScript script = candy_grid[move.Value.x][move.Value.y];

        float dx = new int[] { -1, 1 }[move.Value.y - move.Key.y + parity_map[move.Key.x]] *mainRadius;
        float dy = PolyPieceGenerator.CalculateVStackDistance(6, mainRadius);

        script.transform.position += new Vector3(dx, -dy, 0);

        CandyScriptIndex id = candy_indexer[script];

        id.row    = move.Value.x;
        id.column = move.Value.y;

        return(script);
    }
コード例 #2
0
    public float GetHighestHeight()
    {
        float vStack = PolyPieceGenerator.CalculateVStackDistance(6, mainRadius);
        float aRad   = PolyPieceGenerator.CalculateActualRadius(6, mainRadius);

        return((GetHighestTrueHeight() + aRad) / vStack);
    }
コード例 #3
0
    public Vector2 GetGridPosition(float row, float col, int parity)
    {
        float       vShift         = PolyPieceGenerator.CalculateVStackDistance(6, mainRadius);
        const float OVERLAP_DIST   = 0.0f;
        float       lattice_offset = mainRadius - 0.5f;

        float x_translate    = (col * 2) * (mainRadius - OVERLAP_DIST);
        float odd_row_offset = parity * mainRadius;

        return(new Vector3(offsetUnits.x, offsetUnits.y) +
               new Vector3(lattice_offset + x_translate - odd_row_offset,
                           (0.5f + row) * vShift, transform.position.z));
    }
コード例 #4
0
    public Vector2 GetVerticalVelocityByTimePeriod(float period)
    {
        float actualRadius = PolyPieceGenerator.CalculateVStackDistance(6, mainRadius);

        return(new Vector2(0.0f, actualRadius / period));
    }