First of all, let's talk about advanced warfare.
Advance Wars, owned by Nintendo'sIntelligent SystemsDeveloped game of chess.
The first birth in the GBA, and then continue to follow up the high-war 2 black hole, and then in the next generation of palm-machine DS also out of the three generations of high-war DS, as well as later not the same day of destruction.
My high School time is the GBA rampant in the world, then the most favorite thing is to hide in the dormitory toilet secretly play GBA (not lights out). Sometimes also with small partners online playing GT2 racing Mario and so on, while the high war ... This time the foodie can and the small partner online one is really too precious.
Since Gao is not popular in Japan, this type of hard-core chess game is not expected to be renewed. But one of the benefits of being a programmer is that it's still possible to do this game on your own.
Except for the long rounds of the game board games too drag time this common mishap, no need to cultivate level, class, the distinctive Co and powerful Co power, Gao absolute hard nuclear war chess, good game ah.
Gao's core play is playing chess, then the most important thing is the chessboard, that is, the production of maps.
As a poor cock programmer, I have no money to buy art, so go to the point of drawing.
There are many ways to pull the map, in fact, many of the foreign sites have many of these ancient games resources. At the beginning I chose to use the GBA simulator VisualBoy to pull the map, the method is Baidu.
After picking up a bunch of pictures like the one below, it was really impatient.
Let's do some things first, like dragging a map out of unity. However......
Tile size, engagement, different terrain transitions .... It's too painful to make a map editor. Especially the transition of different terrains. such as the sea between the peace, nine Gongge border there are eight sides, and the landing of the shoal how to do? There are reef tiles in the water ... The direction of the road, intersection, oh my God, this kind of thing is not the age of almost all tile games have it? Why don't you go find the tools!
So was Amway to a tool: Tiledmapeditor. Baidu a bit to find the official website, or an open source tool, download is free just will entice users to donate a little money. That's a good thing.
Specific how to be Amway's please transfer here to see: https://www.zhihu.com/question/25876314
But I will not use, there is no tile map ... Poor white
At this time an artifact fell from the sky, was a friend Amway learned that a high-flying war on the other side of the battle to make this high-level wars dedicated map editor!
Link: Http://pan.baidu.com/s/1qYf9d2O Password: g2gr
Ah! Niubi
Brush, edit finished, export save ~ ~ And so on! How do you read the map file after you save it? God, there is a wall, don't say to read E, even the site can not open Ah!
In the case of obtaining more information, faced with the export of *.aws files in a daze, can do, read to try it.
The first step, open the file, I dragged directly to the most powerful tool on hand VisualStudio2013, and then appeared such a bunch of hex:
Of course, except for the beginning, other human beings are not to be seen. Slowly analyzed, the beginning is the identity of the file, is a string, very simple, each file is the same, is fixed. It's not the same at the beginning, and the last part is the string.
So the key to solving the format problem is to deal with the middle string.
This kind of file is impossible to do encryption and other things, so, the good news is that just create a new map, constantly compare, you will be able to know the format of the file.
So I created a new map, saved it, and opened it with vs. Found in the middle of a large area of 0000 and FFFF, because the map is empty, it is obvious that these places are the unit fill point on the map.
A 2D map, can be seen as a two-dimensional array, the preservation of the file must have this two-dimensional array on one-dimensional expansion.
Continue to analyze, the high-war map is not like RPG,RPG usually divided into three layers: the topography of buildings and units, and there is no terrain and architecture in the high-level necessary, according to the editor design map when the way can be seen to be divided into two layers, one layer is the terrain and buildings, the second floor is moving units.
Then look at the size of the map, I created a map of 10x11 and 20x21, found that the number of 0000 and FFFF magnified, if the above layered speculation is correct, then 0000 and FFFF respectively is each layer. The 11th and 12th bytes are also changed, and the naked eye knows that the two bytes are the length and width of the map, respectively. Then count the number of 0000 and the number of FFFF, found to be the same, and is exactly the length * width of multiples, that is, a multiple of the chess lattice, just the number of *2byte, that is, a int16 represents a map unit.
Then the format is very clear ~
The first 10 bytes is a fixed string header, 11 is width,12 is the height, using byte to do the long width that the map can not be larger than 255*255. 13 is unclear, but it was later analyzed that it was a bad setting (grass, Desert, snow). Next, according to the Width*height to read the terrain units, every two bytes is a unit, after reading is the same number of mobile combat units is also 2 bytes one. The rest is the map information.
It can be seen that the map information is a string, but in the middle there are some things that are not strings. This part of the information is added to the map creator, so the length of the string is not as fixed as the title 10 bytes, will become.
The simple partitioning of a string is usually two ways: delimiter delimited, or head declaration length. It can be seen here with the naked eye is the length of the head Declaration, the head has four bytes can not be transferred to the string, but calculate the decimal is exactly the length of the string, OK, followed by the same, there are three strings.
Look at the parsed code:
1 stringPath =NULL;2 if(args. Length = =0)3 {4Debug.WriteLine ("Please enter the map file path:");5Path = Console.ReadLine (). Trim ('\"');6 }7 Else8 {9Path = args[0];Ten } One vardata =file.readallbytes (path); ADebug.WriteLine ("Start parsing ..."); -Debug.WriteLine ("------------------------------------"); - intoffset =0; the stringCapition = Encoding.ASCII.GetString (data, offset,Ten); -Debug.WriteLine ("caption:{0}", Capition,1); -Offset + =Ten; - intwidth =Data[offset]; +Offset + =1; - intHeight =Data[offset]; +Offset + =1; ADebug.WriteLine ("width:{0}, Height:{1}", width, height); at intTileset =Data[offset]; -Offset + =1; -Debug.WriteLine ("tileset:{0}", tileset); - - //Terrain - for(inti =0; i < width*height; i++) in { - ShortTerrain =bitconverter.toint16 (data, offset); toOffset + =2; + //if (I < ten) - { theDebug.WriteLine ("terrain:\t{0:x4}\t{0}", terrain); * } $ }Panax Notoginseng //Unit - for(inti =0; I < width * height; i++) the { + ShortUnit =bitconverter.toint16 (data, offset); AOffset + =2; the if(I <Ten) + { - //Debug.WriteLine ("unit:\t{0:x4}\t{0}", unit); $ } $ } - //Info - intMapnamelength =bitconverter.toint32 (data, offset); theOffset + =4; - stringMapname =Encoding.ASCII.GetString (data, offset, mapnamelength);WuyiOffset + =mapnamelength; theDebug.WriteLine ("mapname:{0}", Mapname,1); - Wu intAuthorlength =bitconverter.toint32 (data, offset); -Offset + =4; About stringAuthor =Encoding.ASCII.GetString (data, offset, authorlength); $Offset + =authorlength; -Debug.WriteLine ("author:{0}", author,1); - - intDescriptionlength =bitconverter.toint32 (data, offset); AOffset + =4; + stringDescription =Encoding.ASCII.GetString (data, offset, descriptionlength); theOffset + =descriptionlength; -Debug.WriteLine ("description:{0}", Description,1); $ theDebug.WriteLine ("------------------------------------"); theDebug.WriteLine ("Parse finished! ");
The format of the map file is resolved, and then it is the number of each unit corresponding to it.
In fact, the editing of the terrain and the final map is not the same, such as the sea and land on the border of the corner, in fact, the terrain only the sea and land points, and the map will have four corners and longitudinal transverse six kinds of maps. And the stickers just look at the good, the actual program needs to participate in the calculation is the sea/land of the addition. Roads, bridges, pipes, etc. are all the same. That is to say, the number is only the terrain, regardless of the last map on the mapping is how.
The following is a list of buildings
The terrain table is much simpler and does not differentiate between the camps.
In this way, the exported AWS file with the map PNG screenshot can easily develop a new chessboard ~ take doctrine really awesome!
Finally, the test results are as follows:
Look at the output of the unit, consistent with the units in the diagram.
The first step to re-advancewars--fix the map.