Cocos2d-x-3.3-023-imitation aircraft war-overall analysis and modeling, cocos2dx3.3
The original text is synchronously published on my wiki. To view the original text or updates, go to: Click the open link.
Overall Analysis
Detailed Item Analysis
Aircraft: Our fighters and enemy planes are all planes, the camp is different. Planes can be damaged. Planes can be repaired. Planes have guns. Bullets are fired. Planes have flight speeds. Planes have directions. Planes can get supply guns: the number of bullets fired at a time is different for different types of guns, and the number of bullets fired at a time is different: lethal, after a powerful bullet kills the enemy, its life cycle also ends? Bullet eye? Can a bullet hurt people in the same camp? First, there is no eye, there is no tangle of bullets, there is a speed, there is a starting position, the bullets have a direction to supply-blood package: + blood supply-double-row guns: Gun change, after a bullet hits the light, it switches back to the default Gun Supply-bomb: several missiles are mounted to the plane. After the bullet is launched, the whole screen will destroy the blame, supply speed, supply start position, supply direction
The following figure shows how to create a family chart.
Https://github.com/cheyiliu/All-in-One/raw/master/res/cocos2d/warofairplain.jpg
Description
Role: Role Definition. attributes include: Team, blood volume, attack power, and resources. Actions include determining that an enemy is a friend, attacking, being attacked, and obtaining various supplies; roleHero provides the static factory method RoleHero, which has the following attributes: Multiple guns are used for remote attacks; Various supplies are available; RoleEmemy: enemies: only attacks and attacks can be performed. RoleEnemy has three sub-classes, representing large, medium, and small enemies, and is responsible for instantiating different resources.
Supply: Replenishment class, which defines basic methods and factory methods. Supply has three sub-classes for different replenishment tasks.
- Gun and ammunition Series
Gun: a Gun that can be used to fire a bullet. It contains a static factory method. Gun has three sub-classes, containing different bullets, representing different guns. Bullet: Bullet base class, attributes are powerful, resources, and so on; behavior is killing; static factory methods are also available (for later development, check whether the requirements need to be separately separated from the factory class) bullet has three sub-classes, representing different types of bullets.
Why do we need to provide so many sub-classes? Each system has several sub-classes. My idea is that I don't want to use too many if else when selecting different resources to represent different types of objects. If it is not subclass, the parent class will carry too many judgment statements. The above supplies and ammunition systems all act on aircraft systems.
Draft Code
- Recently with java more, first with java made a draft, sorted out the idea, the above class corresponding code in https://github.com/cheyiliu/test4java/tree/master/src/test/cocos/airplain
- The next step is to use c ++ and cocos mechanisms. Follow the relationships of the above classes as much as possible during implementation. Of course, necessary adjustments are inevitable.