From 026b4edb42523e99da830f8b38c3fbfcc0c49056 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Sat, 4 Nov 2023 21:12:30 +0400 Subject: [PATCH 1/6] =?UTF-8?q?=D0=BF=D1=80=D0=B0=D0=B2=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus/images/KeyDown.jpg | Bin 0 -> 1382 bytes Airbus/images/KeyLeft.jpg | Bin 0 -> 1445 bytes Airbus/images/KeyRight.jpg | Bin 0 -> 1389 bytes Airbus/images/KeyUp.jpg | Bin 0 -> 1449 bytes 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 Airbus/images/KeyDown.jpg create mode 100644 Airbus/images/KeyLeft.jpg create mode 100644 Airbus/images/KeyRight.jpg create mode 100644 Airbus/images/KeyUp.jpg diff --git a/Airbus/images/KeyDown.jpg b/Airbus/images/KeyDown.jpg new file mode 100644 index 0000000000000000000000000000000000000000..d636d38b31f23588929b854e87a4270ca2fa56bf GIT binary patch literal 1382 zcmex=E*8A72xWwP-bSNsiRO>nwXPW zQmJ68U}nI@@c%Z0GXoPNBM3nOGb=L)u(7Z(v$C_Xvx6`PCpRYt2NwrBI~Ok(7dH zkx|JhscGpMnOVgprDf$6l~v6xt!?ccon4bAPnkMx`iz;g7A;<~blLJ1D_3pWyk+aQ z?K^hvI&}ER(PPI?oIG{u@|COCuHU$M>*1rvPo6$|{^I4UkDoq&`TFhqkDtFl{$gZc zhIk9^Gcr>~AaoGc^79 zcOy>p@5(y0ms0-6dDDF^mDG#B`c>LHM@nt-(_6O>)|v#m?Oy9Gu%gT8$mE_$e!le~ zTmSg|yK$%P#(fF!hf zSsn79;qt!j_)AL}>RA6X96V#sY@f-0%rT$ ze<)kNMd^rAS8BxDJhNwJ%vs+1jKXUa|1*eu_4Rulb5(Es`gQBpuV25cdiLzuGov!s zrIzV@vfik3?u@rslBdcfPt(7<{$&0zepr7?`JsD<4e#SzvGYgbL_W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o5T4z>pSiTyv+;{OQgKWhIY+8*+8>-@vE$p@l*<}r31iuL$0KXCV!$kvBD zBlgVSeCzyf`P9i}4|d$yad-0e*ZM!2Z+}}RUwzDe^FRAHiC6zK{0xuZIRArB{10XO zrvD5NrtX*eXH?OAKu+oExWWujAA{X1|_b-mbS!FE?qsS=a=P dO!X$Q&)kRALewsp%{?+nWc^-^1^oYS0s!vNU0VPE literal 0 HcmV?d00001 diff --git a/Airbus/images/KeyRight.jpg b/Airbus/images/KeyRight.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e24b05b2a62943e9ce39de8b6f74a8224aff025f GIT binary patch literal 1389 zcmex=E*8A72xWwP-bSNsiRO>nwXPW zQmJ68U}nI@@c%Z0GXoPNBM3nOGb=L)u(7Z(v$C_Xvx6`PCpRYt2NwrBI~Ok(7dH zkx|JhscGpMnOVgprDf$6l~v6xt!?ccon4bAPnkMx`iz;g7A;<~blLJ1D_3pWyk+aQ z?K^hvI&}ER(PPI?oIG{u@|COCuHU$M>*1rvPo6$|{^I4UkDoq&`TFhqkDtFl{$gZc zhIk9^GcfQUaW%8rMdE)?{xJTy{80TC_d{>R zkKJSY$Tss)KUYQ9{kK+SE0>>B-M-Ujs)h1mZEa;m#)(&_Hl!-l3r5XbS-LK3dieG0 z;pW$`U$#Aa_UxIpI@gVMi3diGc4+U6ZLvMc;fFU$6BSo6w3?bhq07113Bm6JHdQsQ+Q>Jvl4JL?bH)#vT! z1nPJD&yc#8{n7TOH(&SKyI-4^UB2aNu8+9bc7dIJ8Q*!1Ypq_%dX_vXEMw`Re$ueom5{>f|mZ{1#~;q8|qtxxBho?Uuo+9ip|tFaU3DR0@dTHvtOk_UAM>JLiRKe*oO z|EOkH{*m*ys=cq6=<{w;Jva5kKc{QA+Lq1{t@Y`#-4pSjVR~TajP37z9HTVt-S;Qg z|4`U|sQza0w*x0^8MR(;_Y*QMr8I-2>AnJe$Pt?$&aW9M!rZQImj$|)1*)}WKo TB^nw6Dn3|6m%B35|Gxl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=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20'AirBus/images/KeyDown.jpg'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBus/images/KeyDown.jpg | Bin 1382 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 AirBus/images/KeyDown.jpg diff --git a/AirBus/images/KeyDown.jpg b/AirBus/images/KeyDown.jpg deleted file mode 100644 index d636d38b31f23588929b854e87a4270ca2fa56bf..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1382 zcmex=E*8A72xWwP-bSNsiRO>nwXPW zQmJ68U}nI@@c%Z0GXoPNBM3nOGb=L)u(7Z(v$C_Xvx6`PCpRYt2NwrBI~Ok(7dH zkx|JhscGpMnOVgprDf$6l~v6xt!?ccon4bAPnkMx`iz;g7A;<~blLJ1D_3pWyk+aQ z?K^hvI&}ER(PPI?oIG{u@|COCuHU$M>*1rvPo6$|{^I4UkDoq&`TFhqkDtFl{$gZc zhIk9^Gcr>~AaoGc^79 zcOy>p@5(y0ms0-6dDDF^mDG#B`c>LHM@nt-(_6O>)|v#m?Oy9Gu%gT8$mE_$e!le~ zTmSg|yK$%P#(fF!hf zSsn79;qt!j_)AL}>RA6X96V#sY@f-0%rT$ ze<)kNMd^rAS8BxDJhNwJ%vs+1jKXUa|1*eu_4Rulb5(Es`gQBpuV25cdiLzuGov!s zrIzV@vfik3?u@rslBdcfPt(7<{$&0zepr7?`JsD<4e#SzvGYgbL_WGsnN_!Pc}(-u zJBJ>#qmaVD3 z$9nahm(wRZyz9Flse4y;;yjBR%RF>C3cPyigYSQE%)fE}G5edHzcqZ<*OdI|{V0A+ zUSOZHbgkcGw~u!F%U8KR zKFZbqHt)yGWykJGUs!i$KL3~1Gq%@f#vQp~wRxq)rv;@-_g7|4UHa1{&}9AvQwGsT z@!RA72tR+A|3@VMq3!&pf7%&F*->`$S30k{WxMzCt=K4E$-|Y!ZqBPtN> Date: Sat, 4 Nov 2023 21:12:58 +0400 Subject: [PATCH 3/6] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20'AirBus/images/KeyLeft.jpg'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBus/images/KeyLeft.jpg | Bin 1445 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 AirBus/images/KeyLeft.jpg diff --git a/AirBus/images/KeyLeft.jpg b/AirBus/images/KeyLeft.jpg deleted file mode 100644 index dd31ccefed321ffcef86a3d672beeb4ff3baaf68..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1445 zcmex=E*8A72xWwP-bSNsiRO>nwXPW zQmJ68U}nI@@c%Z0GXoPNBM3nOGb=L)u(7Z(v$C_Xvx6`PCpRYt2NwrBI~Ok(7dH zkx|JhscGpMnOVgprDf$6l~v6xt!?ccon4bAPnkMx`iz;g7A;<~blLJ1D_3pWyk+aQ z?K^hvI&}ER(PPI?oIG{u@|COCuHU$M>*1rvPo6$|{^I4UkDoq&`TFhqkDtFl{$gZc zhIk9^Gc?iAgXx0A_ zGkzHUM`-=SUnd`RH$T#s&$`xIxS+z^e{R_C;HMMQW_BoDyIeKl@($%E6Wk{4`dRup z{g3$ie|#*n|8bsP6;q?~BYV-=@{jdlmmcr8I<_+7^wNs5TSc#?3odT_cJiP5t;Gh5 zc}|=QT#*0l_oMtH?}cizezdQt*nLdu*~&-xA{9-=#VcOzn)256>YW)}+#8=i4OqqW zFf=sOA(W}Xeo_1nv(x{$sz28M<4XQ`{afF)f9lxxJ6e zCTH$-f0y3ry?N}LvUG3B{0}$oOYDEKp(gS_!=ckb{}~?NfBtm=|J$yvKlA=GG`sH8 z|FQki^EdV%t@6bymLIvNwd3+W1@HW9v&}2dukg*4yqqI*Y?IfSgXLnmI}hmi8TpDZ ze%Jpa!v2qQ`-kQKxMDw4)+m3pcFA70(a3voc9_nFtb6h^5Adq4IU1e!cI7Vfus+`| zS^13PpIQGiuzLPyXtMqj1|&m%d`$iryZ(>LeEzTA%eG(mlezrXrkCH}Hl1d9IVo4K ztEpysl6>}zdk%f!zkaUa?~3Q%WBzgT!*6RJ+KXpY#dq46uXo5T4z>pSiTyv+;{OQgKWhIY+8*+8>-@vE$p@l*<}r31iuL$0KXCV!$kvBD zBlgVSeCzyf`P9i}4|d$yad-0e*ZM!2Z+}}RUwzDe^FRAHiC6zK{0xuZIRArB{10XO zrvD5NrtX*eXH?OAKu+oExWWujAA{X1|_b-mbS!FE?qsS=a=P dO!X$Q&)kRALewsp%{?+nWc^-^1^oYS0s!vNU0VPE -- 2.25.1 From 23aab7e7ff22a2a3b1df67e8c83dc1b23560d2ab Mon Sep 17 00:00:00 2001 From: dex_moth Date: Sat, 4 Nov 2023 21:13:01 +0400 Subject: [PATCH 4/6] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20'AirBus/images/KeyRight.jpg'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBus/images/KeyRight.jpg | Bin 1389 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 AirBus/images/KeyRight.jpg diff --git a/AirBus/images/KeyRight.jpg b/AirBus/images/KeyRight.jpg deleted file mode 100644 index e24b05b2a62943e9ce39de8b6f74a8224aff025f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1389 zcmex=E*8A72xWwP-bSNsiRO>nwXPW zQmJ68U}nI@@c%Z0GXoPNBM3nOGb=L)u(7Z(v$C_Xvx6`PCpRYt2NwrBI~Ok(7dH zkx|JhscGpMnOVgprDf$6l~v6xt!?ccon4bAPnkMx`iz;g7A;<~blLJ1D_3pWyk+aQ z?K^hvI&}ER(PPI?oIG{u@|COCuHU$M>*1rvPo6$|{^I4UkDoq&`TFhqkDtFl{$gZc zhIk9^GcfQUaW%8rMdE)?{xJTy{80TC_d{>R zkKJSY$Tss)KUYQ9{kK+SE0>>B-M-Ujs)h1mZEa;m#)(&_Hl!-l3r5XbS-LK3dieG0 z;pW$`U$#Aa_UxIpI@gVMi3diGc4+U6ZLvMc;fFU$6BSo6w3?bhq07113Bm6JHdQsQ+Q>Jvl4JL?bH)#vT! z1nPJD&yc#8{n7TOH(&SKyI-4^UB2aNu8+9bc7dIJ8Q*!1Ypq_%dX_vXEMw`Re$ueom5{>f|mZ{1#~;q8|qtxxBho?Uuo+9ip|tFaU3DR0@dTHvtOk_UAM>JLiRKe*oO z|EOkH{*m*ys=cq6=<{w;Jva5kKc{QA+Lq1{t@Y`#-4pSjVR~TajP37z9HTVt-S;Qg z|4`U|sQza0w*x0^8MR(;_Y*QMr8I-2>AnJe$Pt?$&aW9M!rZQImj$|)1*)}WKo TB^nw6Dn3|6m%B35|Gx Date: Sat, 4 Nov 2023 21:13:04 +0400 Subject: [PATCH 5/6] =?UTF-8?q?=D0=A3=D0=B4=D0=B0=D0=BB=D0=B8=D1=82=D1=8C?= =?UTF-8?q?=20'AirBus/images/KeyUp.jpg'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AirBus/images/KeyUp.jpg | Bin 1449 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 AirBus/images/KeyUp.jpg diff --git a/AirBus/images/KeyUp.jpg b/AirBus/images/KeyUp.jpg deleted file mode 100644 index 046f5d5b3dba2df936612a5b3b5e8fa90c98d13e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1449 zcmbV}c~Db#5XXNnFChn)0fHPBA`n3|DiOr0Eh-HVEQ%BnJEe$<5h#~{1dl!ixx}hS z1l&vXmoQrjmDr+sSHa7!`y-pm2PEiX<=o`O^=wyO;dzh(5N(1 z$A1%k6)YbaJ`9tHWhrDb z(Y=eP12U6hGu>yIneFO0s$04pZ%^q-n)~wlc2-0W>M?)A)?7NneyW3`6K95}*Gz9; zzXkpaKVB6089yjEL=gH#l9%gX zJv6)Jr6=p#>F)C*P}YX6Jq&vf-(il0N2Qxtcc=L(} z#g^j$P4mR2UU+Jx-^w|K`56T1RZj+|K7WuGDYwMT^mjVMY3mu##KF)Jq@k{JpGQnUly0JEe6dXpflvgqYZ;I1`P5Uy4=ahW-B`D!w|ho2YOHput?Uf~Dg9SsToWft zZ#d`27+fY}yZkZcppj8_5oz~E5^u$_Wa5Ha6bI7dD^HAsS*c`CU(f4|@AeLf5;t+( zuOId=D0l1P%#p|y*R=b-b~W^&BZ0c?y)To(c65BpsV|AR>t`ONVyRlsIewIp*X5oI zQF9@3I91b$*-aQN8*~cHu5-LiZuCq-E@ib<)C>f(4&|r6_T9YiVY3ipTDowizsy=DBiR{W1H6 zzaeS&u$9L9gL=`RL%`S$h2(`M-H6<%vi=GOxqKY7^PWqF&IdGF)uXrX$mB+-On^2j zif>oXIgrIa8kilQ{2*t=5(m}z)&9%VayBI|Zjkg$V9XOnddWztfs@*fFh#J`)zMj9 zk)NWy8;-sy#N3}%*A)DS$y%cOE(p2P^gMy)yQ0IhFF*;$6eA}v$7h`wYrc%zZ)8Q) z;-F@iy`(x6%+l{r;{bEwq5lf_|;?&|n2j8a$SxNreyX8$2PDz2u+-|LJQGT6y zvc;%#F?+quD&N&hUHWlAZo@$y(&j+$%tE$sH>&66VF@~GsZxG%c(Qfj?@49roTKYB fSDKnjuXQ9lJNhf7kZN~}{>-7Z+EA}5YrO9-)>mHH -- 2.25.1 From ca85f1e7428e6eb41cec14367e8ae2b04a4ff2e4 Mon Sep 17 00:00:00 2001 From: dex_moth Date: Sat, 18 Nov 2023 10:00:43 +0400 Subject: [PATCH 6/6] =?UTF-8?q?=D0=BB=D0=B0=D0=B1=202?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Airbus.sln | 2 +- Airbus/DrawningAirbus.cs | 156 -------------- Airbus/Drawnings/DrawningAirbus.cs | 156 ++++++++++++++ Airbus/Drawnings/DrawningPlane.cs | 48 +++++ .../DirectionType.cs} | 4 +- Airbus/Entities/EntityAirbus.cs | 24 +++ Airbus/Entities/EntityPlane.cs | 23 ++ Airbus/EntityAirbus.cs | 42 ---- Airbus/FormAirbus.Designer.cs | 197 +++++++++++------- Airbus/FormAirbus.cs | 104 +++++++-- Airbus/FormAirbus.resx | 24 +-- Airbus/MovementStrategy/AbstractStrategy.cs | 89 ++++++++ .../MovementStrategy/DrawningObjectAirbus.cs | 39 ++++ Airbus/MovementStrategy/IMoveableObject.cs | 15 ++ Airbus/MovementStrategy/MoveToBorder.cs | 61 ++++++ Airbus/MovementStrategy/MoveToCenter.cs | 59 ++++++ Airbus/MovementStrategy/ObjectParameters.cs | 27 +++ Airbus/MovementStrategy/Status.cs | 15 ++ Airbus/Program.cs | 4 +- .../{Airbus.csproj => ProjectAirbus.csproj} | 0 Airbus/Properties/Resources.Designer.cs | 4 +- 21 files changed, 783 insertions(+), 310 deletions(-) delete mode 100644 Airbus/DrawningAirbus.cs create mode 100644 Airbus/Drawnings/DrawningAirbus.cs create mode 100644 Airbus/Drawnings/DrawningPlane.cs rename Airbus/{Direction.cs => Entities/DirectionType.cs} (76%) create mode 100644 Airbus/Entities/EntityAirbus.cs create mode 100644 Airbus/Entities/EntityPlane.cs delete mode 100644 Airbus/EntityAirbus.cs create mode 100644 Airbus/MovementStrategy/AbstractStrategy.cs create mode 100644 Airbus/MovementStrategy/DrawningObjectAirbus.cs create mode 100644 Airbus/MovementStrategy/IMoveableObject.cs create mode 100644 Airbus/MovementStrategy/MoveToBorder.cs create mode 100644 Airbus/MovementStrategy/MoveToCenter.cs create mode 100644 Airbus/MovementStrategy/ObjectParameters.cs create mode 100644 Airbus/MovementStrategy/Status.cs rename Airbus/{Airbus.csproj => ProjectAirbus.csproj} (100%) diff --git a/Airbus.sln b/Airbus.sln index 8ca6d74..fb92968 100644 --- a/Airbus.sln +++ b/Airbus.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.5.33530.505 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AirBus", "AirBus\AirBus.csproj", "{97F3FB83-880E-4D1D-B941-1FB2F9B5C747}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ProjectAirbus", "AirBus\ProjectAirbus.csproj", "{97F3FB83-880E-4D1D-B941-1FB2F9B5C747}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/Airbus/DrawningAirbus.cs b/Airbus/DrawningAirbus.cs deleted file mode 100644 index f25fd07..0000000 --- a/Airbus/DrawningAirbus.cs +++ /dev/null @@ -1,156 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http.Headers; -using System.Security.Cryptography.X509Certificates; -using System.Text; -using System.Threading.Tasks; - -namespace AirBus -{ - public class DrawningAirBus - { - public EntityAirBus? EntityAirBus { get; private set; } - - // ширина и высота картинки - private int pictureWidht; - private int pictureHeight; - - // стартовые точки - private int startPosX; - private int startPosY; - - private readonly int airbusWidth = 100; - private readonly int airbusHeight = 37; - - public bool Init(int speed, double weight, Color bodyColor, Color additionalColor, int width, int height) - { - pictureWidht = width; - pictureHeight = height; - - EntityAirBus = new EntityAirBus(); - EntityAirBus.Init(speed, weight, bodyColor, additionalColor); - return true; - } - - //установка позиции - public void SetPosition(int x, int y) - { - if (x >= 0 && x + airbusWidth <= pictureWidht && y >= 0 && y + airbusHeight <= pictureHeight) - { - startPosX = x; - startPosY = y; - } - } - - // изменение направления движения - public void MoveTransport(Direction direction) - { - if (EntityAirBus == null) - { - return; - } - switch (direction) - { - case Direction.Left: - if (startPosX - EntityAirBus.Step > 0) - { - startPosX -= (int)EntityAirBus.Step; - } - break; - case Direction.Right: - if (startPosX + EntityAirBus.Step <= pictureWidht) - { - startPosX += (int)EntityAirBus.Step; - } - break; - case Direction.Up: - if (startPosY - EntityAirBus.Step > 0) - { - startPosY -= (int)EntityAirBus.Step; - } - break; - case Direction.Down: - if (startPosY + EntityAirBus.Step <= pictureHeight) - { - startPosY += (int)EntityAirBus.Step; - } - break; - } - } - - // РИСОВАНИЕ САМОЛЁТА - public void DrawTransport(Graphics g) - { - if ( startPosX < 0 || startPosY < 0 || EntityAirBus == null) - { - return; - } - Pen pen = new(Color.Black); - Brush additionalBrush = new SolidBrush(EntityAirBus.AdditionalColor); - Brush additionalBrush2 = new SolidBrush(Color.Black); - - // нос - Point point1 = new Point(startPosX + 74, startPosY + 15); - Point point2 = new Point(startPosX + 88, startPosY + 22); - Point point3 = new Point(startPosX + 74, startPosY + 27); - Point[] PointsNose = { point1, point2, point3 }; - - g.DrawPolygon(pen, PointsNose); - g.FillPolygon(additionalBrush, PointsNose); - - // хвост - Point point4 = new Point(startPosX + 4, startPosY + 17); - Point point5 = new Point(startPosX + 3, startPosY); - Point point6 = new Point(startPosX + 21, startPosY + 17); - - Point[] PointsTail = { point4, point5, point6 }; - g.DrawPolygon(pen, PointsTail); - g.FillPolygon(additionalBrush, PointsTail); - - // тело - g.DrawRectangle(pen, startPosX + 2, startPosY + 14, 72, 14); - g.FillRectangle(additionalBrush, startPosX + 2, startPosY + 14, 72, 14); - - //шасси - g.DrawEllipse(pen, startPosX + 21, startPosY + 30, 3, 3); - g.FillEllipse(additionalBrush, startPosX + 21, startPosY + 30, 3, 3); - - g.DrawEllipse(pen, startPosX + 25, startPosY + 30, 3, 3); - g.FillEllipse(additionalBrush, startPosX + 25, startPosY + 30, 3, 3); - - g.DrawEllipse(pen, startPosX + 70, startPosY + 30, 3, 3); - g.FillEllipse(additionalBrush, startPosX + 70, startPosY + 30, 3, 3); - - // Крыло - g.DrawEllipse(pen, startPosX + 24, startPosY + 20, 31, 4); - g.FillEllipse(additionalBrush, startPosX + 24, startPosY + 20, 31, 4); - - - // у хвоста - g.DrawEllipse(pen, startPosX, startPosY + 14, 14, 5); - g.FillEllipse(additionalBrush, startPosX, startPosY + 14, 14, 5); - - } - - public void ChangeBorders(int width, int height) - { - pictureWidht = width; - pictureHeight = height; - if (pictureWidht <= airbusWidth || pictureHeight <= airbusWidth) - { - pictureWidht = null; - pictureHeight = null; - return; - } - if ( startPosX + airbusWidth > pictureWidht) - { - startPosX = pictureWidht.Value - airbusWidth; - } - if ( startPosY + airbusHeight > pictureHeight) - { - startPosY = pictureHeight.Value - airbusHeight; - } - } - } -} diff --git a/Airbus/Drawnings/DrawningAirbus.cs b/Airbus/Drawnings/DrawningAirbus.cs new file mode 100644 index 0000000..73d7d20 --- /dev/null +++ b/Airbus/Drawnings/DrawningAirbus.cs @@ -0,0 +1,156 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectAirbus.Entities; + +namespace ProjectAirbus.Drawnings +{ + internal class DrawningAirbus + { + public EntityAirbus? EntityAirbus { get; protected set; } + private int _pictureWidth; + private int _pictureHeight; + + protected int _startPosX; + protected int _startPosY; + + protected readonly int _airbusWidth = 89; + protected readonly int _airbusHeight = 34; + + // доработки для интерфейса + public int GetPosX => _startPosX; + public int GetPosY => _startPosY; + public int GetWidth => _airbusWidth; + public int GetHeight => _airbusHeight; + + public DrawningAirbus(int speed, double weight, Color bodyColor, int + width, int height) + { + if (width < _airbusWidth || height < _airbusHeight) + { + return; + } + _pictureWidth = width; + _pictureHeight = height; + EntityAirbus = new EntityAirbus(speed, weight, bodyColor); + } + protected DrawningAirbus(int speed, double weight, Color bodyColor, int width, int height, int carWidth, int carHeight) + { + if (width < _airbusWidth || height < _airbusHeight) + { + return; + } + _pictureWidth = width; + _pictureHeight = height; + _airbusWidth = carWidth; + _airbusHeight = carHeight; + EntityAirbus = new EntityAirbus(speed, weight, bodyColor); + } + + // доработка для интерфейса + // проверка, что может переместиться + public bool CanMove(DirectionType direction) + { + if (EntityAirbus == null) + { + return false; + } + return direction switch + { + DirectionType.Left => _startPosX - EntityAirbus.Step > 0, + DirectionType.Up => _startPosY - EntityAirbus.Step > 0, + DirectionType.Right => _startPosX + _airbusWidth + EntityAirbus.Step < _pictureWidth, + DirectionType.Down => _startPosY + _airbusHeight + EntityAirbus.Step < _pictureHeight, + }; + } + + public void SetPosition(int x, int y) + { + if (x >= _pictureWidth || y >= _pictureHeight) + { + x = _pictureWidth - _airbusWidth; + y = _pictureHeight - _airbusHeight; + } + _startPosX = x; + _startPosY = y; + } + + public void MoveTransport(DirectionType direction) + { + if (!CanMove(direction) || EntityAirbus == null) + { + return; + } + switch (direction) + { + case DirectionType.Left: + _startPosX -= (int)EntityAirbus.Step; + break; + case DirectionType.Right: + _startPosX += (int)EntityAirbus.Step; + break; + case DirectionType.Up: + _startPosY -= (int)EntityAirbus.Step; + break; + case DirectionType.Down: + _startPosY += (int)EntityAirbus.Step; + break; + } + } + + // прорисовка + public virtual void DrawTransport(Graphics g) + { + if (EntityAirbus == null) + { + return; + } + Pen pen = new(Color.Black); + Brush bodyBrush = new SolidBrush(EntityAirbus.BodyColor); + Brush brYellow = new SolidBrush(Color.Yellow); + + // нос + Point point1 = new Point(_startPosX + 74, _startPosY + 15); + Point point2 = new Point(_startPosX + 88, _startPosY + 22); + Point point3 = new Point(_startPosX + 74, _startPosY + 27); + Point[] PointsNose = { point1, point2, point3 }; + + g.DrawPolygon(pen, PointsNose); + g.FillPolygon(brYellow, PointsNose); + + // хвост + Point point4 = new Point(_startPosX + 4, _startPosY + 17); + Point point5 = new Point(_startPosX + 3, _startPosY); + Point point6 = new Point(_startPosX + 21, _startPosY + 17); + + Point[] PointsTail = { point4, point5, point6 }; + g.DrawPolygon(pen, PointsTail); + g.FillPolygon(brYellow, PointsTail); + + // тело + g.DrawRectangle(pen, _startPosX + 2, _startPosY + 14, 72, 14); + g.FillRectangle(bodyBrush, _startPosX + 2, _startPosY + 14, 72, 14); + + //шасси + g.DrawEllipse(pen, _startPosX + 21, _startPosY + 30, 3, 3); + g.FillEllipse(brYellow, _startPosX + 21, _startPosY + 30, 3, 3); + + g.DrawEllipse(pen, _startPosX + 25, _startPosY + 30, 3, 3); + g.FillEllipse(brYellow, _startPosX + 25, _startPosY + 30, 3, 3); + + g.DrawEllipse(pen, _startPosX + 70, _startPosY + 30, 3, 3); + g.FillEllipse(brYellow, _startPosX + 70, _startPosY + 30, 3, 3); + + // Крыло + g.DrawEllipse(pen, _startPosX + 24, _startPosY + 20, 31, 4); + g.FillEllipse(brYellow, _startPosX + 24, _startPosY + 20, 31, 4); + + // двигатель у хвоста + g.DrawEllipse(pen, _startPosX, _startPosY + 14, 14, 5); + g.FillEllipse(brYellow, _startPosX, _startPosY + 14, 14, 5); + } + + } +} diff --git a/Airbus/Drawnings/DrawningPlane.cs b/Airbus/Drawnings/DrawningPlane.cs new file mode 100644 index 0000000..7cb7fe5 --- /dev/null +++ b/Airbus/Drawnings/DrawningPlane.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectAirbus.Entities; + +namespace ProjectAirbus.Drawnings +{ + internal class DrawningPlane : DrawningAirbus + { + public DrawningPlane(int speed, double weight, Color bodyColor, Color additionalColor,bool isCompartment, bool isAdditionalEngine, int width, int height) : + base (speed, weight, bodyColor, width, height, 110, 60) + { + if (EntityAirbus != null) + { + EntityAirbus = new EntityPlane(speed, weight, bodyColor, additionalColor, isCompartment, isAdditionalEngine); + } + } + + public override void DrawTransport(Graphics g) + { + if (EntityAirbus is not EntityPlane superAirbus) + { + return; + } + Pen pen = new(Color.Black); + Brush bodyBrush = new SolidBrush(EntityAirbus.BodyColor); + Brush additionalBrush = new SolidBrush(superAirbus.AdditionalColor); + + // доп отсек + if (superAirbus.IsCompartment) + { + g.DrawEllipse(pen, _startPosX + 51, _startPosY + 10, 24, 10); + g.FillEllipse(bodyBrush, _startPosX + 51, _startPosY + 10, 24, 10); + } + + base.DrawTransport(g); + + // доп двигатель + if (superAirbus.IsAdditionalEngine) + { + g.DrawEllipse(pen, _startPosX, _startPosY + 20, 11, 5); + g.FillEllipse(additionalBrush, _startPosX, _startPosY + 20, 11, 5); + } + } + } +} diff --git a/Airbus/Direction.cs b/Airbus/Entities/DirectionType.cs similarity index 76% rename from Airbus/Direction.cs rename to Airbus/Entities/DirectionType.cs index a8f3c2a..6772442 100644 --- a/Airbus/Direction.cs +++ b/Airbus/Entities/DirectionType.cs @@ -4,9 +4,9 @@ using System.Linq; using System.Text; using System.Threading.Tasks; -namespace AirBus +namespace ProjectAirbus.Entities { - public enum Direction + public enum DirectionType { Up = 1, Down = 2, diff --git a/Airbus/Entities/EntityAirbus.cs b/Airbus/Entities/EntityAirbus.cs new file mode 100644 index 0000000..a2007f8 --- /dev/null +++ b/Airbus/Entities/EntityAirbus.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAirbus.Entities +{ + internal class EntityAirbus + { + public int Speed { get; private set; } + public double Weight { get; private set; } + public Color BodyColor { get; private set; } + + public double Step => (double)Speed * 100 / Weight; + public EntityAirbus(int speed, double weight, Color bodyColor) + { + Speed = speed; + Weight = weight; + BodyColor = bodyColor; + } + } +} diff --git a/Airbus/Entities/EntityPlane.cs b/Airbus/Entities/EntityPlane.cs new file mode 100644 index 0000000..165c56b --- /dev/null +++ b/Airbus/Entities/EntityPlane.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAirbus.Entities +{ + internal class EntityPlane : EntityAirbus + { + public Color AdditionalColor { get; private set; } + public bool IsCompartment { get; private set; } + public bool IsAdditionalEngine { get; private set; } + + public EntityPlane(int speed, double weight, Color bodyColor, Color additionalColor, bool isCompartment, bool isAdditionalEngine) : + base(speed, weight, bodyColor) + { + AdditionalColor = additionalColor; + IsCompartment = isCompartment; + IsAdditionalEngine = isAdditionalEngine; + } + } +} diff --git a/Airbus/EntityAirbus.cs b/Airbus/EntityAirbus.cs deleted file mode 100644 index 005e64d..0000000 --- a/Airbus/EntityAirbus.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace AirBus -{ - public class EntityAirBus - { - // Скорость - public int Speed { get; private set; } - - // Вес - public double Weight { get; private set; } - - // основной цвет - public Color BodyColor { get; private set; } - - // доп. цвет - public Color AdditionalColor { get; private set; } - - // наличие доп отсека для пассажиров - public bool IsCompartment { get; private set; } - - // наличие доп двигателей - public bool IsAdditionalEngine { get; private set; } - - // шаг перемещения - public double Step => (double)Speed * 100 / Weight; - - public void Init (int speed, double weight, Color bodyColor, Color additionalColor, bool isCompartment, bool isAdditionalEngine) - { - Speed = speed; - Weight = weight; - BodyColor = bodyColor; - AdditionalColor = additionalColor; - IsCompartment = isCompartment; - IsAdditionalEngine = isAdditionalEngine; - } - } -} diff --git a/Airbus/FormAirbus.Designer.cs b/Airbus/FormAirbus.Designer.cs index 47253cb..c97f636 100644 --- a/Airbus/FormAirbus.Designer.cs +++ b/Airbus/FormAirbus.Designer.cs @@ -1,4 +1,4 @@ -namespace Airbus +namespace ProjectAirbus { partial class FormAirbus { @@ -29,117 +29,160 @@ private void InitializeComponent() { System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormAirbus)); - pictureAirbus = new PictureBox(); - buttonUp = new Button(); - buttonLeft = new Button(); - buttonDown = new Button(); - buttonRight = new Button(); - buttonCreate = new Button(); - ((System.ComponentModel.ISupportInitialize)pictureAirbus).BeginInit(); + pictureAirBus=new PictureBox(); + buttonUp=new Button(); + buttonLeft=new Button(); + buttonDown=new Button(); + buttonRight=new Button(); + buttonCreate=new Button(); + buttonCreateSuperAirbus=new Button(); + buttonStep=new Button(); + comboBoxStrategy=new ComboBox(); + ((System.ComponentModel.ISupportInitialize)pictureAirBus).BeginInit(); SuspendLayout(); // - // pictureAirbus + // pictureAirBus // - pictureAirbus.Dock = DockStyle.Fill; - pictureAirbus.Location = new Point(0, 0); - pictureAirbus.Name = "pictureAirbus"; - pictureAirbus.Size = new Size(800, 450); - pictureAirbus.SizeMode = PictureBoxSizeMode.AutoSize; - pictureAirbus.TabIndex = 0; - pictureAirbus.TabStop = false; + pictureAirBus.Dock=DockStyle.Fill; + pictureAirBus.Location=new Point(0, 0); + pictureAirBus.Name="pictureAirBus"; + pictureAirBus.Size=new Size(790, 410); + pictureAirBus.SizeMode=PictureBoxSizeMode.AutoSize; + pictureAirBus.TabIndex=0; + pictureAirBus.TabStop=false; // // buttonUp // - buttonUp.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonUp.BackgroundImage = (Image)resources.GetObject("buttonUp.BackgroundImage"); - buttonUp.BackgroundImageLayout = ImageLayout.Zoom; - buttonUp.FlatAppearance.BorderColor = Color.Black; - buttonUp.FlatAppearance.BorderSize = 7; - buttonUp.Location = new Point(679, 313); - buttonUp.Name = "buttonUp"; - buttonUp.Size = new Size(48, 44); - buttonUp.TabIndex = 1; - buttonUp.UseVisualStyleBackColor = true; - buttonUp.Click += buttonMove_Click; + buttonUp.Anchor=AnchorStyles.Bottom|AnchorStyles.Right; + buttonUp.BackgroundImage=(Image)resources.GetObject("buttonUp.BackgroundImage"); + buttonUp.BackgroundImageLayout=ImageLayout.Stretch; + buttonUp.FlatAppearance.BorderColor=Color.Black; + buttonUp.FlatAppearance.BorderSize=7; + buttonUp.Location=new Point(679, 309); + buttonUp.Name="buttonUp"; + buttonUp.Size=new Size(48, 44); + buttonUp.TabIndex=1; + buttonUp.UseVisualStyleBackColor=true; + buttonUp.Click+=buttonMove_Click; // // buttonLeft // - buttonLeft.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonLeft.BackgroundImage = (Image)resources.GetObject("buttonLeft.BackgroundImage"); - buttonLeft.BackgroundImageLayout = ImageLayout.Zoom; - buttonLeft.FlatAppearance.BorderColor = Color.Black; - buttonLeft.FlatAppearance.BorderSize = 7; - buttonLeft.Location = new Point(630, 358); - buttonLeft.Name = "buttonLeft"; - buttonLeft.Size = new Size(48, 44); - buttonLeft.TabIndex = 2; - buttonLeft.UseVisualStyleBackColor = true; - buttonLeft.Click += buttonMove_Click; + buttonLeft.Anchor=AnchorStyles.Bottom|AnchorStyles.Right; + buttonLeft.BackColor=SystemColors.Control; + buttonLeft.BackgroundImage=(Image)resources.GetObject("buttonLeft.BackgroundImage"); + buttonLeft.BackgroundImageLayout=ImageLayout.Stretch; + buttonLeft.FlatAppearance.BorderColor=Color.Black; + buttonLeft.FlatAppearance.BorderSize=7; + buttonLeft.Location=new Point(630, 354); + buttonLeft.Name="buttonLeft"; + buttonLeft.Size=new Size(48, 44); + buttonLeft.TabIndex=2; + buttonLeft.UseVisualStyleBackColor=false; + buttonLeft.Click+=buttonMove_Click; // // buttonDown // - buttonDown.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonDown.BackgroundImage = (Image)resources.GetObject("buttonDown.BackgroundImage"); - buttonDown.BackgroundImageLayout = ImageLayout.Zoom; - buttonDown.FlatAppearance.BorderColor = Color.Black; - buttonDown.FlatAppearance.BorderSize = 7; - buttonDown.Location = new Point(679, 358); - buttonDown.Name = "buttonDown"; - buttonDown.Size = new Size(48, 44); - buttonDown.TabIndex = 3; - buttonDown.UseVisualStyleBackColor = true; - buttonDown.Click += buttonMove_Click; + buttonDown.Anchor=AnchorStyles.Bottom|AnchorStyles.Right; + buttonDown.BackgroundImage=(Image)resources.GetObject("buttonDown.BackgroundImage"); + buttonDown.BackgroundImageLayout=ImageLayout.Stretch; + buttonDown.FlatAppearance.BorderColor=Color.Black; + buttonDown.FlatAppearance.BorderSize=7; + buttonDown.Location=new Point(679, 354); + buttonDown.Name="buttonDown"; + buttonDown.Size=new Size(48, 44); + buttonDown.TabIndex=3; + buttonDown.UseVisualStyleBackColor=true; + buttonDown.Click+=buttonMove_Click; // // buttonRight // - buttonRight.Anchor = AnchorStyles.Bottom | AnchorStyles.Right; - buttonRight.BackgroundImage = (Image)resources.GetObject("buttonRight.BackgroundImage"); - buttonRight.BackgroundImageLayout = ImageLayout.Zoom; - buttonRight.FlatAppearance.BorderColor = Color.Black; - buttonRight.FlatAppearance.BorderSize = 7; - buttonRight.Location = new Point(728, 358); - buttonRight.Name = "buttonRight"; - buttonRight.Size = new Size(48, 44); - buttonRight.TabIndex = 4; - buttonRight.UseVisualStyleBackColor = true; - buttonRight.Click += buttonMove_Click; + buttonRight.Anchor=AnchorStyles.Bottom|AnchorStyles.Right; + buttonRight.BackgroundImage=(Image)resources.GetObject("buttonRight.BackgroundImage"); + buttonRight.BackgroundImageLayout=ImageLayout.Stretch; + buttonRight.FlatAppearance.BorderColor=Color.Black; + buttonRight.FlatAppearance.BorderSize=7; + buttonRight.Location=new Point(728, 354); + buttonRight.Name="buttonRight"; + buttonRight.Size=new Size(48, 44); + buttonRight.TabIndex=4; + buttonRight.UseVisualStyleBackColor=true; + buttonRight.Click+=buttonMove_Click; // // buttonCreate // - buttonCreate.Anchor = AnchorStyles.Bottom | AnchorStyles.Left; - buttonCreate.Location = new Point(12, 387); - buttonCreate.Name = "buttonCreate"; - buttonCreate.Size = new Size(81, 51); - buttonCreate.TabIndex = 5; - buttonCreate.Text = "Создать"; - buttonCreate.UseVisualStyleBackColor = true; - buttonCreate.Click += buttonCreate_Click; + buttonCreate.Anchor=AnchorStyles.Bottom|AnchorStyles.Left; + buttonCreate.Location=new Point(12, 347); + buttonCreate.Name="buttonCreate"; + buttonCreate.Size=new Size(128, 51); + buttonCreate.TabIndex=5; + buttonCreate.Text="Создать самолёт"; + buttonCreate.UseVisualStyleBackColor=true; + buttonCreate.Click+=buttonCreate_Click; // - // FormAirbus + // buttonCreateSuperAirbus // - AutoScaleDimensions = new SizeF(7F, 15F); - AutoScaleMode = AutoScaleMode.Font; - ClientSize = new Size(800, 450); + buttonCreateSuperAirbus.Anchor=AnchorStyles.Bottom|AnchorStyles.Left; + buttonCreateSuperAirbus.Location=new Point(146, 347); + buttonCreateSuperAirbus.Name="buttonCreateSuperAirbus"; + buttonCreateSuperAirbus.Size=new Size(127, 51); + buttonCreateSuperAirbus.TabIndex=6; + buttonCreateSuperAirbus.Text="Создать суперсамолёт"; + buttonCreateSuperAirbus.UseVisualStyleBackColor=true; + buttonCreateSuperAirbus.Click+=buttonCreateSuperAirbus_Click; + // + // buttonStep + // + buttonStep.Anchor=AnchorStyles.Top|AnchorStyles.Right; + buttonStep.Location=new Point(671, 51); + buttonStep.Name="buttonStep"; + buttonStep.Size=new Size(105, 37); + buttonStep.TabIndex=7; + buttonStep.Text="Шаг"; + buttonStep.UseVisualStyleBackColor=true; + buttonStep.Click+=buttonStep_Click; + // + // comboBoxStrategy + // + comboBoxStrategy.Anchor=AnchorStyles.Top|AnchorStyles.Right; + comboBoxStrategy.DropDownStyle=ComboBoxStyle.DropDownList; + comboBoxStrategy.FormattingEnabled=true; + comboBoxStrategy.Items.AddRange(new object[] { "1", "2" }); + comboBoxStrategy.Location=new Point(622, 22); + comboBoxStrategy.Name="comboBoxStrategy"; + comboBoxStrategy.Size=new Size(156, 23); + comboBoxStrategy.TabIndex=8; + // + // Form1 + // + AutoScaleDimensions=new SizeF(7F, 15F); + AutoScaleMode=AutoScaleMode.Font; + ClientSize=new Size(790, 410); + Controls.Add(comboBoxStrategy); + Controls.Add(buttonStep); + Controls.Add(buttonCreateSuperAirbus); Controls.Add(buttonCreate); Controls.Add(buttonRight); Controls.Add(buttonDown); Controls.Add(buttonLeft); Controls.Add(buttonUp); - Controls.Add(pictureAirbus); - Name = "FormAirbus"; - Text = "FormAirbus"; - ((System.ComponentModel.ISupportInitialize)pictureAirbus).EndInit(); + Controls.Add(pictureAirBus); + Name="Form1"; + Text="FormAirbus"; + ((System.ComponentModel.ISupportInitialize)pictureAirBus).EndInit(); ResumeLayout(false); PerformLayout(); } #endregion - private PictureBox pictureAirbus; + private PictureBox pictureAirBus; private Button buttonUp; private Button buttonLeft; private Button buttonDown; private Button buttonRight; private Button buttonCreate; + private Button buttonCreateSuperAirbus; + private Button buttonStep; + private ComboBox comboBoxStrategy; } } \ No newline at end of file diff --git a/Airbus/FormAirbus.cs b/Airbus/FormAirbus.cs index 81cab01..01728ac 100644 --- a/Airbus/FormAirbus.cs +++ b/Airbus/FormAirbus.cs @@ -1,42 +1,77 @@ -namespace Airbus +using ProjectAirbus.Drawnings; +using ProjectAirbus.MovementStrategy; +using ProjectAirbus.Entities; + +namespace ProjectAirbus { public partial class FormAirbus : Form { - - // поле-объект для прористовки самолёта private DrawningAirbus? _drawningAirbus; + private AbstractStrategy? _abstractStrategy; + public FormAirbus() { InitializeComponent(); } - // прорисовка самолёта + // прорисовка самолёта private void Draw() { if (_drawningAirbus == null) { return; } - Bitmap bmp = new(pictureAirbus.Width, pictureAirbus.Height); + Bitmap bmp = new(pictureAirBus.Width, pictureAirBus.Height); Graphics g = Graphics.FromImage(bmp); _drawningAirbus.DrawTransport(g); - pictureAirbus.Image = bmp; + pictureAirBus.Image = bmp; } - // кнопка "Создать" + private void buttonDown_Click(object sender, EventArgs e) + { + buttonMove_Click(sender, e); + } + + private void buttonUp_Click(object sender, EventArgs e) + { + buttonMove_Click(sender, e); + } + + private void buttonRight_Click(object sender, EventArgs e) + { + buttonMove_Click(sender, e); + } + + private void buttonLeft_Click(object sender, EventArgs e) + { + buttonMove_Click(sender, e); + } + + // кнопка "Создать самолёт" private void buttonCreate_Click(object sender, EventArgs e) { Random random = new Random(); - _drawningAirbus = new DrawningAirbus(); - _drawningAirbus.Init(random.Next(100, 300), random.Next(1000, 3000), + _drawningAirbus = new DrawningAirbus(random.Next(200, 400), random.Next(1000, 3000), + Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), + pictureAirBus.Width, pictureAirBus.Height); + + _drawningAirbus.SetPosition(random.Next(10, 200), random.Next(10, 200)); + Draw(); + + } + + // кнопка "Создать суперсамолёт" + private void buttonCreateSuperAirbus_Click(object sender, EventArgs e) + { + Random random = new Random(); + _drawningAirbus = new DrawningPlane(random.Next(200, 400), random.Next(1000, 3000), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Color.FromArgb(random.Next(0, 256), random.Next(0, 256), random.Next(0, 256)), Convert.ToBoolean(random.Next(0, 2)), Convert.ToBoolean(random.Next(0, 2)), - pictureAirbus.Width, pictureAirbus.Height); + pictureAirBus.Width, pictureAirBus.Height); - _drawningAirbus.SetPosition(random.Next(10,100), random.Next(10,100)); + _drawningAirbus.SetPosition(random.Next(10, 200), random.Next(10, 200)); Draw(); - } private void buttonMove_Click(object sender, EventArgs e) @@ -49,15 +84,52 @@ namespace Airbus switch (name) { case "buttonUp": - _drawningAirbus.MoveTransport(Direction.Up); break; + _drawningAirbus.MoveTransport(DirectionType.Up); break; case "buttonDown": - _drawningAirbus.MoveTransport(Direction.Down); break; + _drawningAirbus.MoveTransport(DirectionType.Down); break; case "buttonLeft": - _drawningAirbus.MoveTransport(Direction.Left); break; + _drawningAirbus.MoveTransport(DirectionType.Left); break; case "buttonRight": - _drawningAirbus.MoveTransport(Direction.Right); break; + _drawningAirbus.MoveTransport(DirectionType.Right); break; } Draw(); } + + // Кнопка "Шаг" + private void buttonStep_Click(object sender, EventArgs e) + { + if (_drawningAirbus == null) + { + return; + } + if (comboBoxStrategy.Enabled) + { + _abstractStrategy = comboBoxStrategy.SelectedIndex + switch + { + 0 => new MoveToCenter(), + 1 => new MoveToBorder(), + _ => null, + }; + if (_abstractStrategy == null) + { + return; + } + _abstractStrategy.SetData(new DrawningObjectAirbus(_drawningAirbus), pictureAirBus.Width, pictureAirBus.Height); + comboBoxStrategy.Enabled = false; + } + if (_abstractStrategy == null) + { + return; + } + _abstractStrategy.MakeStep(); + Draw(); + if (_abstractStrategy.GetStatus() == Status.Finish) + { + comboBoxStrategy.Enabled = true; + _abstractStrategy = null; + } + } + } } \ No newline at end of file diff --git a/Airbus/FormAirbus.resx b/Airbus/FormAirbus.resx index c02d9d9..2d6ab17 100644 ---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zsbGyg + W3trKBFCRxRRqAqIiqFVVAAAAAAFadFFAH//2Q== diff --git a/Airbus/MovementStrategy/AbstractStrategy.cs b/Airbus/MovementStrategy/AbstractStrategy.cs new file mode 100644 index 0000000..2cb8b9f --- /dev/null +++ b/Airbus/MovementStrategy/AbstractStrategy.cs @@ -0,0 +1,89 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectAirbus.Drawnings; +using ProjectAirbus.Entities; + +namespace ProjectAirbus.MovementStrategy +{ + internal abstract class AbstractStrategy + { + // объект + private IMoveableObject? _moveableObject; + // статус + private Status _state = Status.NotInit; + // границы окна + protected int FieldWidth { get; private set; } + protected int FieldHeight { get; private set; } + public Status GetStatus() { return _state; } + + // Изменить статус, установить поля + public void SetData(IMoveableObject moveableObject, int width, int height) + { + if (moveableObject == null) + { + _state = Status.NotInit; + return; + } + _state = Status.InProgress; + _moveableObject = moveableObject; + FieldWidth = width; + FieldHeight = height; + } + + // сделать шаг + public void MakeStep() + { + if (_state != Status.InProgress) + { + return; + } + if (IsTargetDestination()) + { + _state = Status.Finish; + return; + } + MoveToTarget(); + } + + // перемещения + protected bool MoveLeft() => MoveTo(DirectionType.Left); + protected bool MoveRight() => MoveTo(DirectionType.Right); + protected bool MoveUp() => MoveTo(DirectionType.Up); + protected bool MoveDown() => MoveTo(DirectionType.Down); + + // параметры + protected ObjectParameters? GetObjectParameters => _moveableObject?.GetObjectPosition; + // шаг + protected int? GetStep() + { + if (_state != Status.InProgress) + { + return null; + } + return _moveableObject?.GetStep; + } + // перемещение + protected abstract void MoveToTarget(); + + // достигнута ли цель + protected abstract bool IsTargetDestination(); + + // попытка перемещения по направлению + private bool MoveTo(DirectionType directionType) + { + if (_state != Status.InProgress) + { + return false; + } + if (_moveableObject?.CheckCanMove(directionType) ?? false) + { + _moveableObject.MoveObject(directionType); + return true; + } + return false; + } + } +} diff --git a/Airbus/MovementStrategy/DrawningObjectAirbus.cs b/Airbus/MovementStrategy/DrawningObjectAirbus.cs new file mode 100644 index 0000000..2a60ee1 --- /dev/null +++ b/Airbus/MovementStrategy/DrawningObjectAirbus.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using ProjectAirbus.Drawnings; +using ProjectAirbus.Entities; + +namespace ProjectAirbus.MovementStrategy +{ + internal class DrawningObjectAirbus : IMoveableObject + { + private readonly DrawningAirbus? _drawningAirbus = null; + + public DrawningObjectAirbus(DrawningAirbus drawningAirbus) + { + _drawningAirbus = drawningAirbus; + } + + public ObjectParameters? GetObjectPosition + { + get + { + if (_drawningAirbus == null || _drawningAirbus.EntityAirbus == null) + { + return null; + } + return new ObjectParameters(_drawningAirbus.GetPosX, _drawningAirbus.GetPosY, _drawningAirbus.GetWidth, _drawningAirbus.GetHeight); + } + } + + public int GetStep => (int)(_drawningAirbus?.EntityAirbus?.Step ?? 0); + + + public bool CheckCanMove(DirectionType direction) => _drawningAirbus?.CanMove(direction) ?? false; + + public void MoveObject(DirectionType direction) => _drawningAirbus?.MoveTransport(direction); + } +} diff --git a/Airbus/MovementStrategy/IMoveableObject.cs b/Airbus/MovementStrategy/IMoveableObject.cs new file mode 100644 index 0000000..116baca --- /dev/null +++ b/Airbus/MovementStrategy/IMoveableObject.cs @@ -0,0 +1,15 @@ +using ProjectAirbus.Drawnings; +using ProjectAirbus.Entities; + +namespace ProjectAirbus.MovementStrategy +{ + internal interface IMoveableObject + { + ObjectParameters? GetObjectPosition { get; } + + int GetStep { get; } + bool CheckCanMove(DirectionType direction); + void MoveObject(DirectionType direction); + + } +} diff --git a/Airbus/MovementStrategy/MoveToBorder.cs b/Airbus/MovementStrategy/MoveToBorder.cs new file mode 100644 index 0000000..8ec837d --- /dev/null +++ b/Airbus/MovementStrategy/MoveToBorder.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAirbus.MovementStrategy +{ + internal class MoveToBorder : AbstractStrategy + { + + // достигнута ли цель + protected override bool IsTargetDestination() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.RightBorder <= FieldWidth && + objParams.RightBorder + GetStep() >= FieldWidth && + objParams.DownBorder <= FieldHeight && + objParams.DownBorder + GetStep() >= FieldHeight; + } + + // движение к цели + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + var diffX = FieldWidth; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX < 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + + var diffY = FieldHeight; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY < 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } + } +} diff --git a/Airbus/MovementStrategy/MoveToCenter.cs b/Airbus/MovementStrategy/MoveToCenter.cs new file mode 100644 index 0000000..315f71c --- /dev/null +++ b/Airbus/MovementStrategy/MoveToCenter.cs @@ -0,0 +1,59 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAirbus.MovementStrategy +{ + internal class MoveToCenter : AbstractStrategy + { + // достигнута ли цель + protected override bool IsTargetDestination() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return false; + } + return objParams.ObjectMiddleHorizontal <= FieldWidth / 2 && + objParams.ObjectMiddleHorizontal + GetStep() >= FieldWidth / 2 && + objParams.ObjectMiddleVertical <= FieldHeight / 2 && + objParams.ObjectMiddleVertical + GetStep() >= FieldHeight / 2; + } + + protected override void MoveToTarget() + { + var objParams = GetObjectParameters; + if (objParams == null) + { + return; + } + var diffX = objParams.ObjectMiddleHorizontal - FieldWidth / 2; + if (Math.Abs(diffX) > GetStep()) + { + if (diffX > 0) + { + MoveLeft(); + } + else + { + MoveRight(); + } + } + + var diffY = objParams.ObjectMiddleVertical - FieldHeight / 2; + if (Math.Abs(diffY) > GetStep()) + { + if (diffY > 0) + { + MoveUp(); + } + else + { + MoveDown(); + } + } + } + } +} diff --git a/Airbus/MovementStrategy/ObjectParameters.cs b/Airbus/MovementStrategy/ObjectParameters.cs new file mode 100644 index 0000000..1e898fc --- /dev/null +++ b/Airbus/MovementStrategy/ObjectParameters.cs @@ -0,0 +1,27 @@ +namespace ProjectAirbus.MovementStrategy +{ + internal class ObjectParameters + { + private readonly int _x; + private readonly int _y; + private readonly int _width; + private readonly int _height; + + // границы + public int LeftBorder => _x; + public int TopBorder => _y; + public int RightBorder => _x + _width; + public int DownBorder => _y + _height; + // середина + public int ObjectMiddleHorizontal => _x + _width / 2; + public int ObjectMiddleVertical => _y + _height / 2; + + public ObjectParameters(int x, int y, int width, int height) + { + _x = x; + _y = y; + _width = width; + _height = height; + } + } +} diff --git a/Airbus/MovementStrategy/Status.cs b/Airbus/MovementStrategy/Status.cs new file mode 100644 index 0000000..4662adf --- /dev/null +++ b/Airbus/MovementStrategy/Status.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace ProjectAirbus.MovementStrategy +{ + internal enum Status + { + NotInit, + InProgress, + Finish + } +} diff --git a/Airbus/Program.cs b/Airbus/Program.cs index 618767c..9d45ae4 100644 --- a/Airbus/Program.cs +++ b/Airbus/Program.cs @@ -1,4 +1,4 @@ -namespace AirBus +namespace ProjectAirbus { internal static class Program { @@ -11,7 +11,7 @@ namespace AirBus // To customize application configuration such as set high DPI settings or default font, // see https://aka.ms/applicationconfiguration. ApplicationConfiguration.Initialize(); - Application.Run(new FormAirBus()); + Application.Run(new FormAirbus()); } } } \ No newline at end of file diff --git a/Airbus/Airbus.csproj b/Airbus/ProjectAirbus.csproj similarity index 100% rename from Airbus/Airbus.csproj rename to Airbus/ProjectAirbus.csproj diff --git a/Airbus/Properties/Resources.Designer.cs b/Airbus/Properties/Resources.Designer.cs index 9feedfc..2733094 100644 --- a/Airbus/Properties/Resources.Designer.cs +++ b/Airbus/Properties/Resources.Designer.cs @@ -8,7 +8,7 @@ // //------------------------------------------------------------------------------ -namespace AirBus.Properties { +namespace ProjectAirbus.Properties { using System; @@ -39,7 +39,7 @@ namespace AirBus.Properties { internal static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { - global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("AirBus.Properties.Resources", typeof(Resources).Assembly); + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ProjectAirbus.Properties.Resources", typeof(Resources).Assembly); resourceMan = temp; } return resourceMan; -- 2.25.1