当前位置:网站首页>Summary of the design and implementation of the weapon system similar to the paladin of vitality
Summary of the design and implementation of the weapon system similar to the paladin of vitality
2022-07-03 06:33:00 【I'm coding】
Summary of the design and implementation of the weapon system similar to the vitality Knight
introduction
This year I made a similar The project of vitality Knight , The poor road is responsible for the weapon system module . Put the weapon module Main organizational structure Here I share with you all . The poor road is still shallow , Please also give me more advice ! If you don't understand something, you can leave a message for me , Be sure to know everything , can ~~
One . Demand analysis
I believe everyone has played or learned about the vitality knight more or less ( If you don't go out, turn left and play next ), Need is to be with the vitality Knight 10 Fen is the same Our weapon system .
1. Weapon category
Guns ( pistol , Submachine gun , Shotgun , sniper rifle ), Cannons ( The rockets , Railgun ), Laser gun , arch , Close combat ( The knife , The sword , gun ), Staff of Dharma , Missiles ( Boomerang , Poison Bottle )…
2. Implementation mechanism
Rate of fire , Offset , combo , laser , Bullets fire bullets , Storing force , summoned , track 、 Bessel curve 、 Simple and harmonic 、 Orbit and other tracks , Switch weapon form …
From the player
3. Trigger mode
Automatic triggering , Single point trigger , Long press and hold to trigger , The accumulated force is automatically released , Release the accumulator , The accumulated force is continuously released …
4. Release ( launch ) The way
Sequential single release , Release all in sequence , Weight individual release , The power storage state is released …
Two . framework design
1. Design principles
a. Unbound relationships do not hold objects to each other , Asynchronous operation will result in object fetching failure , If there is a need, you can save the object id, Check when you use .
b. Member objects should not go to the holder object to get data , But by the holder set. In other words , Does not depend on the holder object , Rely on the data provided by the holder . This ensures that any object holds the member object , Superiors drive subordinates , as long as set data , This member object can run normally .
2. Design thinking
be aware , FireStarter ( I abstract the act of firing bullets as firing ) It is not a unique behavior of weapons , Like skills , equipment ( Some equipment will automatically release lightning around ), The monster AI Will fire , So take the fire away from the weapon .
Different guns have different trigger methods (FireListener), Different ways of using the transmitter (FireBehavoir)( For example, the attack method of the knife is horizontal cutting , Vertical chop , Slash … It is a single point trigger + Sequential single release , The attack method of the magic wand is to slash and release a circle of bullets at the same time, which is a single point + Release all in sequence ), Their polymorphism is based on combinatorial relationships fire Member objects of . Please note that , The combination relationship does not mean that they can combine freely , And not necessarily FireListener,FireListener The responsibility is to monitor the player's operation setting status and decide to fire , for example AI You can set the state and decide when to fire .
Notice that there is a state dependency between the two ( such as The release of the power storage state depends on the power storage value provided by the power storage trigger ), How should they communicate with each other ? There are two ways of thinking :
1. One is more strict “ Who creates who manages ”, Producers produce products , Consumers take products from producers , And tell the producer that I have consumed . Producers get the news of consumption , Then remove this batch of products from the list . As for whether it was really rowed away , Consumers don't care , Consumers only care about whether they can get products .
2. Another way is to build a warehouse , The producer produces products and sends them to the warehouse , The administrator records how many products are added . Consumers go to the warehouse area to pick up products , And tell the warehouse keeper how many products have been taken .
Each of these two ways has its own advantages , Here choose the second way , Use FireState Management status .
Complete process :FireListener Monitor the player's operation , Come on set FireState The state of , And decided to fire . When firing ,FireBehavoir Decide which transmitters to create according to the status and configuration (Launcher) And set the status of these transmitters . thus , The internal work of the weapon system is completed . The launcher then decides how to fire bullets according to the status and configuration table .
See class diagram and class responsibility division for specific details .
3. Class diagram

4. Division of responsibilities of classes
a.Weapon: Modification of attribute appearance and action ; Respond to input notifications Fire; Switch mode …
b.Fire: FireStarter ; Input message received , notice FireListener; Fire sound , action , shock …;cd Record , Firing condition judgment …; Attribute snapshot ;
c.FireState: State information
d.FireListener: Polymorphism responds according to the player's firing key ,“ production ” state , Decided to fire .
e.FireBehavoir: Polymorphism determines which emitters are created and sets emitter status based on status and configuration ,“ consumption ” state , notice Fire Firing completed .
So far, the internal responsibilities of the weapon system have been completed
f.Launcher: How to create bullets depends on the status and configuration , And set the bullet status .
g.bullet According to the State 、 Configuration and triggers determine how emitters are created .( Its trajectory and other behaviors are not discussed here )
边栏推荐
- Use @data in Lombok to simplify entity class code
- [set theory] relational closure (relational closure solution | relational graph closure | relational matrix closure | closure operation and relational properties | closure compound operation)
- How matlab modifies default settings
- Merge and migrate data from small data volume, sub database and sub table Mysql to tidb
- Difference between shortest path and minimum spanning tree
- 使用conda创建自己的深度学习环境
- 堆排序和优先队列
- YOLOV3学习笔记
- Floating menu operation
- Chapter 8. MapReduce production experience
猜你喜欢

表达式的动态解析和计算,Flee用起来真香

Project summary --01 (addition, deletion, modification and query of interfaces; use of multithreading)

Yolov2 learning and summary

【系统设计】邻近服务

Install VM tools

The list of "I'm crazy about open source" was released in the first week, with 160 developers on the list

Mysql

Zhiniu stock project -- 05

Selenium - by changing the window size, the width, height and length of different models will be different

SQL implementation merges multiple rows of records into one row
随机推荐
Opencv mouse and keyboard events
Cesium Click to obtain the longitude and latitude elevation coordinates (3D coordinates) of the model surface
POI dealing with Excel learning
Openresty best practices
Push box games C #
剖析虚幻渲染体系(16)- 图形驱动的秘密
2022 CISP-PTE(三)命令执行
Chapter 8. MapReduce production experience
.NET程序配置文件操作(ini,cfg,config)
Simple understanding of bubble sorting
[C /vb.net] convert PDF to svg/image, svg/image to PDF
Selenium - by changing the window size, the width, height and length of different models will be different
A letter to graduating college students
Paper notes vsalm literature review "a comprehensive survey of visual slam algorithms"
Apifix installation
100000 bonus is divided up. Come and meet the "sister who braves the wind and waves" among the winners
opencv鼠标键盘事件
Time format record
Know flex box
JMeter performance automation test