Esempio n. 1
0
void NPC::update (uint32_t deltaTime)
{
	IEntity::update(deltaTime);

	if (isDying())
		return;

	if (_dazedTime > 0 && _time - _dazedTime > _dazedTimeout) {
		if (_lastDirectionRight)
			setAnimationType(Animations::ANIMATION_WAKEUP_RIGHT);
		else
			setAnimationType(Animations::ANIMATION_WAKEUP_LEFT);

		const int length = SpriteDefinition::get().getAnimationLength(_type, getAnimationType());
		if (length > 0) {
			TimeManager& t = _map.getTimeManager();
			_idleTimer = t.setTimeout(length, this, &NPC::setIdle);
		}
		_dazedTime = 0;
	}

	if (isMoving()) {
		const float xPos = getPos().x;
		static const float gap = 0.1f;
		if (Between(xPos, _targetPos.x - gap, _targetPos.x + gap)) {
			// target reached
			setIdle();
		}
	} else if (isDazed() || isIdle()) {
		setLinearVelocity(b2Vec2_zero);
	}
}
Esempio n. 2
0
PackageTarget::PackageTarget (Map& map, const std::string& spriteID, gridCoord x, gridCoord y) :
		MapTile(map, spriteID, x, y,
				ThemeTypes::isIce(map.getTheme()) ? EntityTypes::PACKAGETARGET_ICE : EntityTypes::PACKAGETARGET_ROCK), _joint(
				nullptr), _package(nullptr), _lengthUpdate(0)
{
	setAnimationType(Animations::ANIMATION_IDLE);
}
Esempio n. 3
0
void Geyser::update (uint32_t deltaTime)
{
	MapTile::update(deltaTime);
	_modificator->update(deltaTime);

	if (_lastActivation < _time) {
		_activeTime = _time + rand() % RANDOM_ACTIVE_TIME + MIN_ACTIVE_TIME;
		updateLastActivation();
		// TODO: handle SpriteDefFrame::active
		_modificator->setModificatorState(true);
		setAnimationType(Animations::ANIMATION_ACTIVE);
	}
	if (_activeTime < _time) {
		_modificator->setModificatorState(false);
		setAnimationType(Animations::ANIMATION_IDLE);
	}
}
Esempio n. 4
0
void PackageTarget::removeJoint ()
{
	// the joint is deleted once the body is removed
	_joint = nullptr;
	setAnimationType(Animations::ANIMATION_IDLE);
	_package->setDelivered();
	_package = nullptr;
}
Esempio n. 5
0
void NPC::setIdle ()
{
	debug(LOG_SERVER, String::format("idle npc %i: %s", getID(), _type.name.c_str()));
	setState(NPCState::NPC_IDLE);
	setAnimationType(getIdleAnimation());
	setLinearVelocity(b2Vec2_zero);
	_idleTimer = 0;
}
Esempio n. 6
0
Geyser::Geyser (Map& map, const std::string& spriteID, gridCoord gridX, gridCoord gridY, uint32_t initialGeyserDelay) :
		MapTile(map, spriteID, gridX, gridY, ThemeTypes::isIce(map.getTheme()) ? EntityTypes::GEYSER_ICE : EntityTypes::GEYSER_ROCK), _modificator(
				nullptr), _lastActivation(0), _activeTime(0), _initialGeyserDelay(initialGeyserDelay)
{
	setAnimationType(Animations::ANIMATION_IDLE);
	_modificator = new WindModificator(_map, DIRECTION_UP, 11.0f, 2.0f);
	_modificator->createBody(getPos(), -0.5f);
	updateLastActivation();
}
Esempio n. 7
0
void NPC::setDying (const IEntity* entity)
{
	info(LOG_SERVER, String::format("dying npc %i: %s", getID(), _type.name.c_str()));
	setState(NPCState::NPC_DYING);
	if (EntityTypes::isNpcFlying(_type)) {
		Achievements::DAZE_PTERODACTYLS.unlock();
	}
	setAnimationType(getFallingAnimation());
	_map.addPoints(entity, 15);
}
Esempio n. 8
0
void NPC::setMoving (const b2Vec2& targetPos)
{
	debug(LOG_SERVER, String::format("moving npc %i: %s", getID(), _type.name.c_str()));
	_targetPos = targetPos;
	if (EntityTypes::hasDirection(_type)) {
		const int length = handleTurnAnimation(targetPos, Animations::ANIMATION_WALK_LEFT, Animations::ANIMATION_WALK_RIGHT);
		if (length > 0) {
			TimeManager& t = _map.getTimeManager();
			_moveTimer = t.setTimeout(length, this, &NPC::move);
		} else {
			move();
		}
	} else {
		if (targetPos.x > getPos().x) {
			_lastDirectionRight = true;
			setAnimationType(Animations::ANIMATION_WALK_RIGHT);
		} else {
			_lastDirectionRight = false;
			setAnimationType(Animations::ANIMATION_WALK_LEFT);
		}
		move();
	}
}
Esempio n. 9
0
void MibitDialog::showDialog(const QString &msg, AnimationType animation )
{
    //set default msg if the sent is empty. Also set the animation -the same way-.
    if (msg.isEmpty()) setMessage(text->text()); else setMessage( msg );
    if (animation == 0) setAnimationType( atSlideDown ); else setAnimationType( animation );

    setGeometry(-1000,-1000,0,0);
    show();
    //update steps for animation, now that the window is showing.

    int maxStep; int minStep = 0;
    switch (animType) {
        case atSlideDown:
            maxStep = (m_parent->geometry().height()/2)-(maxHeight/2);
            minStep = -maxHeight;
            break;
        case atSlideUp:
            maxStep = (m_parent->geometry().height()/2)-(maxHeight/2);
            minStep = maxHeight + m_parent->geometry().height();
            break;
        case atGrowCenterH:
            maxStep = maxWidth;
            minStep = 0;
            break;
        case atGrowCenterV:
            maxStep= maxHeight;
            minStep = 0;
            break;
    }

    /// QTimeLine: Hacer una curva de movimiento armonico criticamente amortiguado.
    timeLine->setFrameRange(minStep,maxStep);
    //make it grow...
    timeLine->setDirection(QTimeLine::Forward);
    timeLine->start();
    btnClose->setFocus();
}
Esempio n. 10
0
void Tree::setDazed (IEntity* entity)
{
	if (_dropFruitCausedBy == entity)
		return;

	if (getState() == TreeState::TREE_DAZED)
		return;

	if (entity) {
		_dropFruit = _droppedFruits < 10;
		setAnimationType(Animations::ANIMATION_DAZED);
		setState(TreeState::TREE_DAZED);
	}
	_dropFruitCausedBy = entity;
}
/// <summary>
/// Constructor for the Sprite Model
/// </summary>
ModelImageSprite::ModelImageSprite() 
{
	// Setup our starting animation parameters
	myAnim.lastTime = 0.0f;
	myAnim.currentTime = 1.0f;
	setAnimationType(STAND);
	setModelScale(1.0);
	// Set our model to render at the default location
	myLocation.x = 0.0f; 
	myLocation.y = 0.0f; 
	myLocation.z = 15.1f;	
	myTextureHandle = UNDEFINED_TEXTURE_HANDLE;
	// Set up the point structure we use to render the Sprite Model
	myPoint.point.x = 0.0f;
	myPoint.point.y = 0.0f; 
	myPoint.point.z = 0.0f;
	myPoint.texture_S = 0.0f;
	myPoint.texture_T = 0.5f;
	myPoints.push_back(myPoint);
}
Esempio n. 12
0
void PackageTarget::onPreSolve (b2Contact* contact, IEntity* entity, const b2Manifold* oldManifold)
{
	IEntity::onPreSolve(contact, entity, oldManifold);
	// there is already a pull in progress
	if (_joint != nullptr)
		return;

	if (!isValidContact(contact, "top"))
		return;

	contact->SetEnabled(false);

	if (entity->isPackage()) {
		Package *package = static_cast<Package*>(entity);
		package->setLinearVelocity(b2Vec2_zero);
		package->setAngularVelocity(0.0f);
		setAnimationType(Animations::ANIMATION_ACTIVE);
		_package = package;
	}
}
/// <summary>
/// Decides what type of animation to render ...
/// </summary>		
void ModelImageSprite::setAnimationType(AnimationType type, ModelAnimState &modelAnim)
{
	setAnimationType(type);	
}
Esempio n. 14
0
void NPC::onSpawn ()
{
	if (getAnimationType() == Animation::NONE)
		setAnimationType(getIdleAnimation());
}
Esempio n. 15
0
void NPC::setFalling ()
{
	debug(LOG_SERVER, String::format("falling npc %i: %s", getID(), _type.name.c_str()));
	setState(NPCState::NPC_FALLING);
	setAnimationType(getFallingAnimation());
}
Esempio n. 16
0
void Tree::setIdle ()
{
	setAnimationType(Animations::ANIMATION_IDLE);
	setState(TreeState::TREE_IDLE);
	_idleTimer = 0;
}