Exemplo n.º 1
0
        public bool CanMove(int x, int y)
        {
            IPlayer currentPlayer = GetCurrentPlayer();
            Coord   nextStep      = currentPlayer.CalculateNextStep(x, y);
            bool    isInGameField = DrawingEngine.IsInGameField(nextStep);

            if (isInGameField)
            {
                bool isFieldFree = IsFieldFree(nextStep);
                if (isFieldFree)
                {
                    return(true);
                }
                else
                {
                    DrawingEngine.ShowMessage("You can't move there! Try again!");
                }
            }
            else
            {
                DrawingEngine.ShowMessage("You can't move outside the field! Try again!");
            }

            return(false);
        }
Exemplo n.º 2
0
        private void MainPaint_Load(object sender, EventArgs e)
        {
            settings     = Settings.Initialize();
            mouseHandler = MouseHandler.Initialize();
            penPreview   = PenPreview.Initialize(settings.Pen, PictureBoxThickness.Width, PictureBoxThickness.Height);
            storage      = Storage.Initialize();

            drawingEngine = new DrawingEngine(settings, mouseHandler, penPreview, storage);

            PictureBoxThickness.Image = drawingEngine.GetPenImage();
            PictureBoxPaint.Image     = drawingEngine.MainImage;

            currentProcess = Process.GetCurrentProcess();
            currentProcess.Refresh();
            memoryLabel.Text = "Memory usage: " + ((float)currentProcess.PrivateMemorySize64 / 1024f / 1024f).ToString("F1") + "MB";

            _isLineFinished   = true;
            _isBtnFillClicked = false;
            _isFigureCreated  = false;
            _isFirstPointAdd  = false;
            _isFigureSelected = false;


            this.SetStyle(ControlStyles.DoubleBuffer | ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint, true);
            this.UpdateStyles();

            NumericUpDownPolygon.Value = settings.numberOfPolygonApexes;
        }
Exemplo n.º 3
0
        public LevelElements()
        {
            this._engine   = new DrawingEngine();
            this._elements = new List <Drawable>();

            this.Enemies = new List <Drawable>();
            this.Tiles   = new List <Drawable>();
        }
Exemplo n.º 4
0
 public void Setup()
 {
     _settings      = Settings.Initialize();
     _mouseHandler  = MouseHandler.Initialize();
     _penPreview    = PenPreview.Initialize(_settings.Pen, 31, 31);
     _storage       = new Mock <IStorage>(MockBehavior.Strict);
     _mousehandler  = new Mock <IMouseHandler>(MockBehavior.Strict);
     _drawingEngine = new DrawingEngine(_settings, _mousehandler.Object, _penPreview, _storage.Object);
     _drawable      = new Line(_mouseHandler.GetPreviousMove(), _mouseHandler.GetMove(), _settings.Pen, _settings.SmoothingMode);
 }
Exemplo n.º 5
0
        public void Run()
        {
            GameFieldForm gf = new GameFieldForm();

            gf.Show();
            (DrawingEngine as WFormDrawingEngine).Form = gf;

            DrawingEngine.DrawBoardFields();
            DrawingEngine.DrawPlayers(this.Players);

            DrawingEngine.DrawObjects(this.GameObjects);
        }
 /// <summary>
 /// Renders the annotation on the <see cref="T:Vintasoft.Imaging.Drawing.DrawingEngine" />
 /// in the coordinate space of annotation.
 /// </summary>
 /// <param name="drawingEngine">The <see cref="T:Vintasoft.Imaging.Drawing.DrawingEngine" /> to render on.</param>
 /// <param name="drawingSurface">The object that provides information about drawing surface.</param>
 protected override void RenderInContentSpace(DrawingEngine drawingEngine, DrawingSurface drawingSurface)
 {
     using (IGraphicsPath path = GetAsGraphicsPath(drawingEngine.DrawingFactory))
     {
         if (Data.FillBrush != null)
         {
             using (IDrawingBrush brush = drawingEngine.DrawingFactory.CreateBrush(Data.FillBrush))
                 drawingEngine.FillPath(brush, path);
         }
         if (Data.Border)
         {
             using (IDrawingPen pen = drawingEngine.DrawingFactory.CreatePen(Data.Outline))
                 drawingEngine.DrawPath(pen, path);
         }
     }
 }
Exemplo n.º 7
0
        public void SendPlayground(Message message, TelegramBotClient bot)
        {
            try
            {
                var             fileStream = DrawingEngine.GetPlaygrounds(this);
                InputOnlineFile dichFile   = new InputOnlineFile(fileStream);
                bot.SendPhotoAsync(message.From.Id, dichFile, caption: "Игровое поле.").Wait();
            }
            catch (Exception e)
            {
                bot.SendTextMessageAsync(message.From.Id,
                                         $"Что-то навернулось при отправке картинки игрового поля. {e.Message}");
            }

            if (!_game.GameIsOn)
            {
                bot.SendTextMessageAsync(message.From.Id, "Игровое поле для остановленой игры.");
            }
        }
Exemplo n.º 8
0
        private bool IsFieldFree(Coord nextStep)
        {
            IGameObject gameObject = GetObjectOnNextStep(nextStep);

            if (gameObject != null)
            {
                DrawingEngine.ShowMessage("You have just met an object!");

                if (gameObject is Obstacle)
                {
                    (gameObject as IEnemy).ApplyEffects(GetCurrentPlayer());
                    return(false);
                }
                else if (gameObject is IEnemy)
                {
                    (gameObject as IEnemy).ApplyEffects(GetCurrentPlayer());
                    return(true);
                }
                else if (gameObject is IFriend)
                {
                    (gameObject as IFriend).ApplyEffects(GetCurrentPlayer());
                    return(true);
                }
                else if (gameObject is ITarget)
                {
                    DrawingEngine.ShowMessage(GetCurrentPlayer().Name + " wins the game! Start a new game!");
                }

                return(false);
            }

            foreach (IPlayer obj in players)
            {
                if (obj.IsVisible && obj.Location.X == nextStep.X && obj.Location.Y == nextStep.Y)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 9
0
 public CreateNewCanvas()
 {
     InitializeComponent();
     settings      = Settings.Initialize();
     drawingEngine = new DrawingEngine(settings, MouseHandler.Initialize(), PenPreview.Initialize(settings.Pen, 31, 31), Storage.Initialize());
 }
Exemplo n.º 10
0
 private void InitializeEngine()
 {
     DrawEngine = new DrawingEngine();
     GameEngine = new GameEngine(DrawEngine, new GameStatus());
 }