To simplify the movement of the boss, we temporarily make a grid-based movement of the boss.
This is implemented in the "gridbase" branch in git.
The main logic is implemented GridObject class.
Properties:
width, height imply the size of the boss, counted in tiles.
ox, oy imply the center of the boss, (0, 0) specify the left-top, counted in tiles.
NOTE: The boss's volume is calculated as transform.position.x + width * unit, transform.position.y + height * unit, that is, the left-top corner is the position of transform component.
Functions:
Move(int dx, int dy, bool slide)
dx, dy should be -1, 0, 1. If not moving, then go to adjacent grid, otherwise do nothing. It's the only useful function.
if slide is false, you will stop when colliding walls, otherwise you will slide on the wall if you can.
------
Based on GridObject, we implement new BossBahaviour and BossSequence.
For BossBehaviour call RunSeq() to run a new sequence, which is a sequences of commands.
Inherit BossSequence to implement a new behaviour, and override the Run() function, that's how we make AI.
Run is a coroutine function, useful functions:
Move(dx, dy, slide)
You should call like this:
"yield return Move(dx, dy, slide)"
then the coroutine will wait until movement finished. Otherwise you initiate a move and go on.
If the move is finished or failed, you can call IsLastMoveFailed() to check whether the move succeeds.
------
I have implemented a simple sequence STrace.
-----
Maybe we could use a script to write the AI.
==================================
Next
Maybe more information after movement is failed.
Moving speed.
Turning around.
Shooting.
No comments:
Post a Comment