Esempio n. 1
0
        public IList CreateObjects()
        {
            List<IRenderable> balloons = new List<IRenderable>();

            Array colours = Enum.GetValues(typeof(Colour));

            for (int row = 0; row < Constants.MaximalYPosition; row += Constants.IterationStep)
            {
                for (int column = 0; column < Constants.MaximalXPosition; column += Constants.IterationStep)
                {
                    Position position = new Position(column + Constants.XOffset, row + Constants.YOffset);

                    int randomisedBalloonNumber = RandomNumberGenerator.Instance.Next(this.balloonVisualisations.Length);

                    char visualisation = this.balloonVisualisations[randomisedBalloonNumber];

                    Colour colour = (Colour)colours.GetValue(randomisedBalloonNumber);

                    Balloon balloon = new Balloon(position, visualisation, colour);

                    balloons.Add(balloon);
                }
            }

            return balloons;
        }
        /// <summary>
        /// Method that get the Balloon with a concrete value.
        /// </summary>
        /// <param name="value">The balloon value to be set</param>
        /// <returns>An existing instance of a Balloon class or creates one.</returns>
        public IBalloon GetBalloon(int value)
        {
            if (this.balloonsList.ContainsKey(value))
            {
                return this.balloonsList[value];
            }
            else
            {
                ITraversalEffect effect;

                switch (value)
                {
                    case 1:
                        effect = this.effectFactory.GetDefaultEffect();
                        break;
                    case 2:
                        effect = this.effectFactory.GetDefaultEffect();
                        break;
                    case 3:
                        effect = this.effectFactory.GetDefaultEffect();
                        break;
                    case 4:
                        effect = this.effectFactory.GetDefaultEffect();
                        break;
                    case 5:
                        effect = this.effectFactory.GetAreaPopEffect();
                        break;
                    default:
                        throw new ArgumentException("Invalid balloon value.");
                }

                var balloon = new Balloon(value, effect);

                this.balloonsList.Add(value, balloon);

                return balloon;
            }
        }