Пример #1
0
    private bool OnCellInteract(PaintingCell cell)
    {
        if (!_activeColor.HasValue)
        {
            _bombModule.LogFormat("Tried to paint {0} with no palette color!", cell.name);
            return(true);
        }

        if (!cell.FinalColorOption.HasValue)
        {
            if (_activeColor != cell.ColorOption)
            {
                cell.ColorOption      = _activeColor.Value;
                cell.FinalColorOption = cell.ColorOption;
                _bombModule.LogFormat("Painting {0} with {1}.", cell.name, _activeColor.Value);
            }
            else
            {
                _bombModule.LogFormat("Tried to paint {0}, but that cell is already complete.", cell.name);
                _bombModule.HandleStrike();
            }

            if (IsAllSolved())
            {
                _bombModule.Log("All cells are now at a final color.");
                _bombModule.HandlePass();
            }

            return(true);
        }

        if (cell.ColorOption == cell.FinalColorOption)
        {
            _bombModule.LogFormat("Tried to paint {0}, but that cell is already complete.", cell.name);
            _bombModule.HandleStrike();
            return(true);
        }

        if (_activeColor.Value != cell.FinalColorOption)
        {
            _bombModule.LogFormat("Tried to paint {0} with {1}, but that's not the correct final color; expected {2}.", cell.name, _activeColor.Value, cell.FinalColorOption);
            _bombModule.HandleStrike();
            return(true);
        }

        _bombModule.LogFormat("Painting {0} with {1}.", cell.name, _activeColor.Value);
        cell.ColorOption = _activeColor.Value;

        if (IsAllSolved())
        {
            _bombModule.Log("All cells are now at their final color.");
            _bombModule.HandlePass();
        }

        return(true);
    }
Пример #2
0
    private void InstantiateCells(List <ConvexPoly> polys, ColorOption[] pickedColors)
    {
        for (int polyIndex = 0; polyIndex < polys.Count; ++polyIndex)
        {
            ColorOption colorOption = pickedColors[polyIndex];

            PaintingCell cell = Instantiate <PaintingCell>(cellPrefab);
            cell.name = string.Format("Cell #{0}", polyIndex + 1);
            cell.transform.SetParent(transform, false);
            cell.gameObject.SetActive(true);
            cell.Generate(colorOption, polys[polyIndex].GetInsetPoints(shapeBorderWidth * 0.5f));

            Cells.Add(cell);
        }
    }
Пример #3
0
    private void Repaint()
    {
        _bombModule.Log("Generating painting...");

        _painting.Repaint();

        SetupPaletteToPaintingLinks();

        _painting.selectionGrid.SetChildren(GetComponentsInChildren <FluidSelectable>());

        foreach (PaintingCell cell in _painting.Cells)
        {
            PaintingCell closureCell = cell;

            _bombModule.LogFormat("{0} => {1}.", closureCell.name, cell.ColorOption);

            closureCell.fluidSelectable.selectable.Parent      = _selectable;
            closureCell.fluidSelectable.selectable.OnInteract += () => OnCellInteract(closureCell);
        }
    }