Пример #1
0
        /// <summary>
        ///     Method used to create a dot.
        /// </summary>
        /// <param name="cell">The cell you want to move the dot to.</param>
        /// <param name="type">The type of dot you want to create.</param>
        public void CreateDot(BoardCell cell, DotTypes type = DotTypes.Normal)
        {
            Dot dotCreated = null;

            switch (type)
            {
            case DotTypes.None:
                Debug.LogError("Invalid Dot Type.");
                break;

            case DotTypes.Normal:
                dotCreated = PoolManager.Instance.GetPoolableObject().GetComponent <NormalDot>();
                dotCreated.Setup(DotTypes.Normal, cell);

                // to prevent the same color as square from getting created right after the square is found.
                int colorIndex;
                do
                {
                    colorIndex = Random.Range(0, _colors.Count);
                } while (RemovedSquareColor == _colors[colorIndex]);

                ((NormalDot)dotCreated).DotColor = _colors[colorIndex];
                break;

            default:
                throw new InvalidEnumArgumentException();
            }

            if (dotCreated == null)
            {
                Debug.LogError("No Dot created");
                return;
            }

            cell.ContainingDot = dotCreated;
            cell.ContainingDot.SetSpawnPosition(_spawningPositions[dotCreated.ColumnNumber]);
            cell.ContainingDot.MoveToPosition(cell.transform);
            MoveManager.Instance.AddEventListeners(dotCreated);
        }
Пример #2
0
 /// <summary>
 /// Setups the dot.
 /// </summary>
 /// <param name="dotType">Type of the dot.</param>
 /// <param name="cell">The cell.</param>
 public virtual void Setup(DotTypes dotType, BoardCell cell)
 {
     DotType = dotType;
     UpdateCoordinates(cell.Row, cell.Column);
 }