Пример #1
0
        private void AddBallToGrid(IBallController newBall, GridPosition gridPosition)
        {
            if (!_ballArray.IsValidPosition(gridPosition))
            {
                Logging.Instance.Log(LogLevel.Warning,
                                     string.Format("Attempted to add at invalid grid position: {0}", gridPosition.ToString()));
            }
            if (_ballArray[gridPosition.X, gridPosition.Y] != null)
            {
                Logging.Instance.Log(LogLevel.Warning,
                                     string.Format("Overlapping at position: {0}", gridPosition.ToString()));
            }

            _ballPositionHandler.AppendAt(_ballArray, newBall, gridPosition);
            newBall.MarkDirty();
            _activeBalls.Add(newBall);

            Logging.Instance.Log(LogLevel.Debug,
                                 string.Format("Appending to grid : {0},{1} type: {2}", gridPosition.X, gridPosition.Y,
                                               newBall.BallType));

            var worldPosition = _ballFactory.GetWorldPositionFromGrid(gridPosition);

            newBall.SetActiveInGrid(gridPosition, worldPosition, _ballContainer.transform);
        }