void AureolaSpell::update(const sf::Time& frameTime) {
    sf::Vector2f nextPosition;
    calculateNextPosition(frameTime, nextPosition);
    sf::Vector2f diff = nextPosition - getPosition();

    // check collisions with main char
    if (m_ownerType != GameObjectType::_LevelMainCharacter && !m_isOwnerControlled) {
        checkCollisionsWithMainChar(getBoundingBox());
    }
    // check collisions with enemies
    checkCollisionsWithEnemies(getBoundingBox());
    MovableGameObject::update(frameTime);
    GameObject::updateTime(m_data.activeDuration, frameTime);

    // check collisions with owner
    if (m_isReturning && m_mob->getBoundingBox()->intersects(*getBoundingBox())) {
        m_mob->addHeal(getHeal());
        setDisposed();
    }

    if (m_data.activeDuration == sf::Time::Zero) {
        setDisposed();
    }

    if (!m_isReturning) {
        m_rangeLeft -= norm(diff);
        if (m_rangeLeft <= 0.f) {
            m_isReturning = true;
            m_absVel = std::sqrt(getVelocity().x * getVelocity().x + getVelocity().y * getVelocity().y);
        }
    }
    else {
        setSpriteRotation(atan2(getVelocity().y, getVelocity().x));
    }
}
示例#2
0
void UnstableTile::update(const sf::Time& frameTime) {
	if (m_state == GameObjectState::Crumbling) {
		updateTime(m_crumblingTime, frameTime);
		if (m_crumblingTime == sf::Time::Zero) {
			setDisposed();
		}
	}
	else if (m_isCritical) {
		updateTime(m_criticalTime, frameTime);
		if (m_criticalTime == sf::Time::Zero) {
			m_isFalling = true;
			setState(GameObjectState::Idle);
		}
	}
	else if (m_isFalling) {
		setAcceleration(sf::Vector2f(0.f, GRAVITY_ACCELERATION));
		sf::Vector2f nextPosition;
		calculateNextPosition(frameTime, nextPosition);
		checkCollisions(nextPosition);
	}
	MovableGameObject::update(frameTime);
	if (m_isCritical && !m_wasCritical) {
		m_criticalTime = CRITICAL_TIME;
		m_isCritical = false;
		setState(GameObjectState::Idle);
	}
	m_wasCritical = false;
}
void DestructibleTile::update(const sf::Time& frameTime) {
    if (m_state == GameObjectState::Crumbling) {
        m_crumblingTime = m_crumblingTime - frameTime;
        if (m_crumblingTime < sf::Time::Zero) {
            setDisposed();
        }
    }
    LevelDynamicTile::update(frameTime);
}
示例#4
0
void ShiftableTile::update(const sf::Time& frameTime) {
	if (m_state == GameObjectState::Crumbling) {
		updateTime(m_crumblingTime, frameTime);
		if (m_crumblingTime == sf::Time::Zero) {
			setDisposed();
		}
		MovableGameObject::update(frameTime);
		return;
	}
	setAcceleration(sf::Vector2f(m_pushAcceleration, GRAVITY_ACCELERATION));
	sf::Vector2f nextPosition;
	calculateNextPosition(frameTime, nextPosition);
	checkCollisions(nextPosition);
	MovableGameObject::update(frameTime);
	m_pushAcceleration = 0.f;
	if (m_boundingBox.top + m_boundingBox.height > (m_level->getWorldRect().top + m_level->getWorldRect().height)) {
		setDisposed();
	}
}
示例#5
0
void FearSpell::execOnHit(LevelMovableGameObject *target)
{
	if (Enemy* enemy = dynamic_cast<Enemy*>(target)) 
	{
		if (enemy->getMentalStrength() <= m_strength)
		{
			enemy->setFeared(m_fearedDuration);
			setDisposed();
		}
	}
	// main character can't be feared yet.
}
示例#6
0
void TelekinesisSpell::checkCollisionsWithItems() {
	for (auto& it : *m_items) {
		if (!it->isViewable()) continue;
		if (it->getBoundingBox()->intersects(*getBoundingBox())) {
			LevelItem* item = dynamic_cast<LevelItem*>(it);
			if (item != nullptr) {
				item->pickup();
				setDisposed();
			}
		}
	}
}
void ModifierTile::update(const sf::Time& frameTime) {
	LevelDynamicTile::update(frameTime);

	if (m_state == GameObjectState::Active) {
		GameObject::updateTime(m_particleTime, frameTime);
		if (m_particleTime == sf::Time::Zero) {
			setDisposed();
		}
	}

	m_ps->update(frameTime);
}
示例#8
0
void RaiseTheDeadSpell::execOnHit(LevelMovableGameObject* target) {
	if (!target->isDead()) return;
	Enemy* enemy = dynamic_cast<Enemy*>(target);
	if (enemy == nullptr) return;
	if (enemy->getMentalStrength() >= m_strength) {
		setDisposed();
		return;
	}

	AttributeData attributes = ZERO_ATTRIBUTES;
	attributes.damagePhysical = m_data.damage;
	attributes.damageFire = m_data.damage;
	attributes.damageIce = m_data.damage;
	attributes.damageLight = m_data.damage;
	attributes.damageShadow = m_data.damage;

	// add an allied copy of that mob.
	Enemy* copy = ObjectFactory::Instance()->createEnemy(enemy->getEnemyID(), m_level, m_screen);
	copy->setAlly(m_data.duration);
	copy->addAttributes(m_data.duration, attributes);
	copy->setPosition(enemy->getPosition());
	m_screen->addObject(copy);
	setDisposed();
}
示例#9
0
void LeapOfFaithSpell::update(const sf::Time& frameTime) {
	if (m_isFacingRight != m_mob->isFacingRight()) {
		m_isFacingRight = m_mob->isFacingRight();
		setCurrentAnimation(getAnimation(GameObjectState::Idle), !m_isFacingRight);
	}

	sf::Vector2f nextPosition;
	calculatePositionAccordingToMob(nextPosition);
	setPosition(nextPosition);

	MovableGameObject::update(frameTime);

	updateTime(m_data.activeDuration, frameTime);
	if (m_data.activeDuration == sf::Time::Zero) {
		setDisposed();
	}
	m_ps->update(frameTime);
}
void GhostFormSpell::update(const sf::Time& frameTime) {
	sf::Vector2f nextPosition;
	calculatePositionAccordingToMob(nextPosition);
	setPosition(nextPosition);
	m_mob->setSpriteColor(GHOST_COLOR, sf::milliseconds(100));

	MovableGameObject::update(frameTime);
	m_ps->update(frameTime);
	updateParticleSystemPosition();

	WorldCollisionQueryRecord rec;
	rec.boundingBox = *m_mob->getBoundingBox();
	if (!(m_level->collides(rec))) {
		m_lastSafePosition = m_mob->getPosition();
	}

	GameObject::updateTime(m_data.activeDuration, frameTime);
	if (m_data.activeDuration <= sf::Time::Zero) {
		setDisposed();
	}
}
示例#11
0
/**
   @brief Restore a todo list from a QVariant representation
   @sa toVariant()
 */
void TodoList::fromVariant(const QVariant &todolist)
{
  m_loading = true;
  QVariantMap map = todolist.toMap();

  // Special handling for id: Only update if identify changes
  if ( m_uuid != map.value( "uuid", QUuid() ).toUuid() || !m_hasId ) {
    m_hasId = map.contains( "id" );
    if ( m_hasId ) {
      setId( map.value( "id", m_id ).toInt() );
    }
  }

  setAccount( map.value( "accountUuid", m_accountUuid ).toUuid() );
  setMetaAttributes( map.value( "metaAttributes", m_metaAttributes ).toMap() );
  setName( map.value( "name", m_name ).toString() );
  setUuid( map.value( "uuid", m_uuid ).toUuid() );
  setDirty( map.value( "dirty", m_dirty ).toInt() );
  setDisposed( map.value( "disposed", m_disposed ).toBool() );
  m_loading = false;
}
示例#12
0
void Task::fromVariant(const QVariant &task)
{
  m_loading = true;
  QVariantMap map = task.toMap();

  // Special handling ID: Onlz override on identity change
  if ( map.value( "uuid" ).toUuid() != m_uuid || !m_hasId ) {
    if ( map.contains( "id" ) ) {
      setId( map.value( "id" ).toInt() );
    }
  }

  setDone( map.value( "done", m_done ).toBool() );
  setMetaAttributes( map.value( "metaAttributes", m_metaAttributes ).toMap() );
  setTitle( map.value( "title", m_title ).toString() );
  setTodo( map.value( "todoUuid", m_todoUuid ).toUuid() );
  setUuid( map.value( "uuid", m_uuid ).toUuid() );
  setWeight( map.value( "weight", m_weigth ).toDouble() );
  setDirty( map.value( "dirty", m_dirty ).toInt() );
  setDisposed( map.value( "disposed", m_disposed ).toBool() );

  m_loading = false;
}
示例#13
0
void LevelEquipment::update(const sf::Time& frameTime)
{
	GameObjectState newState = m_mainChar->getState();
	if (newState == GameObjectState::Dead)
	{
		setDisposed();
		return;
	}
	bool newFacingRight = m_mainChar->getIsFacingRight();
	if (m_state != newState || newFacingRight != m_isFacingRight) 
	{
		m_state = newState;
		m_isFacingRight = newFacingRight;
		setCurrentAnimation(getAnimation(m_state), !m_isFacingRight);
	}
	if (m_mainChar->getIsUpsideDown() != m_animatedSprite.isFlippedY())
	{
		m_animatedSprite.setFlippedY(m_mainChar->getIsUpsideDown());
	}
	sf::Vector2f newPosition;
	calculatePositionAccordingToMainChar(newPosition);
	setPosition(newPosition);
	GameObject::update(frameTime);
}
示例#14
0
void JumpingGhostDebugger::update(const sf::Time& frameTime) {
	updateTime(m_renderTime, frameTime);
	if (m_renderTime == sf::Time::Zero) {
		setDisposed();
	}
}