Beispiel #1
0
void AGENT::update_fight(GROUP* target_group)
{
	// get target
	AGENT * t = find_target(target_group); //group->is_single_unit() ? find_target(target_group) : find_target_random(target_group);
	if (!t) return; // didn't find one

	// fight
	move_mult(collision ? 3.0 : 1.0);
	set_dest(t->get_x(), t->get_y());
	if (dist_dest() > (t->getRadius() + getRadius()) * 2) { // move to target
		fight_timer--;
		if (!collision) move((int)get_dest_x(), (int)get_dest_y(), true); // move
		else collision_avoid(); // collision avoid
		state = AGENT::READY_FIGHT;
		setAnimation(is_stuckcounter() ? ANIMATION_DATA::STAND : ANIMATION_DATA::MOVE, true);
	} else { // at target
		move_stop();
		state = AGENT::FIGHTING;
		if (is_near_dest_angle(45)) { // deal damage
			set_dest(x, y);
			t->hurt_by(unitData->damage, this);
			setAnimation(ANIMATION_DATA::ATTACK, true);
		} else { // face target
			fight_timer--;
			rotate_towards((int)get_angle_dest());
			if (!is_near_dest_angle(90)) setAnimation(ANIMATION_DATA::STAND, true);
		}
	}

	// single units sync group position with their own
	if (group->is_single_unit()) group->sync_to(this);

	// update gemeric stuff
	update();
}
Beispiel #2
0
void Arrow::load_animations(AnimationHolder *animHolder)
{
	if (dir_facing & DIR_LEFT)
		setAnimation(animHolder->get_anim(ANIM_ARROW_LEFT));
	else
		setAnimation(animHolder->get_anim(ANIM_ARROW_RIGHT));
}
void CC3PODMeshNode::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez )
{
    init();
    setPodIndex( aPODIndex );
    
    SPODNode* pmn = (SPODNode*)getNodePODStructAtIndex( aPODIndex, aPODRez );
    
    //LogRez(@"Creating %@ at index %i from: %@", [self class], aPODIndex, NSStringFromSPODNode(psn));
    setName( pmn->pszName );
    setPodContentIndex( pmn->nIdx );
    setPodParentIndex( pmn->nIdxParent );
    
    if ( pmn->pfAnimPosition )
        setLocation( *(CC3Vector*)pmn->pfAnimPosition );
    if ( pmn->pfAnimRotation )
        setQuaternion( *(CC3Quaternion*)pmn->pfAnimRotation );
    if ( pmn->pfAnimScale )
        setScale( *(CC3Vector*)pmn->pfAnimScale );
    
    if ( CC3PODNodeAnimation::sPODNodeDoesContainAnimation((PODStructPtr)pmn) )
        setAnimation( CC3PODNodeAnimation::animationFromSPODNode( (PODStructPtr)pmn, aPODRez->getAnimationFrameCount() ) );
    else if (aPODRez->shouldFreezeInanimateNodes())
        setAnimation( CC3FrozenNodeAnimation::animationFromNodeState( this ) );

	// If this node has a mesh, build it
	if (getPodContentIndex() >= 0) {
		setMesh( aPODRez->getMeshAtIndex( getPodContentIndex() ) );
	}
	// If this node has a material, build it
	setPodMaterialIndex( pmn->nIdxMaterial );
	if (getPodMaterialIndex() >= 0)
		setMaterial( (CC3PODMaterial*)aPODRez->getMaterialAtIndex( getPodMaterialIndex() ) );
}
void Robot_Soldier::updateGameObject(float delta) {


  if (AI_STATE != AI_DEAD) {
    if (HP <= 0) {
      AI_STATE = AI_DEAD;
      auto audio = CocosDenshion::SimpleAudioEngine::getInstance();
      audio->setEffectsVolume(0.2f);
      audio->playEffect("explosion.aif");
      if (hsp >= 0) {
        setAnimation("robSol_Dead");
        player_sprite->setScaleX(1);
      }
      else {
        setAnimation("robSol_Dead");
        player_sprite->setScaleX(-1);
      }

      return;

    }
    if (hsp > 0) {
      setAnimation("robSol_WalkRight");
      player_sprite->setScaleX(1);
    }
    else {
      setAnimation("robSol_WalkLeft");
      player_sprite->setScaleX(-1);
    }
  }
  else {
    hsp *= 0.98;
  }
}
Beispiel #5
0
void CSimpleEnemy::updateAnimationsCallback(const Ogre::Real fTime) {
    for (CWorldEntity *pEnt : dynamic_cast<CharacterControllerPhysics*>(mCCPhysics)->getCollidingWorldEntities()) {
        if (dynamic_cast<CCharacter*>(pEnt) && dynamic_cast<CCharacter*>(pEnt)->getFriendOrEnemyState() == FOE_FRIENDLY) {
            pEnt->hit(CDamage(DMG_SWORD, m_pSceneNode->getOrientation().zAxis()));
        }
    }

    CSimpleEnemyController::EKIState eKIState = dynamic_cast<CSimpleEnemyController*>(m_pCharacterController)->getCurrentKIState();
    if (eKIState == CSimpleEnemyController::KI_PATROLING || eKIState == CSimpleEnemyController::KI_WALK_TO_PLAYER) {
        if (m_uiAnimID != SE_ANIM_WALK) {
            setAnimation(SE_ANIM_WALK, true);
        }
    }
    else if (eKIState == CSimpleEnemyController::KI_SCOUTING) {
        if (m_uiAnimID != SE_ANIM_SCOUT) {
            setAnimation(SE_ANIM_SCOUT, true);
        }
    }

    const Ogre::Vector3 vDir = m_pBodyEntity->getParentNode()->convertLocalToWorldOrientation(m_pBodyEntity->getSkeleton()->getBone(PERSON_RIGHT_HANDLE)->_getDerivedOrientation()).yAxis();
    const Ogre::Vector3 vPos = m_pBodyEntity->getParentNode()->convertLocalToWorldPosition(m_pBodyEntity->getSkeleton()->getBone(PERSON_RIGHT_HANDLE)->_getDerivedPosition());

    DebugDrawer::getSingleton().drawLine(vPos, vPos + vDir * 0.1, Ogre::ColourValue::Blue);
    createDamage(Ogre::Ray(vPos, vDir * 0.1), CDamage(DMG_SWORD, m_pSceneNode->getOrientation().zAxis()));
}
Beispiel #6
0
void Game::onKeyboardKey(KeyboardCodes::Key key, bool pressed)
{
	switch (key)
	{
		case KeyboardCodes::Key::Escape: window.postClose();
			break;
		case KeyboardCodes::Key::W:
			if (pressed)
				setAnimation(6);
			else
				setAnimation(-1u);
			//setAnimation(pressed ? "Walk" : nullptr);
			walking = pressed;
			break;
		case KeyboardCodes::Key::Space:
			if (pressed)
			{
				setAnimation(5);
				walking = false;
			}
			break;
		case KeyboardCodes::Key::LShift:
			cameraMode = pressed;
			break;
		case KeyboardCodes::Key::RShift:
			camera2->getFrustum().addConvexPoint(vector3f(-1., 0., 0.));
			break;
	}
}
Beispiel #7
0
void ShooterEnemy_onFrame( Object* e )
{
    const int STATE_MOVING = 0;
    const int STATE_ATTACK1 = MS_TO_FRAMES(750);
    const int STATE_ATTACK2 = MS_TO_FRAMES(1000);

    if (e->state <= STATE_MOVING) {
        if (isVisible(e, (Object*)&player)) {
            Object* shot = createObject(level, TYPE_ICESHOT, 0, 0);
            shot->x = e->anim.direction > 0 ? e->x + e->type->width : e->x - e->type->width;
            shot->y = e->y;
            shot->vx *= e->anim.direction;
            shot->anim.direction = e->anim.direction;
            e->state = STATE_MOVING + 1;
        } else if (move(e, e->vx, e->vy, 1)) {
            e->vx = -e->vx;
            e->anim.direction = -e->anim.direction;
        }
        setAnimation(e, 1, 2, 24);

    } else if (e->state <= STATE_ATTACK1) {
        setAnimation(e, 4, 4, 24);

    } else if (e->state <= STATE_ATTACK2) {
        setAnimation(e, 1, 1, 24);

    } else {
        e->state = STATE_MOVING;
    }

    e->state += e->state > STATE_MOVING;
}
Beispiel #8
0
void
Trundler::update()
{
  // MOVE IT
  int oldX = x;
  int oldY = y;

  int animMap[] = {TRUNDLER_RIGHT, TRUNDLER_LEFT};

  if(inAir)
    {
      // Fall
      field->moveCollidableRel(this, 0, yvel);

      if(yvel < 4 && --yvelTimer == 0)
	{
	  yvel++;

	  yvelTimer = TRUNDLER_FALL_DELAY;
	}

      // See if we've landed
      if(oldY == y)
	{
	  inAir = false;
	  setAnimation(animMap[dir]);
	}
    }
  else
    {
      // Move in 'dir' direction
      int dirMap[] = {1, -1};
      TrundlerDir dirChangeMap[] = {TRUNDLE_LEFT, TRUNDLE_RIGHT};

      field->moveCollidableRel(this, dirMap[dir], 0);
      if(oldX == x)
	{
	  dir = dirChangeMap[dir];
	  setAnimation(animMap[dir]);
	}
    }

  // See if we're now suddenly in the air
  if(!inAir)
    {
      if(field->blockEmpty((x+boxX)/32, (y+boxY+boxHeight)/32)
	 && field->blockEmpty((x+boxX+boxWidth-1)/32, (y+boxY+boxHeight)/32))
	{
	  inAir = true;

	  setAnimation(TRUNDLER_PAUSE);

	  yvel = 1;
	  yvelTimer = TRUNDLER_FALL_DELAY;
	}
    }
}
Beispiel #9
0
void Player::endLevel(GameProperties* gameProps)
{
	pi->playerDied(this);
	ending_level = 1;
	end_level_anim_time = 0;
	if (dir_facing & DIR_RIGHT)
		setAnimation(gameProps->getAnimHolder(), ANIM_PLAYER_CUT_UP_RIGHT);
	if (dir_facing & DIR_LEFT)
		setAnimation(gameProps->getAnimHolder(), ANIM_PLAYER_CUT_UP_LEFT);
}
Beispiel #10
0
bool AlaLedRgb::runAnimation()
{
    // skip the refresh if not enough time has passed since last update
	unsigned long cTime = millis();
	if (cTime < lastRefreshTime + refreshMillis)
		return false;
	
	// calculate real refresh rate
	refreshRate = 1000/(cTime - lastRefreshTime);
	
	lastRefreshTime = cTime;
	
    
	if (animSeqLen != 0)
    {
		if(animSeq[currAnim].duration == 0)
		{
			setAnimation(animSeq[currAnim].animation, animSeq[currAnim].speed, animSeq[currAnim].palette);
		}
		else
		{
			long c = 0;
			long t = cTime % animSeqDuration;
			for(int i=0; i<animSeqLen; i++)
			{
				if (t>=c && t<(c+animSeq[i].duration))
				{
					setAnimation(animSeq[i].animation, animSeq[i].speed, animSeq[i].palette);
					break;
				}
				c = c + animSeq[i].duration;
			}
		}
    }
    
    if (animFunc != NULL)
    {
		(this->*animFunc)();

		// use an 8 bit shift to divide by 256
		
		if((driver==ALA_PWM) || (driver==ALA_BP))
		{
			int offset = 0;
			if (driver==ALA_BP)
				offset = 255;
			
			for(int i=0; i<numLeds; i++)
			{
				int j = 3*i;
				analogWrite(pins[j],   offset - (leds[i].r*maxOut.r)>>8);
				analogWrite(pins[j+1], offset - (leds[i].g*maxOut.g)>>8);
				analogWrite(pins[j+2], offset - (leds[i].b*maxOut.b)>>8);
			}
		}
Beispiel #11
0
void CC3PODLight::initAtIndex( GLint aPODIndex, CC3PODResource* aPODRez )
{
    init();
    setPodIndex( aPODIndex );
    
    SPODNode* psn = (SPODNode*)getNodePODStructAtIndex( aPODIndex, aPODRez );
    //LogRez(@"Creating %@ at index %i from: %@", [self class], aPODIndex, NSStringFromSPODNode(psn));
    setName( psn->pszName );
    setPodContentIndex( psn->nIdx );
    setPodParentIndex( psn->nIdxParent );
    
    if ( psn->pfAnimPosition )
        setLocation( *(CC3Vector*)psn->pfAnimPosition );
    if ( psn->pfAnimRotation )
        setQuaternion( *(CC3Quaternion*)psn->pfAnimRotation );
    if ( psn->pfAnimScale )
        setScale( *(CC3Vector*)psn->pfAnimScale );
    
    if ( CC3PODNodeAnimation::sPODNodeDoesContainAnimation((PODStructPtr)psn) )
        setAnimation( CC3PODNodeAnimation::animationFromSPODNode( (PODStructPtr)psn, aPODRez->getAnimationFrameCount() ) );
    else if (aPODRez->shouldFreezeInanimateNodes())
        setAnimation( CC3FrozenNodeAnimation::animationFromNodeState( this ) );
    
	// Get the light content
	if (getPodContentIndex() >= 0) 
	{
		SPODLight* psl = (SPODLight*)aPODRez->getLightPODStructAtIndex(getPodContentIndex());
		//LogRez(@"Setting %@ parameters from %@", [self class], NSStringFromSPODLight(psl));
		setPodTargetIndex( psl->nIdxTarget );

		setAmbientColor( kCC3DefaultLightColorAmbient );
		setDiffuseColor( ccc4f(psl->pfColour[0], psl->pfColour[1], psl->pfColour[2], 1.0) );
		setSpecularColor( kCC3DefaultLightColorSpecular );

		setAttenuation( CC3AttenuationCoefficientsMake(psl->fConstantAttenuation,
															psl->fLinearAttenuation,
															psl->fQuadraticAttenuation) );
		switch (psl->eType) 
		{
			case ePODDirectional:
				setIsDirectionalOnly( true );
				break;
			case ePODPoint:
				setIsDirectionalOnly( false );
				break;
			case ePODSpot:
				setIsDirectionalOnly( false );
				setSpotCutoffAngle( CC3RadToDeg(psl->fFalloffAngle) );
				setSpotExponent( psl->fFalloffExponent );
				break;
			default:
				break;
		}
	}
}
Beispiel #12
0
void Game::onMouseButton(int x, int y, MouseCodes::Button button, bool down)
{
	if (down) switch (button)
		{
			case MouseCodes::Button::Left:
				setAnimation(0);
				walking = false;
				break;
			case MouseCodes::Button::Right:
				setAnimation(2);
				walking = false;
				break;
		}
}
void Orientation::chooseAnimation()
{
	//determine the default orientation of the agent
	Vec3f fwdView(Config::getParamF(Agent_Param::FwdViewX_F), Config::getParamF(Agent_Param::FwdViewY_F), Config::getParamF(Agent_Param::FwdViewZ_F));
	float *rot;
	if(fwdView.z > 0 || fwdView.x > 0)
		rot = &m_target.y;
	else if(fwdView.y > 0) //TODO: well, here we actually have 2 solutions depending on the y-axis rotation, eitehr x is the up axis or z
		rot = &m_target.x;
	
	if(*rot > 0)
		setAnimation( (*m_anims)[MovementAnimTypes::ORIENT_RIGHT] );
	else
		setAnimation( (*m_anims)[MovementAnimTypes::ORIENT_LEFT] );
}
Beispiel #14
0
void Model::setAnimation(const std::string& name)
{
	if( !mesh ) return;

	Animation* animation = mesh->findAnimation(name);
	setAnimation(animation);
}
Beispiel #15
0
void Game::run()
{
	while (window.processEvents())
	{
		float time = window.getTimeSinceLastUpdate() * animSpeed / 1000;
		logic(time);
		player->setParentToLocalR(matrix4f::buildScaling(0.0001f).rotated(vector3f(1, 0, 0), -M_PI / 2).rotated(vector3f(0, 1, 0), dir).translated(pos));
		scene->update(time);
		if (lastAnimation->weight == 0)
		{
			setAnimation(-1u);
			scene->update(1e-7f);
		}

		FrameDescription * frame = scene->getFrame(*camera);
		
		//NEWLOG("camera1: %u camera2: %u", camera, camera2);
		//frame->dump();
		std::vector<MemorySettingOrder> orders;
		ResourceManager::getInstance().getMemoryOrders(frame, orders);
		Renderer::getInstance().executeMemoryOrders(orders);
		
		Renderer::getInstance().drawFrameToSurface(frame, camera, &window);
		delete frame;
		
		window.update();
	}
	window.close();
}
Beispiel #16
0
SiliTab::SiliTab( QWidget *parent ) : QWidget( parent )
{
    p = new SiliTabPrivate;

    p->preview = 0;
    p->previewer_delay = 1357;
    p->previewer_timer = 0;

    p->layout = new QHBoxLayout();
        p->layout->setContentsMargins( 0 , 0 , 0 , 0 );
        p->layout->setSpacing( 1 );

    p->baseLayout = new QHBoxLayout( this );
        p->baseLayout->setContentsMargins( 0 , 0 , 0 , 0 );
        p->baseLayout->setSpacing( 0 );
        p->baseLayout->addLayout( p->layout );
        p->baseLayout->addSpacerItem( new QSpacerItem( 4 ,  2 ,  QSizePolicy::Expanding ,  QSizePolicy::Minimum ) );

    p->default_items_size = QSize( 137 , 30 );
    p->animation = 0;
    p->current_item = 0;

    p->at_spec_removing = false;

    setPreviewer( true );
    setAnimation( true );
}
void MosquitoBase::setState(MOSQUITO_STATE state)
{
	bool loop = true, blend = false;
	float pos[3];
	getPos(pos);
	if(state == eMosuqitoHit)
	{
		loop = false;
		setBillboard("blood_billboard");
		AudioSystem::getInstance()->play3D("../music/spring.wav", pos);
	}
	else if(state == eMosuqitoCut)
	{
		loop = false;
		setBillboard("blood_billboard");
		AudioSystem::getInstance()->play3D("../music/pop.wav", pos);
	}
	else if(state == eMosquitoBlood)
	{
		GameSystem::getInstance()->setDrinkTime();
		AudioSystem::getInstance()->play3D("../music/kiss.wav", pos);
	}
	if(m_uiMeshID < GameSystem::getInstance()->m_vMeshData.size())
	{
		if(state < GameSystem::getInstance()->m_vMeshData[m_uiMeshID].m_vAniName.size())
			setAnimation(GameSystem::getInstance()->m_vMeshData[m_uiMeshID].m_vAniName[state].c_str(), loop, blend);
	}
	m_eState = state;
	m_fTimer = 0.0f;
}
Beispiel #18
0
Spawn::Spawn(uint16_t id, 
	     int16_t x, int16_t y, int16_t z,
	     int16_t deltaX, int16_t deltaY, int16_t deltaZ,
	     int8_t heading, int8_t deltaHeading,
	     uint8_t animation) 
  : Item(tSpawn, id)
{
  // apply the unknown mob values
  m_name = "unknown";
  setNPC(SPAWN_NPC_UNKNOWN);

  // set what is known
  setPos(x, y, z);
  setDeltas(deltaX, deltaY, deltaZ);
  setHeading(heading, deltaHeading);
  setAnimation(animation);
  
  // initialize what isn't to 0
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setLevel(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);
  setTypeflag(0);
  setConsidered(false);

  // turn on auto delete for the track list
  m_spawnTrackList.setAutoDelete(true);
}
Beispiel #19
0
Spawn::Spawn(Spawn& s, uint16_t id)
  : Item(tSpawn, id)
{
  setName(s.name());
  setLastName(s.lastName());
  Item::setPoint(s.x(), s.y(), s.z());
  setPetOwnerID(s.petOwnerID());
  setLight(s.light());
  setGender(s.gender());
  setDeity(s.deity());
  setRace(s.race());
  setClassVal(s.classVal());
  setHP(s.HP());
  setMaxHP(s.maxHP());
  setGuildID(s.GuildID());
  setLevel(s.level());
  for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s.equipment(i));
  setEquipment(tUnknown1, 0);
  setTypeflag(s.typeflag());
  setNPC(s.NPC());
  setAnimation(s.animation());
  setDeltas(s.deltaX(), s.deltaY(), s.deltaZ());
  setHeading(s.heading(), s.deltaHeading());
  setConsidered(s.considered());

  // the new copy will own the spawn track list
  m_spawnTrackList.setAutoDelete(false);
  m_spawnTrackList = s.m_spawnTrackList;
  s.m_spawnTrackList.setAutoDelete(false);
  m_spawnTrackList.setAutoDelete(true);
}
void PathStrokeRenderer::mousePressEvent(QMouseEvent *e)
{
    if (!m_fingerPointMapping.isEmpty())
        return;
    setDescriptionEnabled(false);
    m_activePoint = -1;
    qreal distance = -1;
    for (int i=0; i<m_points.size(); ++i) {
        qreal d = QLineF(e->pos(), m_points.at(i)).length();
        if ((distance < 0 && d < 8 * m_pointSize) || d < distance) {
            distance = d;
            m_activePoint = i;
        }
    }

    if (m_activePoint != -1) {
        m_wasAnimated = m_timer.isActive();
        setAnimation(false);
        mouseMoveEvent(e);
    }

    // If we're not running in small screen mode, always assume we're dragging
    m_mouseDrag = !m_smallScreen;
    m_mousePress = e->pos();
}
Beispiel #21
0
	Character::Character(PhysicsWorld& physicsWorld)
		: Entity(physicsWorld.createCircleBody(GData::r_width/2, GData::r_height/2, GData::t_size/2)),
		  walkingSpeed(4.0f),
		  runningSpeed(8.0f)
	{
		setAnimation(GData::assets.getAnimation("standing"));
	}
Beispiel #22
0
Spawn::Spawn(Spawn* s, uint16_t id) : Item(tSpawn, id)
{
    setName(s->name());
    setLastName(s->lastName());
    Item::setPoint(s->x(), s->y(), s->z());
    setPetOwnerID(s->petOwnerID());
    setLight(s->light());
    setGender(s->gender());
    setDeity(s->deity());
    setRace(s->race());
    setClassVal(s->classVal());
    setHP(s->HP());
    setMaxHP(s->maxHP());
    setGuildID(s->guildID());
    setLevel(s->level());
    for (int i = 0; i <= tLastCoreWearSlot; i++)
    setEquipment(i, s->equipment(i));
    setEquipment(tUnknown1, SlotEmpty);
    setTypeflag(s->typeflag());
    setGM(s->gm());
    setNPC(s->NPC());
    setAnimation(s->animation());
    setDeltas(s->deltaX(), s->deltaY(), s->deltaZ());
    setHeading(s->heading(), s->deltaHeading());
    setConsidered(s->considered());

    // the new copy will own the spawn track list
    m_spawnTrackList.setAutoDelete(false);
    m_spawnTrackList = s->m_spawnTrackList;
    s->m_spawnTrackList.setAutoDelete(false);
    m_spawnTrackList.setAutoDelete(true);
}
Beispiel #23
0
void YYEnemy::updateAnimation(){
    if (frameIntervalCount< actualInterval) {
        frameIntervalCount ++;
    }else{
        frameIntervalCount = 0;
        if(currentFrameIndex < getCurrentActionData()->endFrameIndex){
            currentFrameIndex ++;
            setFrame(currentFrameIndex,isFaceToRight());
        }else{
            isAnimationOver = true;
            if(isRepeatAnimation){
                currentFrameIndex = getCurrentActionData()->startFrameIndex;
                setFrame(currentFrameIndex,isFaceToRight());
            }else{
                switch (_animationID) {
                    case ACTION_STAND:
                    case ACTION_WALK:
                        currentFrameIndex = getCurrentActionData()->startFrameIndex;
                        setFrame(currentFrameIndex,_isFaceToRight);
                        break;
                    case ACTION_ATTACK_0:
                        setAnimation(ACTION_STAND, true, isFaceToRight());
                        setActionState(kActionNormal);
                        break;
                    default:
                        currentFrameIndex = getCurrentActionData()->endFrameIndex;
                        break;
                }
            }
        }
        setPosition(ccpAdd(offsetPerFrame, getPosition()));
    }
}
Beispiel #24
0
void
minidragon::damage(drawable *d)
{
    setAnimation(3);
    isdead = 1;
    killminidragon->play();
}
Beispiel #25
0
void GLWorld::setMark(bool b)
{
    World::setMark(b);
    setAnimation(ANIM_BEND);

    emit changed();
}
Beispiel #26
0
void GLWorld::updateAnimationTarget(bool force_set)
{
    switch(orientation)
    {
    case ORIENT_NORTH:
        player_rotY_target = 0;
        break;
    case ORIENT_WEST:
        player_rotY_target = 90;
        break;
    case ORIENT_SOUTH:
        player_rotY_target = 180;
        break;
    case ORIENT_EAST:
        player_rotY_target = 270;
    default:
        break;
    }

    //Closest direction (270° to 360° instad of 270° to 0°)
    if(player_rotY_from - player_rotY_target > 180)
        player_rotY_from -= 360;
    if(player_rotY_target - player_rotY_from > 180)
        player_rotY_from += 360;

    player_posX_target = steve.first;
    player_posZ_target = steve.second;
    player_posY_target = map[steve.first][steve.second].stack_size * 0.5 - 0.8;

    //setAnimation applies those values, but it's not called at maximum speed
    if(speed_ms == 0 || force_set)
        setAnimation(ANIM_STANDING, true); //Update state
}
void AvatarComponent::tween(CCAnimation * animation, AnimatorData * animatorData, float32 duration)
{
    setAnimation(animation);
    
    for (auto i : m_animatorDataTags)
        this->stopActionByTag(i);
    CC_SAFE_RELEASE_NULL(m_animatorData);
    
    if (animatorData != nullptr)
    {
        m_animatorData = animatorData;
        m_animatorData->retain();
        
        // 移动到期望的位置
        m_animatorData->getInitData()->tweenToNow(this, duration);
        
        DelayTime * delay = DelayTime::create(duration);
        CallFunc * callfunc = CallFunc::create([this](){
            this->resetActions();
        });
        Sequence * sequence = Sequence::create(delay, callfunc, nullptr);
        sequence->setTag(205);
        this->runAction(sequence);
    }
}
Beispiel #28
0
//----------------------------------------------------------------------
// Spawn
Spawn::Spawn()
  : Item(tSpawn, 0)
{
  m_name = "fake";
  setNPC(SPAWN_NPC_UNKNOWN);

  Item::setPos(0, 0, 0);
  setDeltas(0, 0, 0);
  setHeading(0, 0);
  setAnimation(0);
  setPetOwnerID(0);
  setLight(0);
  setGender(0);
  setDeity(0);
  setRace(0);
  setClassVal(0);
  setHP(0);
  setMaxHP(0);
  setGuildID(0xffff);
  setGuildTag(NULL);
  setLevel(0);
  setTypeflag(0);
  for (int i = 0; i < tNumWearSlots; i++)
    setEquipment(i, 0);

  // just clear the considred flag since data would be outdated
  setConsidered(false);

  // finally, note when this update occurred.
  updateLast();
}
Beispiel #29
0
void Avatar::loadGraphics(std::vector<Layer_gfx> _img_gfx) {

	for (unsigned int i=0; i<animsets.size(); i++) {
		if (animsets[i])
			anim->decreaseCount(animsets[i]->getName());
		delete anims[i];
	}
	animsets.clear();
	anims.clear();

	for (unsigned int i=0; i<_img_gfx.size(); i++) {
		if (_img_gfx[i].gfx != "") {
			std::string name = "animations/avatar/"+stats.gfx_base+"/"+_img_gfx[i].gfx+".txt";
			anim->increaseCount(name);
			animsets.push_back(anim->getAnimationSet(name));
			animsets.back()->setParent(animationSet);
			anims.push_back(animsets.back()->getAnimation(activeAnimation->getName()));
			setAnimation("stance");
			if(!anims.back()->syncTo(activeAnimation)) {
				logError("Avatar: Error syncing animation in '%s' to 'animations/hero.txt'.", animsets.back()->getName().c_str());
			}
		}
		else {
			animsets.push_back(NULL);
			anims.push_back(NULL);
		}
	}
	anim->cleanUp();
}
Beispiel #30
0
ANIObject::ANIObject(const CMPFile &cmp) : _ani(0), _cmp(&cmp),
	_visible(false), _paused(false), _mode(kModeContinuous),
	_x(0), _y(0), _background(0), _drawn(false) {

	setAnimation(0);
	setPosition();
}