In the days of working in Kunming, I was very dismissive of the manager's style, but the software engineering thought that he hung on his lips all day was very respectable. Whether it is the traditional waterfall flow, or agile development, whether it is a large system, or small functions, the first analysis of requirements, re-conceived design, re-implementation of the process is the eternal truth.
Things have not been clear to begin to do, is the naïve behavior of beginners, the more mature designers, the more emphasis on pre-demand analysis, clear thinking, coding is just "swish" things.
Habits must be cultivated from scratch. So this time I deliberately walk a complete process, even if not so adapt, also need to learn slowly. The main thing is to use Visio to draw UML diagrams before coding.
Due to the particularity of game engineering, most of the UML diagrams used in enterprise application, website design, database design are not in use, but the architecture of a software engineering is always not open to a drawing software, the idea is not to require full specification, just to borrow those shapes, but also a path. Even the most primitive use of plain text to describe the means of demand, but also better than nothing.
Not all games have a copycat before they are made, and if I'm a master planner, I'll just say "We do a DotA saga" or "We do a royal war", obviously without a future. Sooner or later I will face the original, so here is a simple explanation of "besiege" is what kind of game.
This is a single-machine physical sandbox game, players need to use the various parts of the game to assemble their own siege equipment, complete the task of each level, the mission is basically to destroy a building and the like. Its play point lies in the realistic physical effects, as well as unlimited free combination of the brain hole open, you finally assembled a machine can be cleared, looked up at the online other players to make things, probably will produce "We are playing the same game?" "The idea. This has created the divine status of this game.
Then I came to the cottage.
If it is a formal business project, we must first do a full of playability, but my goal is to practice the technology, so maybe this project is not very suitable for porting to the mobile phone, such as a lot of operational design of the mishap, I ignored.
The idea is to simplify, abandon the level design, directly into the main scene, can be assembled, can run, enough.
I have made it into an online version of the idea, considering their own service-side experience is shallow, the first stage of the architecture is not considered online, first make a stand-alone version, and then study how to transform into a multiplayer battle.
So the core function is probably this:
Assembly Stage:
1. Press the module corresponding button, the module prompt icon appears
2. While dragging, the icon moves with the finger
3. When the contact point enters the existing module can be connected to the range, determine whether the new module can be linked to the existing module. If possible, the new module prompts, at this time Wakamatsu hand, then create a new module in the node and link, if not let go of the range, the new module hints disappear.
Run phase:
1. Activate all modules
2. Press the control button to trigger the corresponding function
Note that the main loop structure of the game and desktop applications, though essentially the same, has a major difference in performance.
Is the latter is generally a message-driven, such as mouse click, what to do, the keyboard pressed down, what to do, and no input, the basic is an empty loop do not do.
And the game is a busy to the death of the program, even if there is no input, it is crazy to screen rendering, the basic only hate the CPU is not enough, rarely said to let the CPU rest.
Is there an exception? A few games that do not have high performance requirements can use this to do some power-saving optimization? Or has the engine frame been optimized for us? I can't even talk nonsense.
Anyway think about three years ago just learn to play the time to reduce CPU occupancy rate active online bunch sleep (), all only give three words "take clothes."
However, now this game is really like the application software, at least in the assembly mode, in addition to responding to various operations, there is nothing else to do. So, on the schema, it naturally degrades to the message driver's appearance.
The main loop is actually hidden in Easytouch's update (), and our own code is just as good as binding some On_touchstart, On_touchdown, On_touchup, and the update () is empty. The code looks very much like I did before to look at the diagram software.
Paste part of the core code:
public void Changemode ()//Response "Run/Return" button method {switch (gamestate) {case Gamestate.assemblin G:changetorunningstate (); Break Case GameState.Running:ChangeToAssemblingState (); Break Default:break; }} private void Changetorunningstate () {gamestate = gamestate.running; Unbind ET events of assembling state easytouch.on_touchstart-= on_touchstartassembling; Easytouch.on_touchdown-= on_touchdownassembling; Easytouch.on_touchup-= on_touchupassembling; Create a new copy of machine for running, hide the old one runtimemachine = instantiate (machine); Machine. SetActive (FALSE); Activate all modules on machine rigidbody[] rigs = runtimemachine.getcomponentsinchildren<rigidbody> (); foreach (Rigidbody R in rigs) {r.usegravity = true;R.iskinematic = false; }//bind ET events of Running State} private void Changetoassemblingstate () {gamestate = Gamestat e.assembling; Unbind ET events of Running State//destroy Runtimemachine, show the one for assembling destroy (Runtimemac Hine); Machine. SetActive (TRUE); Unbind ET events of assembling state easytouch.on_touchstart + = on_touchstartassembling; Easytouch.on_touchdown + = on_touchdownassembling; Easytouch.on_touchup + = on_touchupassembling; }
Now the response method of the Runningmode I have not added, the method of activating the part is only for the special type of small wood block, later will be changed to call different types of parts of the corresponding method.
And then I tried to draw the class diagram for each module:
This design will certainly be changed after, may do to find a method does not need, and some other methods to add in. This should not be the design itself is debatable, such as the power Wheel is to inherit from the follower and the like, we do not care about these, the wrong pre-design is always better than not pre-design.
In addition, I can see some clues from this diagram, for example, because all the engine gameobject have their own transform components, and Unity provides the Rigidbody component has already included the quality of this parameter, in fact, some simple classes have no need to design their own, Just include the basic components. In addition, like wheels and hinges, these classes may introduce some of the relevant components of unity, and can save many methods and members.
The camera control module is relatively independent, and the general requirement is this:
A. Assembly phase
1. Always focus on machine centroid
2. The camera rotates around the target while sliding the screen
3. Two-finger stretching adjusts the camera distance to the target
B. Operational phase
1. Follow the view after maintaining the target
I was completely reassured by the fact that I was doing a lot of camera control at work.
I'm not too familiar with the wheels and hinges of the unity physics engine, and then I want to do some of what I call the "core technology tackle", which is to do some testing before you formally do the project.
The existing hundred line code has implemented a 7788 function for the assembly phase.
Then directly to do a control of the car, steering, should be able to run the main work of the stage is covered, and then is the code integration work.
Finally, the next few days to the UI code this piece of some thinking.
Is it primarily a function such as whether some of the features that are involved in UI buttons are scattered around the script that binds to each UI element, or is it better to focus on one of the main controls?
At first I was inclined to the latter, so that the code is not too fragmented, easier to read, but then think about it, in fact, the function code tied to its related trigger source is not so difficult to understand, but more intuitive.
Practical work to understand again, a matter of opinion.
Cottage Besiege (iii) demand analysis and architecture design