From 3137380cdb88d146d5b008ffc054877746e96e67 Mon Sep 17 00:00:00 2001 From: xom9kxom9k Date: Tue, 6 Feb 2024 20:08:51 +0400 Subject: [PATCH] 6 --- Seaplane/DrawingSeaplane.cs | 63 ++++++++++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 8 deletions(-) diff --git a/Seaplane/DrawingSeaplane.cs b/Seaplane/DrawingSeaplane.cs index d23be23..67d7381 100644 --- a/Seaplane/DrawingSeaplane.cs +++ b/Seaplane/DrawingSeaplane.cs @@ -1,12 +1,6 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Seaplane; +namespace Seaplane; /// -/// +/// Класс отвечающий за прорисовку и перемещение объекта - сущности /// public class DrawingSeaplane { @@ -105,5 +99,58 @@ public class DrawingSeaplane else if (y < 0) _startPosY = 0; else _startPosY = y; } + /// + /// Изменение направления перемещения + /// + /// + /// + public bool MoveTransport(DirectionType direction) + { + if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return false; + } + switch (direction) + { + //влево + case DirectionType.Left: + if (_startPosX.Value - EntitySeaplane.Step > 0) + { + _startPosX -= (int)EntitySeaplane.Step; + } + return true; + //вверх + case DirectionType.Up: + if (_startPosY.Value - EntitySeaplane.Step > 0) + { + _startPosY -= (int)EntitySeaplane.Step; + } + return true; + // вправо + case DirectionType.Right: + if (_startPosX.Value + _drawningPlaneWidth + EntitySeaplane.Step < _pictureWidth) + { + _startPosX += (int)EntitySeaplane.Step; + } + return true; + //вниз + case DirectionType.Down: + if (_startPosY.Value + _drawningPlaneHeight + EntitySeaplane.Step < _pictureHeight) + { + _startPosY += (int)EntitySeaplane.Step; + } + return true; + default: + return false; + } + } + + public void DrawTransport(Graphics g) + { + if (EntitySeaplane == null || !_startPosX.HasValue || !_startPosY.HasValue) + { + return; + } + } }