-
NPBehave (Assets/ThirdParty/NPBehave): Event driven Behavior Tree Library.
-
Tiling rules (Assets/ThirdParty/Settings/Ground) : The rules Editor of combining ground tiles in the level generator.
-
Sprites (Assets/ThirdParty/Sprites): All sprites used in the tech demo.
-
Animations (Assets/Animation): All animations used in the boss, player and effects, except Fire animation of boss.
-
Some functions of boss:
LookAtPlayer (Assets/Agent/Boss/Boss.cs): Implementation of turning the boss to face the player.
All functions in Boss_Move class (Assets/Agent/Boss/Boss_Move.cs): Defining the behaviour when the boss enters the moving state.
Attack, EnragedAttack and OnDrawGizmosSelected (Assets/Agent/Boss/BossWeapon.cs): Logic of boss attacking and debug of attacking range.
-
Some functions or IEnumerators of player:
Move and Flip (Assets/Agent/Player/CharacterController2D.cs): Logic of player moving and flipping.
Die and DamageAnimation (Assets/Agent/Player/PlayerHealth.cs): Logic of player dying and taking damage animation.
All functions in PlayerMovement class (Assets/Agent/Player/PlayerMovement.cs): Logic of player's movement.
Shoot (Assets/Agent/Player/PrefabWeapon.cs): Logic of player shooting/Firing.
-
Some functions of level generator:
GenerateMap, GenerateArray, PerlinNoiseCave and OnInspectorGUI (Assets/Generator/Level/LevelGenerator.cs): Generating base 2D arrays for the generator with default perlin noise from Mathf.PerlinNoise and GUI settings for generating and clearing.
All functions in RuleTile and RuleTileEditor class (Assets/Generator/Level/RuleTile.cs and RuleTileEditor.cs): The logic of rule tiles and tile editor.
-
The boss comes out once the player lands on the boss battle stage at the bottom of the level. (FixedUpdate in Assets/Agent/Player/CharacterController2D.cs)
-
Once the boss comes out and finishes the introduction animation, its behaviour tree starts. (OnStateExit in Assets/Agent/Boss/Boss_Intro.cs)
-
The tree first checks if it is enraged. If so, the boss follows phase two behaviours (PhaseTwoBehaviour in Assets/Agent/Boss/Boss.cs). If not, then check whether the health is below a certain value. If so, the boss enters enraging state (EnrageBehaviour in Assets/Agent/Boss/Boss.cs). If not, the boss follows phase one behaviours (BehaviourTree in Assets/Agent/Boss/Boss.cs). All actions (except looking at player and waiting) are executed when the boss is in the specific state (animation finite state machine).
-
In phase one subtree (PhaseOneBehaviour in Assets/Agent/Boss/Boss.cs), the boss looks at the player at first, then waits for 0.5 second to allow the last state continue for a while. Subsequently, the boss enters attacking state the player if the player is in the attacking range. If not, the boss selects between moving and firing state and the result is more likely to be moving to the player. The boss only fires (sword wind, less damage than melee) at the player only when the player is in the firing range.
-
In phase two subtree (PhaseTwoBehaviour in Assets/Agent/Boss/Boss.cs), the boss also looks at the player at first. Then it enters the running to the player state (faster than in phase one). It attacks the player if the player is in the attacking range (faster and more damage in than phase one).
-
The boss dies when its health is below 0 and the tree stops (TakeDamage and Die in Assets/Agent/Boss/BossHealth.cs).
-
In GameObject **LevelGenerator **GUI, there are few features which can be adjusted, including Random Seed, Edges Are Walls (Ticking it would close all paths to the boss battle stage), Modifier (Perlin Noise parameter, the bigger it is, the more shattered the level would be), Danger Degree (controls the proportion of spikes), Potion Num (controls the proportion of potions), Player Event Num (controls the proportion of player events).
-
Spike: Damage the player by a fixed value and can be destroyed. Potion: Randomly damage the player or recover the player's health between a range. Player Event: Randomly choose among changing the cool down of player's bullet, changing player's running speed, changing player's jump force, changing the speed of player's bullet, and changing the damage of player's bullet.
-
Whether running or not, level can be generated and cleared in GameObject **LevelGenerator **GUI. Besides, when running, the level can be regenerated by pressing 'N'.
-
The level is generated in function GenerateMap (Assets/Generator/Level/LevelGenerator.cs). first a 2D array is initialized with 0 (GenerateArray) and then Mathf.PerlinNoise is used to generate 2D Perlin Noise with tiles represented by 1 in the array (PerlinNoiseCave). Then in RenderMap, the grid is set as tile if its corresponding value is 1 in the array. After that, at the positions of the grids whose corresponding value are 0, spikes, potions and player events are randomly (due to the value of Danger Degree, Potion Num and Player Event Num) instantiated. Subsequently the player's initial position will be randomly set onto one tile on the top row. Then the boss battle stage's position and width keep being generated with some limits to make sure it is under the level, until there is a channel of a certain length for the player to arrive at the stage (existPath). Finally, the position of boss on the stage is randomly generated.
- Move: WASD / ↑←↓→
- Fire: Space
- Restart: N
(280) Two Phases Boss Fight with Generated Levels in Unity - YouTube