Exemple #1
0
 public T Eval(GraphicEntity2 ge)
 {
     if (func != null)
     {
         return(func(ge));
     }
     return(val);
 }
Exemple #2
0
    public void Merge(GraphicEntity2 another, float duration = 0)
    {
        // TODO race condition!!
        var target = rect.Merge(another.rect);

        another.Remove(duration);
        Transform(target, duration);
    }
Exemple #3
0
    GraphicEntity2 AddRectAtPosition(int minX, int minY, int width, int height, Color color)
    {
        GridRect emptyRect = new GridRect(minX, minY, width, height);

        if (emptyRect != null)
        {
            var ge = GraphicEntity2.New(emptyRect, board);
            ge.SetColor(color);
            ge.SetOpacity(1, Beat(1));
            return(ge);
        }
        return(null);
    }
Exemple #4
0
    public IList <GraphicEntity2> BreakToUnitSquares(float duration = 0)
    {
        var squares = new List <GraphicEntity2>();

        foreach (var gridRect in rect.SplitToUnitSquares())
        {
            var g = GraphicEntity2.New(gridRect, board);
            g.SetColor(animatable.color);
            squares.Add(g);
        }
        Remove(duration, DONTUNLOCK: true);
        return(squares);
        // splits existing x to this as much as it can
    }
Exemple #5
0
 /*** ACCESS ***/
 public void LockTiles(GridRect rect, GraphicEntity2 ge)
 {
     //Debug.Log($"Board2: Lock {rect}");
     for (int x = rect.min.x; x <= rect.max.x; x++)
     {
         for (int y = rect.min.y; y <= rect.max.y; y++)
         {
             if (x >= 0 && x < width && y >= 0 && y < height)
             {
                 graphicEntities[x, y] = ge;
             }
             else
             {
                 //Debug.Log($"lock failed {x} {y}");
             }
         }
     }
 }
Exemple #6
0
    GraphicEntity2 AddRect(int width, int height, Color color, bool allowStacking = false)
    {
        Debug.Log(width + " " + height);
        GridRect emptyRect = board.FindEmptyRectWithSize(width, height);

        if (emptyRect == null && allowStacking)
        {
            emptyRect = board.FindRandomRectWithSize(width, height);
        }
        if (emptyRect != null)
        {
            var ge = GraphicEntity2.New(emptyRect, board);
            ge.SetColor(color);
            //ge.SetOpacity(opacity, Beat(1));
            return(ge);
        }
        return(null);
    }
Exemple #7
0
    bool AddRow(Color color, bool force = false)
    {
        // search for vacant spots
        // MUTEX
        Debug.Log("StoryOfASound: Looking for empty row");
        GridRect emptyRow = board.FindEmptyRow();

        Debug.Log("Found empty row" + emptyRow);
        if (emptyRow == null)
        {
            emptyRow = new GridRect(0, Random.Range(0, rows), cols, 1);
            foreach (var ge in board.GraphicEntities())
            {
                ge.DeleteRect(emptyRow, Beat(1));
            }
        }

        var newGe = GraphicEntity2.New(emptyRow, board);

        newGe.SetColor(color);
        //newGe.SetOpacity(1, Beat(1));
        return(true);
    }
Exemple #8
0
    IEnumerator Section4StoryOfASound(GraphicEntity2 ge, List <GA2> actions)
    {
        yield return(null);

        ge.ApplyActions(actions);
    }
Exemple #9
0
    public void Duplicate(float duration = 0)
    {
        var ge = GraphicEntity2.New(rect, board);

        ge.ApplyActions(actions);
    }