├── .gitignore
├── README.md
├── Resouces
├── add.wav
├── blast.wav
├── blast1.gif
├── blast2.gif
├── blast3.gif
├── blast4.gif
├── blast5.gif
├── blast6.gif
├── blast7.gif
├── blast8.gif
├── bomb.gif
├── enemy1D.gif
├── enemy1L.gif
├── enemy1R.gif
├── enemy1U.gif
├── enemy2D.gif
├── enemy2L.gif
├── enemy2R.gif
├── enemy2U.gif
├── enemy3D.gif
├── enemy3L.gif
├── enemy3R.gif
├── enemy3U.gif
├── enemymissile.gif
├── fire.wav
├── hit.wav
├── p1tankD.gif
├── p1tankL.gif
├── p1tankR.gif
├── p1tankU.gif
├── star.gif
├── start.wav
├── tankmissile.gif
├── timer.gif
└── wall.gif
└── TankGameV1.0
└── TankGame
├── TankGame.sln
└── TankGame
├── App.config
├── Boom.cs
├── ClassDiagram1.cd
├── EnemyTank.cs
├── EnemyZD.cs
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── GameObject.cs
├── PlayerTank.cs
├── PlayerZD.cs
├── Program.cs
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── Resources
├── add.wav
├── blast.wav
├── blast1.gif
├── blast2.gif
├── blast3.gif
├── blast4.gif
├── blast5.gif
├── blast6.gif
├── blast7.gif
├── blast8.gif
├── bomb.gif
├── born1.gif
├── born2.gif
├── born3.gif
├── born4.gif
├── enemy1D.gif
├── enemy1L.gif
├── enemy1R.gif
├── enemy1U.gif
├── enemy2D.gif
├── enemy2L.gif
├── enemy2R.gif
├── enemy2U.gif
├── enemy3D.gif
├── enemy3L.gif
├── enemy3R.gif
├── enemy3U.gif
├── enemymissile.gif
├── fire.wav
├── hit.wav
├── p1tankD.gif
├── p1tankL.gif
├── p1tankR.gif
├── p1tankU.gif
├── star.gif
├── start.wav
├── tankmissile.gif
├── timer.gif
└── wall.gif
├── SingleObject.cs
├── TankBorn.cs
├── TankFather.cs
├── TankGame.csproj
├── Wall.cs
├── Zhuangbei.cs
├── ZiDanFather.cs
├── image.cs
└── soundPlayer.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015/2017 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # Visual Studio 2017 auto generated files
33 | Generated\ Files/
34 |
35 | # MSTest test Results
36 | [Tt]est[Rr]esult*/
37 | [Bb]uild[Ll]og.*
38 |
39 | # NUNIT
40 | *.VisualState.xml
41 | TestResult.xml
42 |
43 | # Build Results of an ATL Project
44 | [Dd]ebugPS/
45 | [Rr]eleasePS/
46 | dlldata.c
47 |
48 | # Benchmark Results
49 | BenchmarkDotNet.Artifacts/
50 |
51 | # .NET Core
52 | project.lock.json
53 | project.fragment.lock.json
54 | artifacts/
55 | **/Properties/launchSettings.json
56 |
57 | # StyleCop
58 | StyleCopReport.xml
59 |
60 | # Files built by Visual Studio
61 | *_i.c
62 | *_p.c
63 | *_i.h
64 | *.ilk
65 | *.meta
66 | *.obj
67 | *.iobj
68 | *.pch
69 | *.pdb
70 | *.ipdb
71 | *.pgc
72 | *.pgd
73 | *.rsp
74 | *.sbr
75 | *.tlb
76 | *.tli
77 | *.tlh
78 | *.tmp
79 | *.tmp_proj
80 | *.log
81 | *.vspscc
82 | *.vssscc
83 | .builds
84 | *.pidb
85 | *.svclog
86 | *.scc
87 |
88 | # Chutzpah Test files
89 | _Chutzpah*
90 |
91 | # Visual C++ cache files
92 | ipch/
93 | *.aps
94 | *.ncb
95 | *.opendb
96 | *.opensdf
97 | *.sdf
98 | *.cachefile
99 | *.VC.db
100 | *.VC.VC.opendb
101 |
102 | # Visual Studio profiler
103 | *.psess
104 | *.vsp
105 | *.vspx
106 | *.sap
107 |
108 | # Visual Studio Trace Files
109 | *.e2e
110 |
111 | # TFS 2012 Local Workspace
112 | $tf/
113 |
114 | # Guidance Automation Toolkit
115 | *.gpState
116 |
117 | # ReSharper is a .NET coding add-in
118 | _ReSharper*/
119 | *.[Rr]e[Ss]harper
120 | *.DotSettings.user
121 |
122 | # JustCode is a .NET coding add-in
123 | .JustCode
124 |
125 | # TeamCity is a build add-in
126 | _TeamCity*
127 |
128 | # DotCover is a Code Coverage Tool
129 | *.dotCover
130 |
131 | # AxoCover is a Code Coverage Tool
132 | .axoCover/*
133 | !.axoCover/settings.json
134 |
135 | # Visual Studio code coverage results
136 | *.coverage
137 | *.coveragexml
138 |
139 | # NCrunch
140 | _NCrunch_*
141 | .*crunch*.local.xml
142 | nCrunchTemp_*
143 |
144 | # MightyMoose
145 | *.mm.*
146 | AutoTest.Net/
147 |
148 | # Web workbench (sass)
149 | .sass-cache/
150 |
151 | # Installshield output folder
152 | [Ee]xpress/
153 |
154 | # DocProject is a documentation generator add-in
155 | DocProject/buildhelp/
156 | DocProject/Help/*.HxT
157 | DocProject/Help/*.HxC
158 | DocProject/Help/*.hhc
159 | DocProject/Help/*.hhk
160 | DocProject/Help/*.hhp
161 | DocProject/Help/Html2
162 | DocProject/Help/html
163 |
164 | # Click-Once directory
165 | publish/
166 |
167 | # Publish Web Output
168 | *.[Pp]ublish.xml
169 | *.azurePubxml
170 | # Note: Comment the next line if you want to checkin your web deploy settings,
171 | # but database connection strings (with potential passwords) will be unencrypted
172 | *.pubxml
173 | *.publishproj
174 |
175 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
176 | # checkin your Azure Web App publish settings, but sensitive information contained
177 | # in these scripts will be unencrypted
178 | PublishScripts/
179 |
180 | # NuGet Packages
181 | *.nupkg
182 | # The packages folder can be ignored because of Package Restore
183 | **/[Pp]ackages/*
184 | # except build/, which is used as an MSBuild target.
185 | !**/[Pp]ackages/build/
186 | # Uncomment if necessary however generally it will be regenerated when needed
187 | #!**/[Pp]ackages/repositories.config
188 | # NuGet v3's project.json files produces more ignorable files
189 | *.nuget.props
190 | *.nuget.targets
191 |
192 | # Microsoft Azure Build Output
193 | csx/
194 | *.build.csdef
195 |
196 | # Microsoft Azure Emulator
197 | ecf/
198 | rcf/
199 |
200 | # Windows Store app package directories and files
201 | AppPackages/
202 | BundleArtifacts/
203 | Package.StoreAssociation.xml
204 | _pkginfo.txt
205 | *.appx
206 |
207 | # Visual Studio cache files
208 | # files ending in .cache can be ignored
209 | *.[Cc]ache
210 | # but keep track of directories ending in .cache
211 | !*.[Cc]ache/
212 |
213 | # Others
214 | ClientBin/
215 | ~$*
216 | *~
217 | *.dbmdl
218 | *.dbproj.schemaview
219 | *.jfm
220 | *.pfx
221 | *.publishsettings
222 | orleans.codegen.cs
223 |
224 | # Including strong name files can present a security risk
225 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
226 | #*.snk
227 |
228 | # Since there are multiple workflows, uncomment next line to ignore bower_components
229 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
230 | #bower_components/
231 |
232 | # RIA/Silverlight projects
233 | Generated_Code/
234 |
235 | # Backup & report files from converting an old project file
236 | # to a newer Visual Studio version. Backup files are not needed,
237 | # because we have git ;-)
238 | _UpgradeReport_Files/
239 | Backup*/
240 | UpgradeLog*.XML
241 | UpgradeLog*.htm
242 | ServiceFabricBackup/
243 | *.rptproj.bak
244 |
245 | # SQL Server files
246 | *.mdf
247 | *.ldf
248 | *.ndf
249 |
250 | # Business Intelligence projects
251 | *.rdl.data
252 | *.bim.layout
253 | *.bim_*.settings
254 | *.rptproj.rsuser
255 |
256 | # Microsoft Fakes
257 | FakesAssemblies/
258 |
259 | # GhostDoc plugin setting file
260 | *.GhostDoc.xml
261 |
262 | # Node.js Tools for Visual Studio
263 | .ntvs_analysis.dat
264 | node_modules/
265 |
266 | # Visual Studio 6 build log
267 | *.plg
268 |
269 | # Visual Studio 6 workspace options file
270 | *.opt
271 |
272 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
273 | *.vbw
274 |
275 | # Visual Studio LightSwitch build output
276 | **/*.HTMLClient/GeneratedArtifacts
277 | **/*.DesktopClient/GeneratedArtifacts
278 | **/*.DesktopClient/ModelManifest.xml
279 | **/*.Server/GeneratedArtifacts
280 | **/*.Server/ModelManifest.xml
281 | _Pvt_Extensions
282 |
283 | # Paket dependency manager
284 | .paket/paket.exe
285 | paket-files/
286 |
287 | # FAKE - F# Make
288 | .fake/
289 |
290 | # JetBrains Rider
291 | .idea/
292 | *.sln.iml
293 |
294 | # CodeRush
295 | .cr/
296 |
297 | # Python Tools for Visual Studio (PTVS)
298 | __pycache__/
299 | *.pyc
300 |
301 | # Cake - Uncomment if you are using it
302 | # tools/**
303 | # !tools/packages.config
304 |
305 | # Tabs Studio
306 | *.tss
307 |
308 | # Telerik's JustMock configuration file
309 | *.jmconfig
310 |
311 | # BizTalk build output
312 | *.btp.cs
313 | *.btm.cs
314 | *.odx.cs
315 | *.xsd.cs
316 |
317 | # OpenCover UI analysis results
318 | OpenCover/
319 |
320 | # Azure Stream Analytics local run output
321 | ASALocalRun/
322 |
323 | # MSBuild Binary and Structured Log
324 | *.binlog
325 |
326 | # NVidia Nsight GPU debugger configuration file
327 | *.nvuser
328 |
329 | # MFractors (Xamarin productivity tool) working folder
330 | .mfractor/
331 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # TankGame
2 | 基于C#实现坦克大战的小游戏
3 |
--------------------------------------------------------------------------------
/Resouces/add.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/add.wav
--------------------------------------------------------------------------------
/Resouces/blast.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast.wav
--------------------------------------------------------------------------------
/Resouces/blast1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast1.gif
--------------------------------------------------------------------------------
/Resouces/blast2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast2.gif
--------------------------------------------------------------------------------
/Resouces/blast3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast3.gif
--------------------------------------------------------------------------------
/Resouces/blast4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast4.gif
--------------------------------------------------------------------------------
/Resouces/blast5.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast5.gif
--------------------------------------------------------------------------------
/Resouces/blast6.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast6.gif
--------------------------------------------------------------------------------
/Resouces/blast7.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast7.gif
--------------------------------------------------------------------------------
/Resouces/blast8.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/blast8.gif
--------------------------------------------------------------------------------
/Resouces/bomb.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/bomb.gif
--------------------------------------------------------------------------------
/Resouces/enemy1D.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy1D.gif
--------------------------------------------------------------------------------
/Resouces/enemy1L.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy1L.gif
--------------------------------------------------------------------------------
/Resouces/enemy1R.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy1R.gif
--------------------------------------------------------------------------------
/Resouces/enemy1U.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy1U.gif
--------------------------------------------------------------------------------
/Resouces/enemy2D.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy2D.gif
--------------------------------------------------------------------------------
/Resouces/enemy2L.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy2L.gif
--------------------------------------------------------------------------------
/Resouces/enemy2R.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy2R.gif
--------------------------------------------------------------------------------
/Resouces/enemy2U.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy2U.gif
--------------------------------------------------------------------------------
/Resouces/enemy3D.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy3D.gif
--------------------------------------------------------------------------------
/Resouces/enemy3L.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy3L.gif
--------------------------------------------------------------------------------
/Resouces/enemy3R.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy3R.gif
--------------------------------------------------------------------------------
/Resouces/enemy3U.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemy3U.gif
--------------------------------------------------------------------------------
/Resouces/enemymissile.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/enemymissile.gif
--------------------------------------------------------------------------------
/Resouces/fire.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/fire.wav
--------------------------------------------------------------------------------
/Resouces/hit.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/hit.wav
--------------------------------------------------------------------------------
/Resouces/p1tankD.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/p1tankD.gif
--------------------------------------------------------------------------------
/Resouces/p1tankL.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/p1tankL.gif
--------------------------------------------------------------------------------
/Resouces/p1tankR.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/p1tankR.gif
--------------------------------------------------------------------------------
/Resouces/p1tankU.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/p1tankU.gif
--------------------------------------------------------------------------------
/Resouces/star.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/star.gif
--------------------------------------------------------------------------------
/Resouces/start.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/start.wav
--------------------------------------------------------------------------------
/Resouces/tankmissile.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/tankmissile.gif
--------------------------------------------------------------------------------
/Resouces/timer.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/timer.gif
--------------------------------------------------------------------------------
/Resouces/wall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/Resouces/wall.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 2013
4 | VisualStudioVersion = 12.0.21005.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TankGame", "TankGame\TankGame.csproj", "{21D2DD90-DE19-450B-93C6-9B2B502A7A51}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {21D2DD90-DE19-450B-93C6-9B2B502A7A51}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {21D2DD90-DE19-450B-93C6-9B2B502A7A51}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {21D2DD90-DE19-450B-93C6-9B2B502A7A51}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {21D2DD90-DE19-450B-93C6-9B2B502A7A51}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Boom.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Drawing;
7 | using TankGame.Properties;
8 |
9 | namespace TankGame
10 | {
11 | class Boom:GameObject
12 | {
13 | //1.导入爆炸图片
14 | private Image[] imgs ={
15 | Resources.blast1 ,
16 | Resources.blast2 ,
17 | Resources.blast3 ,
18 | Resources.blast4 ,
19 | Resources.blast5 ,
20 | Resources.blast6 ,
21 | Resources.blast7 ,
22 | Resources.blast8 ,
23 | };
24 | //2.构造函数
25 | public Boom (int x,int y) :base(x,y)
26 | {
27 |
28 | }
29 | //3.重写绘制图像的方法
30 | public override void Draw(Graphics g)
31 | {
32 | for (int i = 0; i < imgs.Length ; i++)
33 | {
34 | g.DrawImage(imgs[i], this.X, this.Y);
35 | }
36 | //爆炸播放完成之后,就删除游戏对象
37 | SingleObject.GetSingle().RemoveGameObject(this);
38 | }
39 |
40 |
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/ClassDiagram1.cd:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/EnemyTank.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Media;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using TankGame.Properties;
9 |
10 | namespace TankGame
11 | {
12 | class EnemyTank:TankFather
13 | {
14 | private static Image[] imgs1 = {
15 | Resources.enemy1U,
16 | Resources.enemy1D,
17 | Resources.enemy1L,
18 | Resources.enemy1R
19 | };
20 | private static Image[] imgs2 = {
21 | Resources.enemy2U,
22 | Resources.enemy2D,
23 | Resources.enemy2L,
24 | Resources.enemy2R
25 | };
26 | private static Image[] imgs3 = {
27 | Resources.enemy3U,
28 | Resources.enemy3D,
29 | Resources.enemy3L,
30 | Resources.enemy3R
31 | };
32 |
33 | //1.存储敌人坦克的速度
34 | private static int _speed;
35 | //2.存储敌人坦克的生命
36 | private static int _life;
37 |
38 | public int EnemyTankType
39 | {
40 | get;
41 | set;
42 | }
43 |
44 |
45 | ///
46 | ///3. 通过一个静态方法设置敌人坦克的速度
47 | ///
48 | ///
49 | ///
50 | public static int SetSpeed(int type)
51 | {
52 | switch (type)
53 | {
54 | case 0: _speed = 5;
55 | break;
56 | case 1: _speed = 6;
57 | break;
58 | case 2: _speed = 7;
59 | break;
60 | }
61 | return _speed;
62 | }
63 |
64 |
65 | ///
66 | /// 4.通过一个静态方法设置敌人坦克的生命
67 | ///
68 | ///
69 | ///
70 | public static int SetLife(int type)
71 | {
72 | switch (type)
73 | {
74 | case 0:
75 | _life = 1;
76 | break;
77 | case 1:
78 | _life = 2;
79 | break;
80 | case 2:
81 | _life = 3;
82 | break;
83 | }
84 | return _life;
85 | }
86 |
87 |
88 |
89 | public EnemyTank(int x, int y, int type, Direction dir)
90 | : base(x, y, imgs1, SetSpeed(type), SetLife(type), dir)
91 | {
92 | this.EnemyTankType = type;
93 | Born();
94 | }
95 |
96 |
97 | //10.吃装备让敌人暂停、
98 | public bool isStop = true;
99 | //11.吃装备让敌人暂停多长时间
100 | public int stoptime = 0;
101 |
102 |
103 |
104 |
105 | //5.向窗体当中绘制我们的敌人坦克
106 | public override void Draw(Graphics g)
107 | {
108 |
109 | bornTime++;
110 | if(bornTime %20==0)
111 | {
112 | IsMove = true;
113 | }
114 | if (IsMove)
115 | {
116 | //一绘制我们的敌人坦克 就让坦克移动
117 | //加一个小判断,让敌人停止和暂停一段时间内开始
118 | if(isStop )
119 | {
120 | Move();
121 | }
122 | else
123 | {
124 | stoptime++;
125 | if(stoptime %50==0)
126 | {
127 | isStop = true;
128 |
129 | }
130 | }
131 |
132 |
133 | switch (EnemyTankType)
134 | {
135 | case 0:
136 | switch (this.Dir)
137 | {
138 | case Direction.Up:
139 | g.DrawImage(imgs1[0], this.X, this.Y);
140 | break;
141 | case Direction.Down:
142 | g.DrawImage(imgs1[1], this.X, this.Y);
143 | break;
144 | case Direction.Left:
145 | g.DrawImage(imgs1[2], this.X, this.Y);
146 | break;
147 | case Direction.Right:
148 | g.DrawImage(imgs1[3], this.X, this.Y);
149 | break;
150 | }
151 | break;
152 | case 1:
153 | switch (this.Dir)
154 | {
155 | case Direction.Up:
156 | g.DrawImage(imgs2[0], this.X, this.Y);
157 | break;
158 | case Direction.Down:
159 | g.DrawImage(imgs2[1], this.X, this.Y);
160 | break;
161 | case Direction.Left:
162 | g.DrawImage(imgs2[2], this.X, this.Y);
163 | break;
164 | case Direction.Right:
165 | g.DrawImage(imgs2[3], this.X, this.Y);
166 | break;
167 | }
168 | break;
169 | case 2:
170 | switch (this.Dir)
171 | {
172 | case Direction.Up:
173 | g.DrawImage(imgs3[0], this.X, this.Y);
174 | break;
175 | case Direction.Down:
176 | g.DrawImage(imgs3[1], this.X, this.Y);
177 | break;
178 | case Direction.Left:
179 | g.DrawImage(imgs3[2], this.X, this.Y);
180 | break;
181 | case Direction.Right:
182 | g.DrawImage(imgs3[3], this.X, this.Y);
183 | break;
184 | }
185 | break;
186 | }
187 | //一边移动,一边发子弹
188 | if (r.Next(0, 100) < 2)
189 | {
190 | Fire();
191 | }
192 | }
193 | }
194 |
195 |
196 | //7.发射子弹的重写
197 | ///
198 | /// 敌人发射子弹
199 | ///
200 | public override void Fire()
201 | {
202 | SingleObject.GetSingle().AddGameObject(new EnemyZD(this,10,10, 1));
203 | }
204 |
205 | //8.重写是否中弹的方法就是显示爆炸的的图像。播放音乐。敌人死亡
206 | public override void IsOver()
207 | {
208 | //if (this.Life == 0)//敌人被击中了,并且死亡
209 | //{
210 | //出现爆炸的图像
211 | SingleObject.GetSingle().AddGameObject(new Boom(this.X - 25, this.Y - 25));
212 | //被击中就删掉,删掉被击中的坦克
213 | SingleObject.GetSingle().RemoveGameObject(this);
214 | //播放爆炸音乐
215 | SoundPlayer sp = new SoundPlayer(Resources.fire);
216 | sp.Play();
217 | //当敌人坦克死亡的时候,会有一定的几率,在出生新的坦克
218 | if (r.Next(0, 100) >30)
219 | {
220 | SingleObject.GetSingle().AddGameObject(new EnemyTank(r.Next(0, 700), r.Next(0, 600), r.Next(0, 3), Direction.Down));
221 | }
222 | //当敌人死亡的额时候有一定的几率,产生装备
223 | if(r.Next (0,100)>20)
224 | {
225 |
226 | SingleObject.GetSingle().AddGameObject(new Zhuangbei(this.X, this.Y, r.Next(0, 3)));
227 |
228 | }
229 |
230 |
231 | //}
232 | //else//敌人被击中了,但没死亡
233 | //{
234 | // SoundPlayer sp = new SoundPlayer(Resources.hit );
235 | // sp.Play();
236 |
237 | //}
238 |
239 |
240 |
241 | }
242 | //9.坦克出生重写
243 | public override void Born()
244 | {
245 | SingleObject.GetSingle().AddGameObject(new TankBorn(this.X, this.Y));
246 | }
247 |
248 |
249 |
250 | //6.产生一个随机数,控制敌人坦克随机运动,
251 | //并且必须是静态的随机数
252 | static Random r = new Random();
253 |
254 | public override void Move()
255 | {
256 | base.Move();
257 | //给一个很小的概率,让他进行下一步
258 | if (r.Next(0, 100) < 5)
259 | {
260 | switch (r.Next(0, 4))
261 | {
262 | case 0:
263 | this.Dir = Direction.Up;
264 | break;
265 | case 1:
266 | this.Dir = Direction.Down;
267 | break;
268 | case 2:
269 | this.Dir = Direction.Left;
270 | break;
271 | case 3:
272 | this.Dir = Direction.Right;
273 | break;
274 | }
275 | }
276 | }
277 | }
278 | }
279 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/EnemyZD.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 | using System.Drawing;
7 | using TankGame.Properties;
8 |
9 |
10 |
11 | namespace TankGame
12 | {
13 | class EnemyZD:ZiDanFather
14 | {
15 |
16 | //倒入玩家子弹图片
17 | private static Image img = Resources.enemymissile ;
18 | //写构造函数
19 | public EnemyZD (TankFather tf,int speed,int life,int power):base(tf,speed,life,power ,img)
20 | {
21 |
22 |
23 |
24 |
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Form1.Designer.cs:
--------------------------------------------------------------------------------
1 | namespace TankGame
2 | {
3 | partial class Form1
4 | {
5 | ///
6 | /// 必需的设计器变量。
7 | ///
8 | private System.ComponentModel.IContainer components = null;
9 |
10 | ///
11 | /// 清理所有正在使用的资源。
12 | ///
13 | /// 如果应释放托管资源,为 true;否则为 false。
14 | protected override void Dispose(bool disposing)
15 | {
16 | if (disposing && (components != null))
17 | {
18 | components.Dispose();
19 | }
20 | base.Dispose(disposing);
21 | }
22 |
23 | #region Windows 窗体设计器生成的代码
24 |
25 | ///
26 | /// 设计器支持所需的方法 - 不要
27 | /// 使用代码编辑器修改此方法的内容。
28 | ///
29 | private void InitializeComponent()
30 | {
31 | this.components = new System.ComponentModel.Container();
32 | this.timer1 = new System.Windows.Forms.Timer(this.components);
33 | this.SuspendLayout();
34 | //
35 | // timer1
36 | //
37 | this.timer1.Enabled = true;
38 | this.timer1.Interval = 50;
39 | this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
40 | //
41 | // Form1
42 | //
43 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
44 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
45 | this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
46 | this.ClientSize = new System.Drawing.Size(784, 662);
47 | this.MaximumSize = new System.Drawing.Size(800, 700);
48 | this.MinimumSize = new System.Drawing.Size(800, 700);
49 | this.Name = "Form1";
50 | this.Text = "Form1";
51 | this.Load += new System.EventHandler(this.Form1_Load);
52 | this.Paint += new System.Windows.Forms.PaintEventHandler(this.Form1_Paint);
53 | this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
54 | this.ResumeLayout(false);
55 |
56 | }
57 |
58 | #endregion
59 |
60 | private System.Windows.Forms.Timer timer1;
61 | }
62 | }
63 |
64 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Form1.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.ComponentModel;
4 | using System.Data;
5 | using System.Drawing;
6 | using System.Linq;
7 | using System.Media;
8 | using System.Text;
9 | using System.Threading.Tasks;
10 | using System.Windows.Forms;
11 | using TankGame.Properties;
12 |
13 | namespace TankGame
14 | {
15 | public partial class Form1 : Form
16 | {
17 | public Form1()
18 | {
19 | InitializeComponent();
20 | //对我们的游戏进行初始化。先得写一个初始化方法
21 | InitialGame();
22 | InitialMap();
23 | }
24 | ///
25 | /// 1.初始化游戏。包括初始化玩家坦克对象
26 | ///
27 | private void InitialGame ()
28 | {
29 | SingleObject.GetSingle().AddGameObject(new PlayerTank(200, 200, 10, 10, Direction.Up));
30 | SetEnemyTank();
31 |
32 | }
33 |
34 | //不绕了,直接在写一个方法初始化地图
35 | ///
36 | /// 初始化游戏地图
37 | ///
38 | public void InitialMap()
39 | {
40 | for (int i = 0; i < 10; i++)
41 | {
42 | SingleObject.GetSingle().AddGameObject(new Wall(i * 15 + 30, 100));
43 | SingleObject.GetSingle().AddGameObject(new Wall(95, 100 + 15 * i));
44 |
45 | SingleObject.GetSingle().AddGameObject(new Wall(245 - i * 7, 100 + 15 * i));
46 | SingleObject.GetSingle().AddGameObject(new Wall(245 + i * 7, 100 + 15 * i));
47 | SingleObject.GetSingle().AddGameObject(new Wall(215 + i * 15 / 2, 185));
48 |
49 | SingleObject.GetSingle().AddGameObject(new Wall(390 - i * 5, 100 + 15 * i));
50 | SingleObject.GetSingle().AddGameObject(new Wall(390 + i * 5, 100 + 15 * i));
51 | SingleObject.GetSingle().AddGameObject(new Wall(480 - i * 5, 100 + 15 * i));
52 |
53 | SingleObject.GetSingle().AddGameObject(new Wall(515, 100 + 15 * i));
54 | SingleObject.GetSingle().AddGameObject(new Wall(595 - i * 8, 100 + 15 * i / 2));
55 | SingleObject.GetSingle().AddGameObject(new Wall(530 + i * 8, 165 + 15 * i / 2));
56 | }
57 |
58 |
59 |
60 |
61 | }
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 | Random r = new Random();
73 |
74 | ///
75 | /// 6.初始化敌人坦克对象
76 | ///
77 | public void SetEnemyTank()
78 | {
79 | for (int i = 0; i < 8; i++)
80 | {
81 | SingleObject.GetSingle().AddGameObject(new EnemyTank(r.Next(0,
82 | this.Width), r.Next(0, this.Height), r.Next(0, 3), Direction.Down));
83 | }
84 | }
85 |
86 |
87 |
88 |
89 | ///
90 | /// 2.窗体的paint事件,确保重绘的时候不会擦掉
91 | ///
92 | /// 出发当前事件的对象
93 | /// 执行这个方法所需要的资源
94 | private void Form1_Paint(object sender, PaintEventArgs e)
95 | {
96 | SingleObject.GetSingle().Draw(e.Graphics);
97 | }
98 | ///
99 | /// 3..对窗体实时进行更新50ms
100 | ///
101 | ///
102 | ///
103 | private void timer1_Tick(object sender, EventArgs e)
104 | {
105 | this.Invalidate();
106 | //调用碰撞检测方法
107 | SingleObject.GetSingle().PZJC();
108 |
109 | }
110 | ///
111 | /// 4.当键按下的时候会触发
112 | ///
113 | ///
114 | ///
115 | private void Form1_KeyDown(object sender, KeyEventArgs e)
116 | {
117 | //调用方法
118 | SingleObject.GetSingle().PT.KeyDown(e);
119 | }
120 | ///
121 | /// 5.窗体加载
122 | ///
123 | ///
124 | ///
125 | private void Form1_Load(object sender, EventArgs e)
126 | {
127 | //1.减少闪烁
128 | this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint, true);
129 | //(2.在程序加载的时候哦播放音乐
130 | SoundPlayer sp = new SoundPlayer(Resources.start );
131 | sp.Play();
132 |
133 |
134 | }
135 |
136 | public object Resourse { get; set; }
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Form1.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 | 17, 17
122 |
123 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/GameObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TankGame
9 | {
10 | //1.枚举类型
11 | enum Direction
12 | {
13 | Up,
14 | Down,
15 | Right,
16 | Left
17 |
18 | }
19 |
20 |
21 |
22 | abstract class GameObject
23 | {
24 | //2.父类的属性
25 | //父类的属性 XY坐标,宽度,高度,速度,生命值,方向。
26 | #region 游戏对象的属性
27 |
28 |
29 | public int X
30 | {
31 | get;
32 | set;
33 | }
34 | public int Y
35 | {
36 | get;
37 | set;
38 | }
39 | public int Width
40 | {
41 |
42 | get;
43 | set;
44 | }
45 | public int Height
46 | {
47 | get;
48 | set;
49 | }
50 | public int Speed
51 | {
52 | get;
53 | set;
54 | }
55 | public int Life
56 | {
57 | get;
58 | set;
59 | }
60 | public Direction Dir
61 | {
62 | get;
63 | set;
64 | }
65 | #endregion
66 | //3.父类的构造函数
67 | //构造函数
68 | //构造函数是初始化对象用的
69 | public GameObject (int x,int y,int width,int height,int speed,int life,Direction dir)
70 | {
71 | this.X = x;
72 | this.Y = y;
73 | this.Width = width;
74 | this.Height = height;
75 | this.Speed = speed;
76 | this.Life = life;
77 | this.Dir = dir;
78 |
79 | }
80 |
81 | //4.父类画图的抽象方法
82 | //绘图的抽象方法
83 | public abstract void Draw(Graphics g);
84 |
85 |
86 | //5.游戏对象移动的虚方法
87 | ///
88 | /// 我们在移动的时候,,是根据当前游戏对象的方向进行移动
89 | ///
90 | public virtual void Move()
91 | {
92 | switch (this.Dir )
93 | {
94 | case Direction .Up :
95 | this.Y -= this.Speed;
96 | break;
97 | case Direction.Down :
98 | this.Y += this.Speed;
99 | break;
100 | case Direction .Left :
101 | this.X -= this.Speed;
102 | break;
103 | case Direction.Right :
104 | this.X += this.Speed;
105 | break;
106 |
107 | }
108 | //在游戏对象完成之后。我们应该判断一下,当前游戏对象是否超出当前的窗体
109 | if (this.X<=0)
110 | {
111 | this.X = 0;
112 | }
113 | if (this.Y<=0)
114 | {
115 | this.Y = 0;
116 | }
117 | if(this.Y >=600)
118 | {
119 | this.Y = 600;
120 | }
121 | if(this.X>=720)
122 | {
123 | this.X = 720;
124 | }
125 |
126 |
127 | }
128 |
129 | //6.获得当前对象矩形的方法
130 | //主要用于后面的碰撞检测
131 | ///
132 | /// 用于碰撞检测
133 | ///
134 | ///
135 | public Rectangle GetRectangle()
136 | {
137 |
138 | return new Rectangle(this.X, this.Y, this.Width, this.Height);
139 |
140 | }
141 |
142 | //7.爆炸图片构造函数的父类传
143 | public GameObject(int x, int y):this(x,y,0,0,0,0,0)//this作用代表当前类的对象,第二个显示的调用自己类中的构造函数
144 | {
145 |
146 |
147 | }
148 | //8.专门给zhuangbei的构造函数
149 | //分析:由于zhuangbei类中需要调用父类的构造函数,但是调用其他的构造函数,,又未免大张旗鼓。
150 | // 所以好像是那个重载,方法的重载,子类的构造函数可以继承这个构造函数、、、
151 | public GameObject (int x,int y,int width,int height)
152 | :this(x,y,width ,height,0,0,0) //this作用调用自己的构造函数
153 | {
154 |
155 | }
156 | }
157 | }
158 |
159 |
160 |
161 |
162 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/PlayerTank.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Media;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using System.Windows.Forms;
9 | using TankGame.Properties;
10 |
11 |
12 | namespace TankGame
13 | {
14 | class PlayerTank:TankFather
15 | {
16 | private static Image[] imgs ={
17 | Resources .p1tankU ,
18 | Resources .p1tankD ,
19 | Resources .p1tankL ,
20 | Resources.p1tankR
21 | };
22 | public PlayerTank (int x,int y,int speed,int life ,Direction dir)
23 | :base(x,y,imgs,speed,life,dir )
24 | {
25 | Born();
26 |
27 | }
28 |
29 |
30 | //6.标明子弹等级-属性
31 |
32 | public int ZDLevel
33 | {
34 | get;
35 | set;
36 | }
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 | //1.玩家按键移动方法
47 | public void KeyDown(KeyEventArgs e)
48 | {
49 | switch (e.KeyCode)
50 | {
51 | case Keys.W:
52 | this.Dir = Direction.Up;
53 | base.Move();
54 | break;
55 | case Keys.A:
56 | this.Dir = Direction.Left;
57 | base.Move();
58 | break;
59 | case Keys.D :
60 | this.Dir = Direction.Right;
61 | base.Move();
62 | break;
63 | case Keys.S :
64 | this.Dir = Direction.Down;
65 | base.Move();
66 | break;
67 | //发射子弹的按键
68 | case Keys.K :
69 | Fire();
70 | break;
71 |
72 |
73 |
74 | }
75 | }
76 | //2.重写发射子弹
77 | public override void Fire()
78 | {
79 | //(6.位吃装备写代码{{
80 | switch (ZDLevel )
81 | {
82 | case 0:
83 | SingleObject.GetSingle().AddGameObject(new PlayerZD(this, 10, 10, 1));
84 | break;
85 | case 1:
86 | SingleObject.GetSingle().AddGameObject(new PlayerZD(this, 20, 10, 1));
87 | break;
88 | case 2:
89 | SingleObject.GetSingle().AddGameObject(new PlayerZD(this, 40, 10, 1));
90 | break;
91 |
92 |
93 | }
94 |
95 | //当执行这个方法时,我们创建子弹对象
96 | SingleObject.GetSingle().AddGameObject(new PlayerZD(this,10, 10, 1));
97 | }
98 |
99 | //3.重写是否中弹的方法
100 | public override void IsOver()
101 | {
102 | //玩家坦克爆炸
103 | //SingleObject.GetSingle().AddGameObject(new Boom(this.X - 25, this.Y - 25));
104 | //播放声音
105 | SoundPlayer sp = new SoundPlayer(Resources.hit);
106 | sp.Play();
107 |
108 |
109 | }
110 | //4.重写坦克出生的方法
111 | public override void Born()
112 | {
113 | SingleObject.GetSingle().AddGameObject(new TankBorn(this.X, this.Y));
114 | }
115 |
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/PlayerZD.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using TankGame.Properties;
8 |
9 | namespace TankGame
10 | {
11 | class PlayerZD:ZiDanFather
12 | {
13 | //倒入玩家子弹图片
14 | private static Image img = Resources.tankmissile;
15 | //写构造函数
16 | public PlayerZD (TankFather tf,int speed,int life,int power):base(tf,speed,life,power ,img)
17 | {
18 |
19 |
20 |
21 |
22 | }
23 |
24 |
25 |
26 |
27 |
28 |
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Threading.Tasks;
5 | using System.Windows.Forms;
6 |
7 | namespace TankGame
8 | {
9 | static class Program
10 | {
11 | ///
12 | /// 应用程序的主入口点。
13 | ///
14 | [STAThread]
15 | static void Main()
16 | {
17 | Application.EnableVisualStyles();
18 | Application.SetCompatibleTextRenderingDefault(false);
19 | Application.Run(new Form1());
20 | }
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的常规信息通过以下
6 | // 特性集控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("TankGame")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("Microsoft")]
12 | [assembly: AssemblyProduct("TankGame")]
13 | [assembly: AssemblyCopyright("Copyright © Microsoft 2015")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // 将 ComVisible 设置为 false 使此程序集中的类型
18 | // 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | // 则将该类型上的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("040595e1-4328-434c-b15a-c392077f2443")]
24 |
25 | // 程序集的版本信息由下面四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本:4.0.30319.34209
5 | //
6 | // 对此文件的更改可能会导致不正确的行为,并且如果
7 | // 重新生成代码,这些更改将会丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TankGame.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// 一个强类型的资源类,用于查找本地化的字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// 返回此类使用的缓存的 ResourceManager 实例。
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("TankGame.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// 使用此强类型资源类,为所有资源查找
51 | /// 重写当前线程的 CurrentUICulture 属性。
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// 查找类似于 System.IO.MemoryStream 的 System.IO.UnmanagedMemoryStream 类型的本地化资源。
65 | ///
66 | internal static System.IO.UnmanagedMemoryStream add {
67 | get {
68 | return ResourceManager.GetStream("add", resourceCulture);
69 | }
70 | }
71 |
72 | ///
73 | /// 查找类似于 System.IO.MemoryStream 的 System.IO.UnmanagedMemoryStream 类型的本地化资源。
74 | ///
75 | internal static System.IO.UnmanagedMemoryStream blast {
76 | get {
77 | return ResourceManager.GetStream("blast", resourceCulture);
78 | }
79 | }
80 |
81 | ///
82 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
83 | ///
84 | internal static System.Drawing.Bitmap blast1 {
85 | get {
86 | object obj = ResourceManager.GetObject("blast1", resourceCulture);
87 | return ((System.Drawing.Bitmap)(obj));
88 | }
89 | }
90 |
91 | ///
92 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
93 | ///
94 | internal static System.Drawing.Bitmap blast2 {
95 | get {
96 | object obj = ResourceManager.GetObject("blast2", resourceCulture);
97 | return ((System.Drawing.Bitmap)(obj));
98 | }
99 | }
100 |
101 | ///
102 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
103 | ///
104 | internal static System.Drawing.Bitmap blast3 {
105 | get {
106 | object obj = ResourceManager.GetObject("blast3", resourceCulture);
107 | return ((System.Drawing.Bitmap)(obj));
108 | }
109 | }
110 |
111 | ///
112 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
113 | ///
114 | internal static System.Drawing.Bitmap blast4 {
115 | get {
116 | object obj = ResourceManager.GetObject("blast4", resourceCulture);
117 | return ((System.Drawing.Bitmap)(obj));
118 | }
119 | }
120 |
121 | ///
122 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
123 | ///
124 | internal static System.Drawing.Bitmap blast5 {
125 | get {
126 | object obj = ResourceManager.GetObject("blast5", resourceCulture);
127 | return ((System.Drawing.Bitmap)(obj));
128 | }
129 | }
130 |
131 | ///
132 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
133 | ///
134 | internal static System.Drawing.Bitmap blast6 {
135 | get {
136 | object obj = ResourceManager.GetObject("blast6", resourceCulture);
137 | return ((System.Drawing.Bitmap)(obj));
138 | }
139 | }
140 |
141 | ///
142 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
143 | ///
144 | internal static System.Drawing.Bitmap blast7 {
145 | get {
146 | object obj = ResourceManager.GetObject("blast7", resourceCulture);
147 | return ((System.Drawing.Bitmap)(obj));
148 | }
149 | }
150 |
151 | ///
152 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
153 | ///
154 | internal static System.Drawing.Bitmap blast8 {
155 | get {
156 | object obj = ResourceManager.GetObject("blast8", resourceCulture);
157 | return ((System.Drawing.Bitmap)(obj));
158 | }
159 | }
160 |
161 | ///
162 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
163 | ///
164 | internal static System.Drawing.Bitmap bomb {
165 | get {
166 | object obj = ResourceManager.GetObject("bomb", resourceCulture);
167 | return ((System.Drawing.Bitmap)(obj));
168 | }
169 | }
170 |
171 | ///
172 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
173 | ///
174 | internal static System.Drawing.Bitmap born1 {
175 | get {
176 | object obj = ResourceManager.GetObject("born1", resourceCulture);
177 | return ((System.Drawing.Bitmap)(obj));
178 | }
179 | }
180 |
181 | ///
182 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
183 | ///
184 | internal static System.Drawing.Bitmap born2 {
185 | get {
186 | object obj = ResourceManager.GetObject("born2", resourceCulture);
187 | return ((System.Drawing.Bitmap)(obj));
188 | }
189 | }
190 |
191 | ///
192 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
193 | ///
194 | internal static System.Drawing.Bitmap born3 {
195 | get {
196 | object obj = ResourceManager.GetObject("born3", resourceCulture);
197 | return ((System.Drawing.Bitmap)(obj));
198 | }
199 | }
200 |
201 | ///
202 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
203 | ///
204 | internal static System.Drawing.Bitmap born4 {
205 | get {
206 | object obj = ResourceManager.GetObject("born4", resourceCulture);
207 | return ((System.Drawing.Bitmap)(obj));
208 | }
209 | }
210 |
211 | ///
212 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
213 | ///
214 | internal static System.Drawing.Bitmap enemy1D {
215 | get {
216 | object obj = ResourceManager.GetObject("enemy1D", resourceCulture);
217 | return ((System.Drawing.Bitmap)(obj));
218 | }
219 | }
220 |
221 | ///
222 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
223 | ///
224 | internal static System.Drawing.Bitmap enemy1L {
225 | get {
226 | object obj = ResourceManager.GetObject("enemy1L", resourceCulture);
227 | return ((System.Drawing.Bitmap)(obj));
228 | }
229 | }
230 |
231 | ///
232 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
233 | ///
234 | internal static System.Drawing.Bitmap enemy1R {
235 | get {
236 | object obj = ResourceManager.GetObject("enemy1R", resourceCulture);
237 | return ((System.Drawing.Bitmap)(obj));
238 | }
239 | }
240 |
241 | ///
242 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
243 | ///
244 | internal static System.Drawing.Bitmap enemy1U {
245 | get {
246 | object obj = ResourceManager.GetObject("enemy1U", resourceCulture);
247 | return ((System.Drawing.Bitmap)(obj));
248 | }
249 | }
250 |
251 | ///
252 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
253 | ///
254 | internal static System.Drawing.Bitmap enemy2D {
255 | get {
256 | object obj = ResourceManager.GetObject("enemy2D", resourceCulture);
257 | return ((System.Drawing.Bitmap)(obj));
258 | }
259 | }
260 |
261 | ///
262 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
263 | ///
264 | internal static System.Drawing.Bitmap enemy2L {
265 | get {
266 | object obj = ResourceManager.GetObject("enemy2L", resourceCulture);
267 | return ((System.Drawing.Bitmap)(obj));
268 | }
269 | }
270 |
271 | ///
272 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
273 | ///
274 | internal static System.Drawing.Bitmap enemy2R {
275 | get {
276 | object obj = ResourceManager.GetObject("enemy2R", resourceCulture);
277 | return ((System.Drawing.Bitmap)(obj));
278 | }
279 | }
280 |
281 | ///
282 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
283 | ///
284 | internal static System.Drawing.Bitmap enemy2U {
285 | get {
286 | object obj = ResourceManager.GetObject("enemy2U", resourceCulture);
287 | return ((System.Drawing.Bitmap)(obj));
288 | }
289 | }
290 |
291 | ///
292 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
293 | ///
294 | internal static System.Drawing.Bitmap enemy3D {
295 | get {
296 | object obj = ResourceManager.GetObject("enemy3D", resourceCulture);
297 | return ((System.Drawing.Bitmap)(obj));
298 | }
299 | }
300 |
301 | ///
302 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
303 | ///
304 | internal static System.Drawing.Bitmap enemy3L {
305 | get {
306 | object obj = ResourceManager.GetObject("enemy3L", resourceCulture);
307 | return ((System.Drawing.Bitmap)(obj));
308 | }
309 | }
310 |
311 | ///
312 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
313 | ///
314 | internal static System.Drawing.Bitmap enemy3R {
315 | get {
316 | object obj = ResourceManager.GetObject("enemy3R", resourceCulture);
317 | return ((System.Drawing.Bitmap)(obj));
318 | }
319 | }
320 |
321 | ///
322 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
323 | ///
324 | internal static System.Drawing.Bitmap enemy3U {
325 | get {
326 | object obj = ResourceManager.GetObject("enemy3U", resourceCulture);
327 | return ((System.Drawing.Bitmap)(obj));
328 | }
329 | }
330 |
331 | ///
332 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
333 | ///
334 | internal static System.Drawing.Bitmap enemymissile {
335 | get {
336 | object obj = ResourceManager.GetObject("enemymissile", resourceCulture);
337 | return ((System.Drawing.Bitmap)(obj));
338 | }
339 | }
340 |
341 | ///
342 | /// 查找类似于 System.IO.MemoryStream 的 System.IO.UnmanagedMemoryStream 类型的本地化资源。
343 | ///
344 | internal static System.IO.UnmanagedMemoryStream fire {
345 | get {
346 | return ResourceManager.GetStream("fire", resourceCulture);
347 | }
348 | }
349 |
350 | ///
351 | /// 查找类似于 System.IO.MemoryStream 的 System.IO.UnmanagedMemoryStream 类型的本地化资源。
352 | ///
353 | internal static System.IO.UnmanagedMemoryStream hit {
354 | get {
355 | return ResourceManager.GetStream("hit", resourceCulture);
356 | }
357 | }
358 |
359 | ///
360 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
361 | ///
362 | internal static System.Drawing.Bitmap p1tankD {
363 | get {
364 | object obj = ResourceManager.GetObject("p1tankD", resourceCulture);
365 | return ((System.Drawing.Bitmap)(obj));
366 | }
367 | }
368 |
369 | ///
370 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
371 | ///
372 | internal static System.Drawing.Bitmap p1tankL {
373 | get {
374 | object obj = ResourceManager.GetObject("p1tankL", resourceCulture);
375 | return ((System.Drawing.Bitmap)(obj));
376 | }
377 | }
378 |
379 | ///
380 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
381 | ///
382 | internal static System.Drawing.Bitmap p1tankR {
383 | get {
384 | object obj = ResourceManager.GetObject("p1tankR", resourceCulture);
385 | return ((System.Drawing.Bitmap)(obj));
386 | }
387 | }
388 |
389 | ///
390 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
391 | ///
392 | internal static System.Drawing.Bitmap p1tankU {
393 | get {
394 | object obj = ResourceManager.GetObject("p1tankU", resourceCulture);
395 | return ((System.Drawing.Bitmap)(obj));
396 | }
397 | }
398 |
399 | ///
400 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
401 | ///
402 | internal static System.Drawing.Bitmap star {
403 | get {
404 | object obj = ResourceManager.GetObject("star", resourceCulture);
405 | return ((System.Drawing.Bitmap)(obj));
406 | }
407 | }
408 |
409 | ///
410 | /// 查找类似于 System.IO.MemoryStream 的 System.IO.UnmanagedMemoryStream 类型的本地化资源。
411 | ///
412 | internal static System.IO.UnmanagedMemoryStream start {
413 | get {
414 | return ResourceManager.GetStream("start", resourceCulture);
415 | }
416 | }
417 |
418 | ///
419 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
420 | ///
421 | internal static System.Drawing.Bitmap tankmissile {
422 | get {
423 | object obj = ResourceManager.GetObject("tankmissile", resourceCulture);
424 | return ((System.Drawing.Bitmap)(obj));
425 | }
426 | }
427 |
428 | ///
429 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
430 | ///
431 | internal static System.Drawing.Bitmap timer {
432 | get {
433 | object obj = ResourceManager.GetObject("timer", resourceCulture);
434 | return ((System.Drawing.Bitmap)(obj));
435 | }
436 | }
437 |
438 | ///
439 | /// 查找 System.Drawing.Bitmap 类型的本地化资源。
440 | ///
441 | internal static System.Drawing.Bitmap wall {
442 | get {
443 | object obj = ResourceManager.GetObject("wall", resourceCulture);
444 | return ((System.Drawing.Bitmap)(obj));
445 | }
446 | }
447 | }
448 | }
449 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\add.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
123 |
124 |
125 | ..\Resources\blast.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
126 |
127 |
128 | ..\Resources\blast1.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | ..\Resources\blast2.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
134 | ..\Resources\blast3.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
135 |
136 |
137 | ..\Resources\blast4.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
138 |
139 |
140 | ..\Resources\blast5.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
141 |
142 |
143 | ..\Resources\blast6.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
144 |
145 |
146 | ..\Resources\blast7.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
147 |
148 |
149 | ..\Resources\blast8.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
150 |
151 |
152 | ..\Resources\bomb.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
153 |
154 |
155 | ..\Resources\born1.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
156 |
157 |
158 | ..\Resources\born2.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
159 |
160 |
161 | ..\Resources\born3.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
162 |
163 |
164 | ..\Resources\born4.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
165 |
166 |
167 | ..\Resources\enemy1D.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
168 |
169 |
170 | ..\Resources\enemy1L.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
171 |
172 |
173 | ..\Resources\enemy1R.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
174 |
175 |
176 | ..\Resources\enemy1U.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
177 |
178 |
179 | ..\Resources\enemy2D.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
180 |
181 |
182 | ..\Resources\enemy2L.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
183 |
184 |
185 | ..\Resources\enemy2R.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
186 |
187 |
188 | ..\Resources\enemy2U.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
189 |
190 |
191 | ..\Resources\enemy3D.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
192 |
193 |
194 | ..\Resources\enemy3L.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
195 |
196 |
197 | ..\Resources\enemy3R.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
198 |
199 |
200 | ..\Resources\enemy3U.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
201 |
202 |
203 | ..\Resources\enemymissile.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
204 |
205 |
206 | ..\Resources\fire.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
207 |
208 |
209 | ..\Resources\hit.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
210 |
211 |
212 | ..\Resources\p1tankD.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
213 |
214 |
215 | ..\Resources\p1tankL.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
216 |
217 |
218 | ..\Resources\p1tankR.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
219 |
220 |
221 | ..\Resources\p1tankU.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
222 |
223 |
224 | ..\Resources\star.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
225 |
226 |
227 | ..\Resources\start.wav;System.IO.MemoryStream, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
228 |
229 |
230 | ..\Resources\tankmissile.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
231 |
232 |
233 | ..\Resources\timer.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
234 |
235 |
236 | ..\Resources\wall.gif;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
237 |
238 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.34209
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace TankGame.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/add.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/add.wav
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast.wav
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast1.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast2.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast3.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast4.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast5.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast5.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast6.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast6.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast7.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast7.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/blast8.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/blast8.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/bomb.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/bomb.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/born1.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/born1.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/born2.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/born2.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/born3.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/born3.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/born4.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/born4.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy1D.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy1D.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy1L.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy1L.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy1R.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy1R.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy1U.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy1U.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy2D.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy2D.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy2L.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy2L.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy2R.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy2R.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy2U.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy2U.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy3D.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy3D.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy3L.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy3L.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy3R.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy3R.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemy3U.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemy3U.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/enemymissile.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/enemymissile.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/fire.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/fire.wav
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/hit.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/hit.wav
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/p1tankD.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/p1tankD.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/p1tankL.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/p1tankL.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/p1tankR.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/p1tankR.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/p1tankU.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/p1tankU.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/star.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/star.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/start.wav:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/start.wav
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/tankmissile.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/tankmissile.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/timer.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/timer.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Resources/wall.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/MartinWuQing/TankGame/0b507d908da571bba727369512f92c55e440b407/TankGameV1.0/TankGame/TankGame/Resources/wall.gif
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/SingleObject.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Media;
6 | using System.Text;
7 | using System.Threading.Tasks;
8 | using TankGame.Properties;
9 |
10 | namespace TankGame
11 | {
12 | ///
13 | /// 这个单例类用来创建我们全局唯一的游戏对象
14 | ///
15 | class SingleObject
16 | {
17 | ///
18 | /// 构造函数
19 | ///
20 | private SingleObject ()
21 | { }
22 |
23 | public static SingleObject _singleobject=null;
24 | public static SingleObject GetSingle()
25 | {
26 | if (_singleobject ==null)
27 | {
28 | _singleobject = new SingleObject();
29 | }
30 |
31 | return _singleobject ;
32 |
33 | }
34 | //1.存储玩家坦克对象
35 | public PlayerTank PT
36 | {
37 | get;
38 | set;
39 |
40 | }
41 |
42 | //4.将我们的敌人坦克、玩家子弹,敌人子弹、爆炸 、出生时的小星星、装备/墙 存储到泛型集合中
43 | List listEnemyTank = new List();
44 | List listPlayerZD = new List();
45 | List listEnemyZD = new List();
46 | List listBoom = new List();
47 |
48 | List listTankBorn = new List();
49 | List listZhuangBei = new List();
50 | List listWall = new List();
51 |
52 |
53 |
54 | //2.提供一个方法,将我们这个游戏对象添加到游戏当中,游戏对象很多,所以把父类传进去
55 | //把玩家坦克添加到游戏当中
56 | ///
57 | /// 添加游戏对象
58 | ///
59 | ///
60 | public void AddGameObject(GameObject go)
61 | {
62 | //(1).添加玩家坦克
63 | if (go is PlayerTank )//is 表示类型转换成功为Yes不成功返回false
64 | {
65 | PT = go as PlayerTank;//as 也是类型转换,成功的话 返回对应的对象,否则返回null
66 |
67 | }
68 | //(2).添加敌人坦克对象
69 | else if (go is EnemyTank )
70 | {
71 | listEnemyTank.Add(go as EnemyTank);
72 | }
73 | //(3).添加玩家子弹
74 | else if(go is PlayerZD )
75 | {
76 | listPlayerZD.Add (go as PlayerZD);
77 |
78 | }
79 | else if (go is EnemyZD )
80 | {
81 | listEnemyZD.Add(go as EnemyZD);
82 |
83 | }
84 | //(4.添加爆炸图
85 | else if(go is Boom )
86 | {
87 | listBoom.Add(go as Boom);
88 |
89 | }
90 | //(5.添加出生时的小星星
91 | else if(go is TankBorn )
92 | {
93 | listTankBorn.Add(go as TankBorn);
94 | }
95 | //(6.添加装备对象
96 | else if(go is Zhuangbei )
97 | {
98 | listZhuangBei.Add(go as Zhuangbei);
99 |
100 | }
101 | //(7.添加墙对象
102 | else if(go is Wall )
103 | {
104 | listWall.Add(go as Wall);
105 | }
106 |
107 | }
108 |
109 | //3.绘制游戏的方法
110 | ///
111 | /// 绘制游戏对象
112 | ///
113 | ///
114 | public void Draw(Graphics g)
115 | {
116 | //(1.画玩家坦克
117 | PT.Draw(g);
118 | //(2.画敌人坦克
119 | for (int i = 0; i < listEnemyTank .Count ; i++)
120 | {
121 | listEnemyTank[i].Draw(g);
122 | }
123 | //(3.绘制玩家子弹
124 | for (int i = 0; i < listPlayerZD .Count ; i++)
125 | {
126 | listPlayerZD[i].Draw(g);
127 | }
128 | //(4.绘制敌人子弹
129 | for (int i = 0; i < listEnemyZD.Count ; i++)
130 | {
131 | listEnemyZD[i].Draw(g);
132 | }
133 | //(5.绘制爆炸
134 | for (int i = 0; i < listBoom .Count ; i++)
135 | {
136 | listBoom[i].Draw(g);
137 | }
138 | //(6。绘制出生时的小星星
139 | for (int i = 0; i < listTankBorn.Count ; i++)
140 | {
141 | listTankBorn[i].Draw(g);
142 | }
143 | //(6.绘制装备对象
144 | for (int i = 0; i < listZhuangBei .Count ; i++)
145 | {
146 | listZhuangBei[i].Draw(g);
147 | }
148 | //(7.绘制墙
149 | for (int i = 0; i < listWall .Count ; i++)
150 | {
151 | listWall[i].Draw(g);
152 | }
153 |
154 | }
155 | ///
156 | /// 4
157 | /// 碰撞检测的方法
158 | ///
159 | public void PZJC()
160 | {
161 | #region (1.首先判断玩家的子弹是否打在了敌人的身上
162 |
163 | for (int i = 0; i < listPlayerZD .Count ; i++)
164 | {
165 | for (int j = 0; j < listEnemyTank.Count ; j++)
166 | {
167 | if(listPlayerZD [i].GetRectangle().IntersectsWith (listEnemyTank [j].GetRectangle ()))
168 | {
169 | //表示玩家的子弹打到敌人的身上
170 | //敌人应该减少生命值
171 | listEnemyTank[j].Life -= listPlayerZD[i].power ;
172 | listEnemyTank[j].IsOver();
173 | //当玩家坦克的子弹击中敌人坦克的时候,子弹消失
174 | listPlayerZD.Remove(listPlayerZD[i]);
175 | break;
176 | }
177 | }
178 | }
179 | #endregion
180 |
181 | #region (2.判断敌人 的子弹是否打在了玩家的身上
182 | for (int i = 0; i < listEnemyZD .Count ; i++)
183 | {
184 | //敌人子弹的矩形区域跟玩家区域相交
185 | if(listEnemyZD [i].GetRectangle ().IntersectsWith (PT.GetRectangle ()))
186 | {
187 |
188 | PT.IsOver();
189 | //将敌人子弹删除
190 | listEnemyZD.Remove(listEnemyZD[i]);
191 | break;
192 | }
193 | }
194 | #endregion
195 | #region (3. (自己写的)判断敌人的子弹是否打在了玩家子弹上
196 | for (int i = 0; i < listEnemyZD.Count ; i++)
197 | {
198 | for (int j= 0; j < listPlayerZD .Count ; j++)
199 | {
200 |
201 |
202 | //敌人子弹的矩形区域跟玩家子弹区域相交
203 | if(listEnemyZD [i].GetRectangle ().IntersectsWith (listPlayerZD[j].GetRectangle()))
204 | {
205 | listPlayerZD.Remove(listPlayerZD[j]);
206 | listEnemyZD.Remove(listEnemyZD[i]);
207 | SoundPlayer sp = new SoundPlayer(Resources.hit);
208 | sp.Play();
209 | break;
210 |
211 | }
212 | }
213 | }
214 |
215 |
216 | #endregion
217 |
218 | #region (4.玩家是否和产生的装备发生碰撞
219 | for (int i = 0; i < listZhuangBei .Count ; i++)
220 | {
221 | //玩家吃到了装备
222 | if(listZhuangBei [i].GetRectangle ().IntersectsWith (PT.GetRectangle ()))
223 | {
224 | //调用JudgeZB的方法 等级++吃五角星、
225 | //注意先后顺序,先掉用后移除
226 | JudgeZB(listZhuangBei[i].ZBType);
227 |
228 | //将装备移除
229 | listZhuangBei.Remove(listZhuangBei[i]);
230 |
231 |
232 |
233 | //添加吃装备的声音
234 | SoundPlayer sp = new SoundPlayer(Resources.add);
235 | sp.Play ();
236 | }
237 | }
238 | #endregion
239 | #region 5.判断敌人是否和墙发生了碰撞
240 | for (int i = 0; i < listWall .Count ; i++)
241 | {
242 |
243 | for (int j = 0; j < listEnemyTank .Count ; j++)
244 | {
245 | if(listWall [i].GetRectangle ().IntersectsWith(listEnemyTank [j].GetRectangle() ))
246 | {
247 | //当敌人 和墙体发生碰撞时。我们应改将敌人的坐标固定到那里
248 | //碰撞的位置,不许穿过墙体
249 | //需要判断敌人是从哪个方向过来发生碰撞的
250 | switch (listEnemyTank[j].Dir)
251 | {
252 | case Direction.Up :
253 | listEnemyTank[j].Y = listWall[i].Y + listWall[i].Height;
254 | break;
255 | case Direction.Down :
256 | listEnemyTank[j].Y = listWall[i].Y- listWall[i].Height;
257 | break;
258 | case Direction.Left :
259 | listEnemyTank[j].X = listWall[i].X + listWall[i].Width ;
260 | break;
261 | case Direction.Right :
262 | listEnemyTank[j].X = listWall[i].X - listWall[i].Width;
263 | break;
264 |
265 |
266 | }
267 |
268 |
269 |
270 | }
271 | }
272 | }
273 |
274 |
275 | #endregion
276 |
277 | }
278 |
279 |
280 |
281 | //6.判断玩家吃了什么装备,然后会怎样
282 | public void JudgeZB(int type)
283 | {
284 | switch (type )
285 | {
286 | case 0://玩家吃到了五角星
287 | //怎么让玩家子弹这速度加快
288 | //ZDLevel++
289 | if(PT.ZDLevel<2)
290 | {
291 | PT.ZDLevel++;
292 | }
293 |
294 | break;
295 | case 1://吃到地雷后炸掉一片敌人
296 | for (int i = 0; i < listEnemyTank .Count ; i++)
297 | {
298 | //把敌人塔克的生命值赋为0
299 | listEnemyTank[i].Life = 0;
300 | //调用敌人死亡的方法
301 | listEnemyTank[i].IsOver();
302 | }
303 | break;
304 | case 2://想办法让所有敌人暂停
305 | // 必须遍历所有敌人对象
306 | for (int i = 0; i
14 | /// 1.构造函数
15 | ///
16 | ///
17 | ///
18 | ///
19 | ///
20 | ///
21 | ///
22 | public TankFather(int x, int y, Image[] imgs, int speed, int life, Direction dir)
23 | : base(x, y, imgs[0].Width, imgs[0].Height, speed, life, dir)
24 | {
25 | this.imgs = imgs;//父类中必须去实现
26 |
27 | }
28 |
29 | //3.发射子弹的虚方法,让两个子类去重写
30 | public abstract void Fire();
31 |
32 | //4.是否中弹的方法
33 | public abstract void IsOver();
34 | //5.坦克出生的方法
35 | public abstract void Born();
36 |
37 |
38 | //6.做延时,先显示星星,再让玩家坦克出现
39 | public int bornTime = 0;
40 | public bool IsMove = false;
41 |
42 |
43 | ///
44 | /// 2.绘图
45 | ///
46 | ///
47 | public override void Draw(Graphics g)
48 | {
49 | bornTime++;
50 | if(bornTime%20==0)
51 | {
52 | IsMove = true;
53 | }
54 |
55 |
56 | if (IsMove)
57 | {
58 | switch (this.Dir)
59 | {
60 | case Direction.Up:
61 | g.DrawImage(imgs[0], this.X, this.Y);
62 | break;
63 | case Direction.Down:
64 | g.DrawImage(imgs[1], this.X, this.Y);
65 | break;
66 | case Direction.Left:
67 | g.DrawImage(imgs[2], this.X, this.Y);
68 | break;
69 | case Direction.Right:
70 | g.DrawImage(imgs[3], this.X, this.Y);
71 | break;
72 | }
73 | }
74 | }
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/TankGame.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {21D2DD90-DE19-450B-93C6-9B2B502A7A51}
8 | WinExe
9 | Properties
10 | TankGame
11 | TankGame
12 | v4.5
13 | 512
14 |
15 |
16 | AnyCPU
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 |
25 |
26 | AnyCPU
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 | Form
52 |
53 |
54 | Form1.cs
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | Form1.cs
71 |
72 |
73 | ResXFileCodeGenerator
74 | Resources.Designer.cs
75 | Designer
76 |
77 |
78 | True
79 | Resources.resx
80 | True
81 |
82 |
83 |
84 | SettingsSingleFileGenerator
85 | Settings.Designer.cs
86 |
87 |
88 | True
89 | Settings.settings
90 | True
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
221 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Wall.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using TankGame.Properties;
8 |
9 | namespace TankGame
10 | {
11 | class Wall :GameObject
12 | {
13 | //必须是静态的
14 | private static Image img = Resources.wall;
15 | public Wall(int x, int y)
16 | : base(x, y, img.Width, img.Height)
17 | {
18 |
19 |
20 | }
21 | public override void Draw(Graphics g)
22 | {
23 | g.DrawImage(img, this.X, this.Y);
24 | }
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/Zhuangbei.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using TankGame.Properties;
8 |
9 | namespace TankGame
10 | {
11 | class Zhuangbei:GameObject
12 | {
13 | //必须标记成静态类才能让 构造函数访问到
14 | private static Image imgStar = Resources.star;
15 | private static Image imgBomb = Resources.bomb;
16 | private static Image imgTimer = Resources.timer;
17 |
18 | //2.来一个属性区分装备
19 | public int ZBType
20 | {
21 | get;
22 | set;
23 | }
24 |
25 | //3.装备构造函数-先在GameObject类中在写一个构造函数专门给zhuangbei的,
26 | public Zhuangbei (int x,int y,int type):base(x,y,imgBomb.Width ,imgBomb .Height )
27 | {
28 | this.ZBType = type;
29 | }
30 |
31 | //4.画图图
32 | public override void Draw(Graphics g)
33 | {
34 | switch (ZBType )
35 | {
36 | case 0:
37 | g.DrawImage(imgStar, this.X, this.Y);
38 | break;
39 | case 1:
40 | g.DrawImage(imgBomb, this.X, this.Y);
41 | break;
42 | case 2:
43 | g.DrawImage(imgTimer, this.X, this.Y);
44 | break;
45 | }
46 | }
47 |
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/ZiDanFather.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace TankGame
9 | {
10 | class ZiDanFather:GameObject
11 | {
12 | //1.字段
13 | private Image img;
14 | //2.属性
15 | public Image Img
16 | {
17 | get { return img;}
18 | set { img = value; }
19 |
20 | }
21 | //3.子弹威力属性
22 | public int power
23 | {
24 | get;
25 | set ;
26 | }
27 | ///
28 | /// 4.构造函数
29 | ///
30 | ///
31 | ///
32 | public ZiDanFather (TankFather tf,int speed,int life ,int power,Image img):base(tf.X+tf.Width /2-6,tf.Y+tf.Height/2-6,img.Width ,img.Height,speed,life,tf.Dir )
33 |
34 | {
35 |
36 | this.img = img;
37 | }
38 |
39 | //5.绘制子弹图像
40 | public override void Draw(Graphics g)
41 | {
42 | switch (this.Dir)
43 | {
44 | case Direction.Up:
45 | this.Y -= this.Speed;
46 | break;
47 | case Direction.Down:
48 | this.Y += this.Speed;
49 | break;
50 | case Direction.Left:
51 | this.X -= this.Speed;
52 | break;
53 | case Direction.Right:
54 | this.X += this.Speed;
55 | break;
56 |
57 | }
58 | //在游戏对象完成之后。我们应该判断一下,当前游戏对象是否超出当前的窗体
59 | if (this.X <= 0)
60 | {
61 | this.X =-100;
62 | }
63 | if (this.Y <= 0)
64 | {
65 | this.Y = -100;
66 | }
67 | if (this.Y >= 700)
68 | {
69 | this.Y =800;
70 | }
71 | if (this.X >= 800)
72 | {
73 | this.X = 900;
74 | }
75 |
76 | g.DrawImage(img, this.X, this.Y);
77 | }
78 |
79 |
80 |
81 |
82 |
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/image.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace TankGame
7 | {
8 | class image
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/TankGameV1.0/TankGame/TankGame/soundPlayer.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace TankGame
7 | {
8 | class soundPlayer
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------