private void OnDragBeganOnDotHandler(object grid)
        {
            var cellView = (GridCellView)grid;

            _currentDotOrigin = cellView as DotView;
            var gridDatum = cellView.GridDatum;

            if (_lineLookup.ContainsKey(gridDatum.ColorData.ColorId))
            {
                _currentLineRenderer = _lineLookup[gridDatum.ColorData.ColorId];
                if (_completedLines.ContainsKey(gridDatum.ColorData.ColorId))
                {
                    ClearLine(gridDatum.ColorData.ColorId);
                }
            }
            else
            {
                _currentLineRenderer            = Instantiate(_linePrefab, transform, false);
                _currentLineRenderer.startColor = _currentLineRenderer.endColor = gridDatum.ColorData.UnityColor;
                _lineLookup.Add(gridDatum.ColorData.ColorId, _currentLineRenderer);
            }

            var lineData = new List <Vector3Int>();
            var gridData = new List <GridDatum>();

            lineData.Add(GridUtility.GetLocalPositionFromIndices(gridDatum.PosX, gridDatum.PosY));
            UpdateLine(_currentLineRenderer, lineData);
            _currentGridDatum     = gridDatum;
            _currentLineColorData = gridDatum.ColorData;
            _currentLineData      = lineData;
            _currentLineGridData  = gridData;
            _lineDrawState        = LineDrawState.Drawing;
        }
Exemple #2
0
 private void PopulateDots(LevelDataModel levelData)
 {
     foreach (var gridDatum in levelData.GridData)
     {
         var position = GridUtility.GetLocalPositionFromIndices(gridDatum.PosX, gridDatum.PosY, levelData.GridSize);
         var cell     = Instantiate(dotPrefab, transform);
         cell.transform.localPosition  = position;
         cell.transform.localPosition += Vector3.back * 0.01f;
         cell.Initialize(gridDatum);
     }
 }
        private void ExtendCurrentLine(GridDatum gridDatum, bool isDot)
        {
            var position = GridUtility.GetLocalPositionFromIndices(gridDatum.PosX, gridDatum.PosY);

            _currentGridDatum = gridDatum;
            _currentLineData.Add(position);
            if (!isDot)
            {
                gridDatum.ColorData = _currentLineColorData;
                _currentLineGridData.Add(gridDatum);
            }
            UpdateLine(_currentLineRenderer, _currentLineData);
        }
Exemple #4
0
 private void PopulateCells(LevelDataModel levelData)
 {
     for (int i = 0; i < levelData.GridSize; i++)
     {
         for (int j = 0; j < levelData.GridSize; j++)
         {
             var position = GridUtility.GetLocalPositionFromIndices(i, j, levelData.GridSize);
             var cell     = Instantiate(gridCellPrefab, transform);
             cell.transform.localPosition = position;
             var gridDatum = new GridDatum(i, j);
             cell.Initialize(gridDatum);
         }
     }
 }