diff --git a/server/gameserver/android.ai.cc b/server/gameserver/android.ai.cc index fe96022..b7ae562 100644 --- a/server/gameserver/android.ai.cc +++ b/server/gameserver/android.ai.cc @@ -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() diff --git a/server/gameserver/app.cc b/server/gameserver/app.cc index 0e5e867..04a1438 100755 --- a/server/gameserver/app.cc +++ b/server/gameserver/app.cc @@ -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; diff --git a/server/gameserver/main.cc b/server/gameserver/main.cc index b413131..7dffbf1 100644 --- a/server/gameserver/main.cc +++ b/server/gameserver/main.cc @@ -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; } diff --git a/server/gameserver/movement.cc b/server/gameserver/movement.cc index a9da52c..b6017b2 100644 --- a/server/gameserver/movement.cc +++ b/server/gameserver/movement.cc @@ -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_); diff --git a/server/gameserver/movement.h b/server/gameserver/movement.h index f8fcbd7..dadcf3e 100644 --- a/server/gameserver/movement.h +++ b/server/gameserver/movement.h @@ -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(); diff --git a/server/gameserver/types.cc b/server/gameserver/types.cc index 9058c0b..75b4a99 100644 --- a/server/gameserver/types.cc +++ b/server/gameserver/types.cc @@ -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]); +} diff --git a/server/gameserver/types.h b/server/gameserver/types.h index c54ceda..7905345 100755 --- a/server/gameserver/types.h +++ b/server/gameserver/types.h @@ -28,4 +28,5 @@ struct Vector2D Vector2D operator + (const Vector2D& b); Vector2D operator - (const Vector2D& b); Vector2D operator * (float scale); + Vector2D Rotate(float angle); };