This commit is contained in:
aozhiwei 2019-03-18 10:17:13 +08:00
parent 13a82ab13d
commit 645ae32cf9
7 changed files with 27 additions and 4 deletions

View File

@ -1,6 +1,8 @@
#include "precompile.h"
#include "android.ai.h"
#include "android.h"
#include "movement.h"
void AndroidAI::Update(int delta_time)
{
@ -78,7 +80,11 @@ void AndroidAI::DoThink()
void AndroidAI::DoMove()
{
if (owner->movement) {
if (owner->movement->Arrived()) {
}
}
}
void AndroidAI::DoAttack()

View File

@ -59,6 +59,13 @@ static void SavePerfLog()
void App::Init(int argc, char* argv[])
{
#if 0
{
Vector2D v1(1, 1);
Vector2D v2 = v1.Rotate(-0.25);
int i = 0;
}
#endif
signal(SIGPIPE, SIG_IGN);
this->argc = argc;
this->argv = argv;

View File

@ -1,15 +1,11 @@
#include "precompile.h"
#if 0
#include "app.h"
#endif
int main(int argc, char* argv[])
{
int exitcode = 0;
#if 0
App::Instance()->Init(argc, argv);
exitcode = App::Instance()->Run();
App::Instance()->UnInit();
#endif
return exitcode;
}

View File

@ -25,6 +25,11 @@ bool MovementComponent::GetMovePosition(int delta_time, Vector2D& out_pos)
return true;
}
bool MovementComponent::Arrived()
{
return path_index_ >= paths_.size();
}
void MovementComponent::AddPathPoint(Vector2D& pos, float distance, float speed)
{
MovePathPoint& point = a8::FastAppend(paths_);

View File

@ -14,6 +14,7 @@ class MovementComponent
virtual void Update(int delta_time);
bool GetMovePosition(int delta_time, Vector2D& out_pos);
bool Arrived();
void AddPathPoint(Vector2D& pos, float distance, float speed);
void ClearPath();

View File

@ -41,3 +41,10 @@ Vector2D Vector2D::operator * (float scale)
Eigen::Vector2f v = Eigen::Vector2f(x, y) * scale;
return Vector2D(v[0], v[1]);
}
Vector2D Vector2D::Rotate(float angle)
{
Eigen::Vector3f v(x, y, 0);
v = Eigen::AngleAxisf(angle * 3.1415926f, Eigen::Vector3f::UnitZ()) * v;
return Vector2D(v[0], v[1]);
}

View File

@ -28,4 +28,5 @@ struct Vector2D
Vector2D operator + (const Vector2D& b);
Vector2D operator - (const Vector2D& b);
Vector2D operator * (float scale);
Vector2D Rotate(float angle);
};