当前位置:网站首页>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 )
边栏推荐
- In depth analysis of kubernetes controller runtime
- 【开源项目推荐-ColugoMum】这群本科生基于国产深度学习框架PaddlePadddle开源了零售行业解决方案
- ODL framework project construction trial -demo
- pytorch练习小项目
- [C /vb.net] convert PDF to svg/image, svg/image to PDF
- 冒泡排序的简单理解
- [set theory] equivalence relation (concept of equivalence relation | examples of equivalence relation | equivalence relation and closure)
- 有意思的鼠标指针交互探究
- Local rviz call and display of remote rostopic
- 学习笔记 -- k-d tree 和 ikd-Tree 原理及对比
猜你喜欢

Cesium 点击获三维坐标(经纬度高程)

有意思的鼠標指針交互探究

Kubesphere - Multi tenant management

Simple understanding of ThreadLocal

ssh链接远程服务器 及 远程图形化界面的本地显示

Cesium 点击获取模型表面经纬度高程坐标(三维坐标)

Une exploration intéressante de l'interaction souris - pointeur

. Net program configuration file operation (INI, CFG, config)

远端rostopic的本地rviz调用及显示

IE browser flash back, automatically open edge browser
随机推荐
arcgis创建postgre企业级数据库
Une exploration intéressante de l'interaction souris - pointeur
The most classic 100 sentences in the world famous works
[untitled] 8 simplified address book
Time format record
简易密码锁
Advanced technology management - do you know the whole picture of growth?
Cesium entity(entities) 实体删除方法
数值法求解最优控制问题(一)——梯度法
Zhiniu stock -- 03
Judge whether the date time exceeds 31 days
UNI-APP中条件注释 实现跨段兼容、导航跳转 和 传参、组件创建使用和生命周期函数
About the difference between count (1), count (*), and count (column name)
YOLOV2学习与总结
Exportation et importation de tables de bibliothèque avec binaires MySQL
2022年华东师范大学计科考研复试机试题-详细题解
论文笔记 VSALM 文献综述《A Comprehensive Survey of Visual SLAM Algorithms》
[untitled] 5 self use history
JMeter linked database
[5g NR] UE registration process