コード例 #1
0
ファイル: Controller.cs プロジェクト: DenisEA81/TheGame
        public override void LogicStep()
        {
            #region Обработка нажатия клавишь и мыши
            {
                if (PressedKeys.GetValue(System.Windows.Forms.Keys.Escape))
                {
                    ApplicationState = ApplicationStateEnum.Stop;
                    if (PressedKeys.GetValue(System.Windows.Forms.Keys.Escape))
                    {
                        if (PressedKeys.GetValue(System.Windows.Forms.Keys.Escape))
                        {
                            PressedKeys.SetValue(System.Windows.Forms.Keys.Escape, false);
                        }
                    }
                }
            }
            #endregion

            #region Проверка общеигровых триггеров
            if (ApplicationState != ApplicationStateEnum.Playing)
            {
                return;
            }
            #endregion

            #region Синхронизация времени
            int deltaAnimation = gameTimerAnimation.NextStep();
            int deltaVariant   = gameTimerVariant.NextStep();
            #endregion

            #region Выполнение всех Actions юнитов
            for (int j = 0; j < TestUnit.Count; j++)
            {
                for (int i = 0; i < ((List <IActions>)TestUnit[j].Actions).Count; i++)
                {
                    ((List <IActions>)TestUnit[j].Actions)[i] = FirstStep? ((List <IActions>)TestUnit[j].Actions)[i]?.Start():((List <IActions>)TestUnit[j].Actions)[i]?.Progress();
                    if (((List <IActions>)TestUnit[j].Actions)[i] == null)
                    {
                        ((List <IActions>)TestUnit[j].Actions).RemoveAt(i--);
                    }
                }
            }
            #endregion


            #region Подготовка матрицы рендеринга
            var CurrentPictures = new List <List <IPositionedBitmap> >()
            {
                new List <IPositionedBitmap>(), new List <IPositionedBitmap> (), new List <IPositionedBitmap>()
            };

            for (int i = 0; i < FullScenePictureList[0].Count; i++)
            {
                //if
                CurrentPictures[0].Add(FullScenePictureList[0][i]);
            }

            /*
             * for (int i = 0; i < FullScenePictureList[1].Count; i++)
             *  //if
             *  CurrentPictures[1].Add(FullScenePictureList[1][i]);
             */
            for (int i = 0; i < TestUnit.Count; i++)
            {
                CurrentPictures[2].Add(FullScenePictureList[1][0]);
            }

            //CurrentPictures[1].Sort(new PositionedPhysicalBitmapComparer( PositionedPhysicalBitmapComparer.SortDirection.Asc));

            /*
             *  for (int j = 0; j < (CurrentPictures[0]?.Count??0); j++)
             *  {
             *      ((IImageAnimation)CurrentPictures[0][j]).AnimateImage(deltaAnimation);
             *      ((IImageAnimation)CurrentPictures[0][j]).VariantRotate(-deltaVariant);
             *  }
             */
            for (int i = 0; i < TestUnit.Count; i++)
            {
                ((IImageAnimation)CurrentPictures[2][i]).AnimateImage(deltaAnimation);
                ((IImageAnimation)CurrentPictures[2][i]).VariantIndex = TestUnit[i].UnitOrientation.CurrentOrientation;
                CurrentPictures[2][i].Position = TestUnit[i].Position.ToPoint();
            }
            ((ImageMatrixRender)Render).ItemMatrix = CurrentPictures;
            #endregion

            FirstStep = false;
        }