/// <summary>
        /// Инициализация списка объектов
        /// </summary>
        public virtual List<IAquariumObject> Init(AquariumInitializationParameters parameters, IAquariumPositionContext positionContext, AquariumObjectFactory factory)
        {
            List<IAquariumObject> aquariumObjects = new List<IAquariumObject>();

            GenerateFishes(parameters, aquariumObjects, positionContext, factory);
            GenerateSeaweeds(parameters, aquariumObjects, positionContext, factory);

            return aquariumObjects;
        }
 /// <summary>
 /// Генерация рыбок
 /// </summary>
 protected virtual void GenerateFishes(AquariumInitializationParameters parameters, List<IAquariumObject> aquariumObjects, IAquariumPositionContext positionContext, AquariumObjectFactory factory)
 {
     for (int fishNumber = 0; fishNumber < parameters.FishCount; fishNumber++)
     {
         // выбираем все параметры рыбок случайным образом
         FishParameters fishParameters = GetFishParameters(parameters, aquariumObjects, positionContext);
         IAquariumObject fish = factory.Create(AquariumObjectType.Fish, fishParameters);
         aquariumObjects.Add(fish);
     }
 }
 /// <summary>
 /// Генерация водорослей
 /// </summary>
 protected virtual void GenerateSeaweeds(AquariumInitializationParameters parameters, List<IAquariumObject> aquariumObjects, IAquariumPositionContext positionContext, AquariumObjectFactory factory)
 {
     Random random = new Random();
     for (int seaweedNumber = 0; seaweedNumber < parameters.SeaweedCount; seaweedNumber++)
     {
         // выбираем все параметры водорослей случайным образом
         SeaweedParameters seaweedParameters = GetSeaweedParameters(parameters, aquariumObjects, positionContext);
         IAquariumObject seaweed = factory.Create(AquariumObjectType.Seaweed, seaweedParameters);
         aquariumObjects.Add(seaweed);
     }
 }
Beispiel #4
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);

            AquariumModel model = AquariumModel.Instance;
            MainForm form = new MainForm(model);

            IRendererSelector rendererSelector = new ImageRendererSelector();

            IAquariumObjectRenderer healthRenderer = new HealthRenderer();
            IAquariumObjectWrapper aquariumObjectWrapper = new AquariumObjectWrapper(healthRenderer, model);

            AquariumObjectFactory factory = new AquariumObjectFactory(rendererSelector, aquariumObjectWrapper);
            model.Init(new AquariumInitializationParametersSinFishes(form.Size.Width, form.Size.Height), new AquariumObjectListInitializerSinFishes(), factory);

            Application.Run(form);
        }
        /// <summary>
        /// Инициализация аквариума
        /// </summary>
        public void Init(AquariumInitializationParameters parameters, AquariumObjectListInitializer aquariumObjectListInitializer, AquariumObjectFactory factory)
        {
            _objects = aquariumObjectListInitializer.Init(parameters, _positionContext, factory);

            SetSize(parameters.AquariumSizeX, parameters.AquariumSizeY);
        }