This commit is contained in:
2026-02-08 16:20:50 +08:00
parent 0ae47e5d6a
commit 8b88904ef7
72 changed files with 5963 additions and 2038 deletions

View File

@@ -19,7 +19,7 @@ VecSpeed3 ActiveObject::GetSpeed()
return this->Speed;
}
void ActiveObject::Update(float deltaTime)
void ActiveObject::OnUpdate(float deltaTime)
{
VecFPos3 MovePos;
@@ -51,6 +51,4 @@ void ActiveObject::Update(float deltaTime)
}
MoveBy(MovePos);
BaseObject::Update(deltaTime);
}

View File

@@ -11,13 +11,12 @@ public:
int _zRemainderMove = 0;
public:
void
SetPosition(VecFPos3 pos) override;
void SetPosition(VecFPos3 pos) override;
void SetYpos(int y) override;
void SetSpeed(VecSpeed3 speed);
VecSpeed3 GetSpeed();
public:
void Update(float deltaTime) override;
void OnUpdate(float deltaTime) override;
};

View File

@@ -3,7 +3,7 @@
BaseObject::BaseObject()
{
Init(); // 调用了RenderBase的Init函数 对象才会被执行回调
// 对象要使用中心锚点
SetAnchor({0.5f, 0.5f});
}
@@ -11,21 +11,16 @@ BaseObject::~BaseObject()
{
}
void BaseObject::Update(float deltaTime)
{
Actor::Update(deltaTime);
}
void BaseObject::SetPosition(VecFPos3 pos)
{
if(pos == this->Position)
return;
if (pos.y != this->Position.y)
{
SetRenderZOrder(pos.y); // 设置渲染顺序
SetZOrder(pos.y); // 设置渲染顺序
}
this->Position = pos;
SetPos(Vec2{this->Position.x, this->Position.y - this->Position.z});
Actor::SetPosition(this->Position.x, this->Position.y - this->Position.z);
}
VecFPos3 BaseObject::GetPosition()
@@ -38,7 +33,7 @@ void BaseObject::SetXpos(int x)
if (x == this->Position.x)
return;
this->Position.x = x;
SetPos({this->Position.x, this->Position.y - this->Position.z});
Actor::SetPosition(this->Position.x, this->Position.y - this->Position.z);
}
void BaseObject::SetYpos(int y)
@@ -47,10 +42,10 @@ void BaseObject::SetYpos(int y)
return;
if (y != this->Position.y)
{
SetRenderZOrder(y); // 设置渲染顺序
SetZOrder(y); // 设置渲染顺序
}
this->Position.y = y;
SetPos({this->Position.x, this->Position.y - this->Position.z});
Actor::SetPosition(this->Position.x, this->Position.y - this->Position.z);
}
void BaseObject::SetZpos(int z)
@@ -58,7 +53,7 @@ void BaseObject::SetZpos(int z)
if (z == this->Position.z)
return;
this->Position.z = z;
SetPos({this->Position.x, this->Position.y - this->Position.z});
Actor::SetPosition(this->Position.x, this->Position.y - this->Position.z);
}
int BaseObject::GetXpos()
@@ -84,11 +79,11 @@ void BaseObject::MoveBy(VecFPos3 pos)
return;
if (RealPos.y != this->Position.y)
{
SetRenderZOrder(RealPos.y); // 设置渲染顺序
SetZOrder(RealPos.y); // 设置渲染顺序
}
if (RealPos != this->Position){
this->Position = RealPos;
SetPos({this->Position.x, this->Position.y - this->Position.z});
Actor::SetPosition({this->Position.x, this->Position.y - this->Position.z});
}
}
@@ -100,28 +95,28 @@ void BaseObject::MoveBy(int x, int y, int z)
return;
if (RealPos.y != this->Position.y)
{
SetRenderZOrder(RealPos.y); // 设置渲染顺序
SetZOrder(RealPos.y); // 设置渲染顺序
}
if (RealPos != this->Position)
{
this->Position = RealPos;
SetPos({this->Position.x, this->Position.y - this->Position.z});
Actor::SetPosition({this->Position.x, this->Position.y - this->Position.z});
}
}
void BaseObject::SetDirection(int dir)
{
this->Direction = dir;
Vec2 sc = GetScale();
glm::vec2 sc = GetScale();
// 朝右
if (dir == 0)
{
SetScale(Vec2({SDL_fabsf(sc.x), sc.y}));
SetScale(SDL_fabsf(sc.x), sc.y);
}
// 朝左
else if (dir == 1)
{
SetScale(Vec2({-SDL_fabsf(sc.x), sc.y}));
SetScale(-SDL_fabsf(sc.x), sc.y);
}
}

View File

@@ -16,8 +16,6 @@ public:
BaseObject(/* args */);
~BaseObject();
void Update(float deltaTime) override;
// 数据储存器
ObjectVars _ObjectVars;

View File

@@ -1,5 +1,7 @@
#include "CharacterObject.h"
#include "Asset/Squirrel/SquirrelManager.h"
#include "Actor/Map/GameMap.h"
#include "Actor/Map/GameWorld.h"
CharacterObject::~CharacterObject()
{
@@ -12,9 +14,6 @@ void CharacterObject::Construction(int job)
// 创建装备管理器
_EquipmentManager = new Chr_Equipment();
_EquipmentManager->Init(this);
// // 创建阴影对象
// _Shadow = new Chr_Shadow();
// _Shadow->Init(this);
// 创建动画管理器(一定要先创建装备管理器再创建动画管理器 因为需要读取身上的装备)
_AnimationManager = new Chr_Animation();
_AnimationManager->Init(this);
@@ -51,19 +50,35 @@ void CharacterObject::ControllerMsg(CONTROLLER_MSG_TYPE msgType, void *msgData)
}
}
void CharacterObject::Update(float deltaTime)
void CharacterObject::SetPosition(VecFPos3 pos)
{
ActiveObject::Update(deltaTime);
}
void CharacterObject::SetPos(Vec2 pos)
{
BaseObject::SetPos(pos);
if(_Shadow)_Shadow->SetPos(this->GetPos());
BaseObject::SetPosition(pos);
}
void CharacterObject::SetDirection(int dir)
{
BaseObject::SetDirection(dir);
if(_Shadow)_Shadow->SetDirection(this->GetDirection());
}
void CharacterObject::OnUpdate(float deltaTime)
{
ActiveObject::OnUpdate(deltaTime);
// 判断是否要进行区域移动
if (!IsTeleportArea)
{
GameMap::MapMoveArea Info = this->_AffMap->CheckIsItMoveArea(this->GetPosition());
if (Info.town != -2 && Info.area != -2)
{
IsTeleportArea = true;
// 调用世界类移动自己
GameWorld::GetWorld()->MoveCharacter(this, Info.town, Info.area);
}
}
else
{
GameMap::MapMoveArea Info = this->_AffMap->CheckIsItMoveArea(this->GetPosition());
if (Info.town == -2 && Info.area == -2)
IsTeleportArea = false;
}
}

View File

@@ -1,10 +1,10 @@
#pragma once
#include "EngineFrame/Base/Actor.h"
#include "Actor/Object/ActiveObject.h"
#include "Asset/Character/Chr_Animation.h"
#include "Asset/Character/Chr_Equipment.h"
#include "Asset/Character/Chr_Controller.h"
#include "Asset/Character/Chr_StateMachine.h"
#include "Asset/Character/Chr_Shadow.h"
#include "Global/Global_Enum.h"
class CharacterObject : public ActiveObject
{
@@ -18,12 +18,12 @@ public:
// 角色状态机
RefPtr<Chr_StateMachine> _StateMachine = nullptr;
// 角色阴影对象
RefPtr<Chr_Shadow> _Shadow = nullptr;
// 职业
int Job = 0;
// 转职职业 如果是-1则没有转职
int GrowType = -1;
/** 传送区域Flag */
bool IsTeleportArea = false;
public:
~CharacterObject();
@@ -39,7 +39,8 @@ public:
// 控制器信息
void ControllerMsg(CONTROLLER_MSG_TYPE msgType, void* msgData);
void Update(float deltaTime) override;
void SetPos(Vec2 pos) override;
void SetPosition(VecFPos3 pos) override;
void SetDirection(int dir) override;
void OnUpdate(float deltaTime) override;
};