walk fixed, animated text changes
This commit is contained in:
parent
400afa9981
commit
ad82c549b8
|
@ -25,6 +25,7 @@
|
|||
#include "map.h"
|
||||
#include <framework/core/clock.h>
|
||||
#include <framework/core/eventdispatcher.h>
|
||||
#include <framework/graphics/graphics.h>
|
||||
|
||||
AnimatedText::AnimatedText()
|
||||
{
|
||||
|
@ -46,7 +47,7 @@ void AnimatedText::start()
|
|||
void AnimatedText::draw(const Point& p)
|
||||
{
|
||||
if(m_font)
|
||||
m_font->renderText(m_text, Rect(p + Point(0, -20.0 * g_clock.timeElapsed(m_startTime) / (DURATION / 1000)), m_textSize), Fw::AlignTopCenter, m_color);
|
||||
m_font->renderText(m_text, Rect(p + Point(20 - m_textSize.width() / 2, -20.0 * g_clock.timeElapsed(m_startTime) / (DURATION / 1000)), m_textSize), Fw::AlignLeft, m_color);
|
||||
}
|
||||
|
||||
void AnimatedText::setColor(int color)
|
||||
|
|
|
@ -130,14 +130,14 @@ void Creature::drawInformation(int x, int y, bool useGray, const Rect& rect)
|
|||
Rect backgroundRect = Rect(x-(13.5), y, 27, 4);
|
||||
backgroundRect.bound(rect);
|
||||
|
||||
Rect textRect = Rect(x - m_nameSize.width() / 2.0, y-15, m_nameSize);
|
||||
Rect textRect = Rect(x - m_nameSize.width() / 2.0, y-12, m_nameSize);
|
||||
textRect.bound(rect);
|
||||
|
||||
// distance them
|
||||
if(textRect.top() == rect.top())
|
||||
backgroundRect.moveTop(textRect.top() + 15);
|
||||
backgroundRect.moveTop(textRect.top() + 12);
|
||||
if(backgroundRect.bottom() == rect.bottom())
|
||||
textRect.moveTop(backgroundRect.top() - 15);
|
||||
textRect.moveTop(backgroundRect.top() - 12);
|
||||
|
||||
// health rect is based on background rect, so no worries
|
||||
Rect healthRect = backgroundRect.expanded(-1);
|
||||
|
@ -251,7 +251,7 @@ void Creature::updateWalk()
|
|||
g_dispatcher.scheduleEvent(std::bind(&Creature::updateWalk, asCreature()), m_walkTimePerPixel);
|
||||
}
|
||||
|
||||
void Creature::cancelWalk(Otc::Direction direction)
|
||||
void Creature::cancelWalk(Otc::Direction direction, bool)
|
||||
{
|
||||
m_walking = false;
|
||||
m_walkStart = 0;
|
||||
|
|
|
@ -62,7 +62,7 @@ public:
|
|||
|
||||
virtual void walk(const Position& position, bool inverse = true);
|
||||
void turn(Otc::Direction direction);
|
||||
virtual void cancelWalk(Otc::Direction direction);
|
||||
virtual void cancelWalk(Otc::Direction direction, bool force = false);
|
||||
Point getWalkOffset() { return m_walkOffset; }
|
||||
|
||||
bool isWalking() { return m_walking; }
|
||||
|
|
|
@ -28,10 +28,12 @@
|
|||
LocalPlayer::LocalPlayer()
|
||||
{
|
||||
m_clientWalking = false;
|
||||
m_nextWalkDirection = Otc::InvalidDirection;
|
||||
}
|
||||
|
||||
void LocalPlayer::clientWalk(Otc::Direction direction)
|
||||
{
|
||||
// We're not walking, so start a client walk.
|
||||
if(!m_walking) {
|
||||
Position newPos = m_position + Position::getPositionFromDirection(direction);
|
||||
Creature::walk(newPos, false);
|
||||
|
@ -41,33 +43,59 @@ void LocalPlayer::clientWalk(Otc::Direction direction)
|
|||
|
||||
void LocalPlayer::walk(const Position& position, bool inverse)
|
||||
{
|
||||
// This can only be received by protocol, so its always inverse.
|
||||
|
||||
// If we're already walking, just finish it.
|
||||
if(m_clientWalking) {
|
||||
m_clientWalking = false;
|
||||
|
||||
Position pos = Position::getPositionFromDirection(m_direction);
|
||||
Point walkOffset = Point(m_walkOffset.x - pos.x * 32,
|
||||
m_walkOffset.y - pos.y * 32);
|
||||
|
||||
Creature::walk(position, inverse);
|
||||
|
||||
// Restore walk offset, because we were already walking.
|
||||
m_walkOffset = walkOffset;
|
||||
m_clientWalking = false;
|
||||
}
|
||||
else {
|
||||
m_walkOffset.x = 0;
|
||||
m_walkOffset.y = 0;
|
||||
// If we're not client walking, we'll just walk like every NPC. Ie: When player is pushed.
|
||||
else
|
||||
Creature::walk(position, inverse);
|
||||
}
|
||||
}
|
||||
|
||||
void LocalPlayer::cancelWalk(Otc::Direction direction)
|
||||
void LocalPlayer::cancelWalk(Otc::Direction direction, bool force)
|
||||
{
|
||||
// Server said we cant walk. Ie: houses, vip areas.
|
||||
if(force) {
|
||||
m_clientWalking = false;
|
||||
Creature::cancelWalk(direction);
|
||||
}
|
||||
else {
|
||||
// Walk finished, and we already received the confirmation from server.
|
||||
if(m_walking && !m_clientWalking) {
|
||||
m_clientWalking = false;
|
||||
Creature::cancelWalk(direction);
|
||||
|
||||
if(m_nextWalkDirection != Otc::InvalidDirection) {
|
||||
g_game.walk(m_nextWalkDirection);
|
||||
m_nextWalkDirection = Otc::InvalidDirection;
|
||||
}
|
||||
}
|
||||
//else..
|
||||
// Walk finished, however we havent received the confirmation from server. So wait for it.
|
||||
}
|
||||
}
|
||||
|
||||
bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||
{
|
||||
if(m_walking)
|
||||
if(m_walking) {
|
||||
if(direction != m_direction && m_nextWalkDirection != direction)
|
||||
m_nextWalkDirection = direction;
|
||||
else if(direction == m_direction && m_nextWalkDirection != Otc::InvalidDirection)
|
||||
m_nextWalkDirection = Otc::InvalidDirection;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Position newPos = m_position + Position::getPositionFromDirection(direction);
|
||||
TilePtr tile = g_map.getTile(newPos);
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
|
||||
void clientWalk(Otc::Direction direction);
|
||||
void walk(const Position& position, bool inverse);
|
||||
void cancelWalk(Otc::Direction direction);
|
||||
void cancelWalk(Otc::Direction direction, bool force = false);
|
||||
bool canWalk(Otc::Direction direction);
|
||||
|
||||
LocalPlayerPtr asLocalPlayer() { return std::static_pointer_cast<LocalPlayer>(shared_from_this()); }
|
||||
|
@ -53,6 +53,7 @@ private:
|
|||
uint16 m_drawSpeed;
|
||||
bool m_canReportBugs;
|
||||
bool m_clientWalking;
|
||||
Otc::Direction m_nextWalkDirection;
|
||||
|
||||
int m_skills[Otc::LastSkill][Otc::LastSkillType];
|
||||
double m_statistics[Otc::LastStatistic];
|
||||
|
|
|
@ -841,7 +841,7 @@ void ProtocolGame::parseTextMessage(InputMessage& msg)
|
|||
void ProtocolGame::parseCancelWalk(InputMessage& msg)
|
||||
{
|
||||
Otc::Direction direction = (Otc::Direction)msg.getU8();
|
||||
m_localPlayer->cancelWalk(direction);
|
||||
m_localPlayer->cancelWalk(direction, true);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseFloorChangeUp(InputMessage& msg)
|
||||
|
|
|
@ -73,10 +73,10 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
|||
|
||||
// cool testing \/
|
||||
if(button == Fw::MouseLeftButton) {
|
||||
/*MissilePtr shot = MissilePtr(new Missile());
|
||||
MissilePtr shot = MissilePtr(new Missile());
|
||||
shot->setId(1);
|
||||
shot->setPath(g_map.getCentralPosition(), tilePos);
|
||||
g_map.addThing(shot, g_map.getCentralPosition());*/
|
||||
g_map.addThing(shot, g_map.getCentralPosition());
|
||||
|
||||
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
||||
animatedText->setPosition(g_map.getCentralPosition());
|
||||
|
@ -91,6 +91,12 @@ bool UIMap::onMousePress(const Point& mousePos, Fw::MouseButton button)
|
|||
effect->start();
|
||||
if(tile)
|
||||
tile->addEffect(effect);
|
||||
|
||||
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
||||
animatedText->setPosition(g_map.getCentralPosition());
|
||||
animatedText->setColor(12);
|
||||
animatedText->setText("8");
|
||||
g_map.addThing(animatedText, g_map.getCentralPosition());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue