Ejemplo n.º 1
0
/* We want to detect when the mouse pointer is over the bubble; this
 * is used to suspend the handling of the paging timeout; if
 * the mouse is over the bubble we keep the bubble up indefinitely
 * to let the user interact with it. As far as I know there is no
 * way to detect enters and leaves that go directly to a subwindow
 * (virtual enters/leaves in X terminology), so we check by simply
 * installing a timeout when the bubble is up.
 */
void
HippoBubble::checkMouse()
{
    POINT pt;
    RECT rect;

    GetCursorPos(&pt);
    ScreenToClient(window_, &pt);
    GetClientRect(window_, &rect);

    if (pt.x > 0 && pt.x < rect.right &&
        pt.y > 0 && pt.y < rect.bottom) 
    {
        if (!haveMouse_) {
            haveMouse_ = TRUE;
            updateIdle();
        }
    } 
    else
    {
        if (haveMouse_) {
            haveMouse_ = FALSE;
            updateIdle();
        }
    }
}
Ejemplo n.º 2
0
void AvatarEntity::update(const float elapsedTime)
{
	//Para actualizar el estado del avatar, miraremos primero en que estado estamos
	//Y despues llamamos a las funciones que actualizan segun el estado
	updateState();
	
switch(m_state) {
	case IDLE:
		updateIdle(elapsedTime);
		break;
	case PUNCH:
		updatePunch(elapsedTime);
		break;
	case JAB:
		updateJab(elapsedTime);
		break;
	case KICK:
		updateKick(elapsedTime);
		break;
	case LOWER:
		updateLower(elapsedTime);
		break;
	case MOVE:
		updateMove(elapsedTime);
		break;
	case JUMP:
		updateJump(elapsedTime);
		break;
	case DEFENSE:
		updateDefense(elapsedTime);
		break;
	}
}
Ejemplo n.º 3
0
void
HippoBubble::doClose()
{
    KillTimer(window_, CHECK_MOUSE);
    if (haveMouse_) {
        haveMouse_ = FALSE;
        updateIdle();
    }

    // See comments in the constructor for why we'd want to only fade out, not in 
    // and why we aren't turning on fading at all at the moment
    // if (!screenSaverRunning_)
    //    setAnimate(true);
    hide();
    // if (!screenSaverRunning_)
    //    setAnimate(false);
}
Ejemplo n.º 4
0
void Character::update(int32 timeIncrement) {
	debugC(5, kDebugCharacter, "update(%d)", timeIncrement);
	if ((_flags & 0x1) && _currentPathNodeCount > 0) {
		if (_currentPathNode < _currentPathNodeCount) {
			if (_currentPathNode < _currentPathNodeCount - 10) {
				int32 delta = MIN<int32>(10, _currentPathNodeCount - _currentPathNode);
				int32 dx = _currentPathX[_currentPathNode+delta] - _x;
				int32 dy = _currentPathY[_currentPathNode+delta] - _y;
				setFacing(getFacingFromDirection(dx, dy));
				playWalkAnim(0, 0);
			}

			// in 1/1000 pixels
			_numPixelToWalk += _speed * (_vm->getSystem()->getMillis() - _lastWalkTime) * _scale / 1024;
			_lastWalkTime =  _vm->getSystem()->getMillis();

			while (_numPixelToWalk > 1000 && _currentPathNode < _currentPathNodeCount) {
				_x = _currentPathX[_currentPathNode];
				_y = _currentPathY[_currentPathNode];
				_currentPathNode += 1;
				_numPixelToWalk -= 1000;
			}
			setPosition(_x, _y);
		} else {
			playStandingAnim();
			_flags &= ~0x1;
			_currentPathNodeCount = 0;
		}
	}

	updateIdle();

#if 0
	// handle special anims
	if ((_flags & 4) == 0)
		return;

	if (_animScriptId != -1) {
		_animationInstance = _vm->getSceneAnimation(this->)
#endif

	int32 animId = _animSpecialId;
	if (animId >= 1000)
		animId = 0;

	if (_animSpecialId < 0)
		return;

	int32 currentFrame = _animationInstance->getFrame();

	const SpecialCharacterAnimation *anim = getSpecialAnimation(_id, animId);

	if ((_animFlags & 0x10) == 0) {
		if (_animScriptId != -1 && currentFrame > 0 && !_vm->getSceneAnimationScript(_animScriptId)->_frozen) {
			if (_vm->getCurrentLineToSay() != _lineToSayId && (_animFlags & 8))
				stopSpecialAnim();
			return;
		}

		if (_id == 1 && (_animFlags & 4)) {
			if (_animFlags & 0x10)
				return;
		} else {
			if (_id == 1 && (_animFlags & 0x10) && _vm->getCurrentLineToSay() != -1) {
				return;
			}
			if ((_animFlags & 0x40) == 0 && _vm->getCurrentLineToSay() == -1) {
				stopSpecialAnim();
				return;
			}

			if (_animScriptId != -1)
				_vm->getSceneAnimationScript(_animScriptId)->_frozenForConversation = true;

			// TODO setup backup //

			_animFlags |= 0x10;
			_animationInstance->setAnimation(_specialAnim);
			_animationInstance->setFrame(0);
			_time = _vm->getOldMilli() + 8 * _vm->getTickLength();
		}

	}

	if ((_animFlags & 3) == 2) {
		if ((((_animFlags & 8) == 8) && _vm->getCurrentLineToSay() != _lineToSayId) || !_vm->getAudioManager()->voiceStillPlaying())  // || (_flags & 8)) && _vm->getAudioManager()->voiceStillPlaying())
			_animFlags |= 1;

	}

	if (_time > _vm->getOldMilli())
		return;

	int32 animFlag = anim->_unused;
	int32 nextFrame = currentFrame + 1;
	int32 nextTime = _time;
	int32 animDir = 1;
	if (!animFlag) {
		if (_animFlags & 1) {
			if (anim->_flags7 == 0xff) {
				if (currentFrame > anim->_flag1 / 2)
					animDir = 1;
				else
					animDir = -1;
			} else {
				if (currentFrame >= anim->_flags6) {
					if (currentFrame < anim->_flags7)
						currentFrame = anim->_flags7;
				}
				if (currentFrame > anim->_flags6)
					animDir = 1;
				else
					animDir = -1;
			}

			nextFrame = currentFrame + animDir;
			nextTime = _vm->getOldMilli() + 6 * _vm->getTickLength();
		} else {
			if (_animFlags & 0x20) {
				nextFrame = currentFrame - 1;
				if (nextFrame == anim->_flags6 - 1) {
					if (anim->_flags8 != 1 && (_vm->randRange(0, 1) == 1 || anim->_flags8 == 2)) {
						_animFlags &= ~0x20;
						nextFrame += 2;
						if (nextFrame > anim->_flags7)
							nextFrame = anim->_flags7;
					} else {
						nextFrame = anim->_flags7;
					}
				}
			} else {
				nextFrame = currentFrame + 1;
				if (nextFrame == anim->_flags7 + 1 && (_animFlags & 0x40) == 0) {
					if (anim->_flags8 != 1 && (_vm->randRange(0, 1) || anim->_flags8 == 2)) {
						_animFlags |= 0x20;
						nextFrame -= 2;
						if (nextFrame < anim->_flags6)
							nextFrame = anim->_flags6;
					} else {
						nextFrame = anim->_flags6;
					}
				}
			}

			nextTime = _vm->getOldMilli() + 8 * _vm->getTickLength();
		}
		// goto label78
	}
	// skipped all this part.

	//label78

#if 0
	if (_id == 0)
		debug(" drew animation name %s / flag %d / frame %d", _specialAnim->_name, _animFlags, nextFrame);
	if (_id == 1)
		debug(" flux animation flag %d / frame %d", _animFlags, nextFrame);
	if (_id == 7)
		debug(" footman animation flag %d / frame %d", _animFlags, nextFrame);
#endif

	_time = nextTime;
	if (nextFrame < 0 || nextFrame >= anim->_flag1) {
		if ((_animFlags & 2) == 0 || _vm->getCurrentLineToSay() != _lineToSayId) {
			stopSpecialAnim();
			return;
		}

		// lots skipped here

		_animFlags &= ~0x10;
		_animationInstance->forceFrame(0);
		return;

	}

	//if ((_flags & 8) == 0 || !_vm->getAudioManager()->voiceStillPlaying( ) || )
	_animationInstance->forceFrame(nextFrame);
}
Ejemplo n.º 5
0
void AvatarController::update(const float elapsedTime)
{
	m_avatarLogicCalculator->computeLogic();

	updateState();

	switch(m_avatarModel->getState()) {

		case AvatarModel::AvatarState::AVATAR_STATE_IDLE:
			updateIdle(elapsedTime);
			break;

		case AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP:
			updateMove(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN:
			updateMove(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_MOVE_LEFT:
			updateMove(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_MOVE_RIGHT:
			updateMove(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP_LEFT:
			updateMove(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_MOVE_UP_RIGHT:
			updateMove(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN_LEFT:
			updateMove(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_MOVE_DOWN_RIGHT:
			updateMove(elapsedTime);
			break;
		
		case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP:
			updateAttack(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN:
			updateAttack(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_LEFT:
			updateAttack(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_RIGHT:
			updateAttack(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP_LEFT:
			updateAttack(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_UP_RIGHT:
			updateAttack(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN_LEFT:
			updateAttack(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_ATTACK_DOWN_RIGHT:
			updateAttack(elapsedTime);
			break;
		case AvatarModel::AvatarState::AVATAR_STATE_DIE:
			updateDie(elapsedTime);
			break;
		
		default:
			updateIdle(elapsedTime);
			break;
	}
	updateBasicAvatarMeasurements();
}
Ejemplo n.º 6
0
void 
HippoBubble::setIdle(bool idle)
{
    idle_ = idle;
    updateIdle();
}
Ejemplo n.º 7
0
void HatSystem::process(float dt)
{
    auto& entities = getEntities();
    for (auto& entity : entities)
    {
        auto& hat = entity.getComponent<MagicHat>();
        switch (hat.state)
        {
        case MagicHat::Spawning:
            hat.spawnTime -= dt;
            updateSpawning(entity, dt);
            break;
        case MagicHat::Dying:
            updateDying(entity, dt);
            break;
        case MagicHat::Idle:
            updateIdle(entity);
            break;
        }
    }

    if (!m_hatActive)
    {
        //check to see if we should spawn a hat
        m_nextHatTime -= dt;

        if (m_nextHatTime < 0)
        {
            m_nextHatTime = xy::Util::Random::value(MinHatTime, MaxHatTime);
            m_hatActive = true;

            sf::Vector2f position(xy::Util::Random::value(128.f, MapBounds.width - 128.f),
                xy::Util::Random::value(256.f, 512.f));

            //spawn a hat
            auto scene = getScene();
            auto entity = scene->createEntity();
            entity.addComponent<xy::Transform>().setPosition(position);
            entity.getComponent<xy::Transform>().setOrigin(PlayerOrigin);
            entity.addComponent<Actor>().id = entity.getIndex();
            entity.getComponent<Actor>().type = ActorID::MagicHat;
            entity.addComponent<MagicHat>();
            entity.getComponent<MagicHat>().state = MagicHat::Spawning;

            entity.addComponent<CollisionComponent>().addHitbox(PlayerBounds, CollisionType::MagicHat);
            entity.getComponent<CollisionComponent>().setCollisionCategoryBits(CollisionFlags::MagicHat);
            entity.getComponent<CollisionComponent>().setCollisionMaskBits(
                CollisionFlags::Solid | CollisionFlags::Platform | CollisionFlags::Teleport | CollisionFlags::Player);
            entity.addComponent<xy::QuadTreeItem>().setArea(PlayerBounds);

            entity.addComponent<AnimationController>();
            entity.addComponent<xy::CommandTarget>().ID = CommandID::MapItem; //so we can destroy at whim

            //broadcast to clients
            ActorEvent evt;
            evt.actor.id = entity.getIndex();
            evt.actor.type = entity.getComponent<Actor>().type;
            evt.x = position.x;
            evt.y = position.y;
            evt.type = ActorEvent::Spawned;
            evt.serverTime = GameServer::getServerTime();

            m_host.broadcastPacket(PacketID::ActorEvent, evt, xy::NetFlag::Reliable, 1);
        }
    }
}