Exemple #1
0
void UNIT::Update(float deltaTime)
{
	//update unit animation time
	m_time += deltaTime * 0.8f * m_speed;

	//if the unit is moving...
	if(m_moving)
	{
		if(m_movePrc < 1.0f)m_movePrc += deltaTime * m_speed;
		if(m_movePrc > 1.0f)m_movePrc = 1.0f;
		
		//waypoint reached
		if(m_movePrc == 1.0f)
		{
			if(m_activeWP + 1 >= (int)m_path.size())		//goal reached
			{
				m_moving = false;
				SetAnimation("Still");
			}
			else if(!CheckCollision(m_path[m_activeWP + 1])) //Next Waypoint
			{			
				m_activeWP++;
				SetAnimation("Run");
				MoveUnit(m_path[m_activeWP]);
			}
		}

		//Interpolate position between m_lastWP and m_nextWP
		m_position = m_lastWP * (1.0f - m_movePrc) + m_nextWP * m_movePrc;
	}
}
Exemple #2
0
/*
==============================
PostThink

==============================
*/
void CBasePlayer::PostThink()
{
	if ( !g_runfuncs )
		return;

	// select the proper animation for the player character	
	if ( !CL_IsDead() && (m_flTouchedByJumpPad < gpGlobals->time) )
	{
		if (!pev->velocity.x && !pev->velocity.y)
			SetAnimation( PLAYER_IDLE );
		else if ((pev->velocity.x || pev->velocity.y) && (FBitSet(pev->flags, FL_ONGROUND)))
			SetAnimation( PLAYER_WALK );
		else if (pev->waterlevel > 1)
			SetAnimation( PLAYER_WALK );
	}

	if ( !CL_IsDead() && ( m_flThrowTime <= 0.0 ) )
	{
		m_Activity = ACT_BASE_WALK;
		m_flThrowTime = 0.0;
		if (!pev->velocity.x && !pev->velocity.y)
		{
			SetAnimation( PLAYER_IDLE );
		}
		else
		{
			SetAnimation( PLAYER_WALK );
		}
	}

	// Store old velocity for use in backpedalling animations
	m_vecOldVelocity = pev->velocity;
	m_vecOldVelocity.Normalize();
}
void GameEntity::Input()
{ 
	  if (GLFW_PRESS == glfwGetKey(GameWindow, GLFW_KEY_W))
        {
			SetAnimation("LookUp",ONCE);
			SwapUVs(UP);
			
	  }
	  if 
		  (GLFW_PRESS == glfwGetKey(GameWindow, GLFW_KEY_A))
        {
			SetAnimation("Run",LOOP);
			SwapUVs(LEFT);
                m_v3Position -= Vector3(1.f, 0.0f, 0.0f);
        }

        if (GLFW_PRESS == glfwGetKey(GameWindow, GLFW_KEY_S))
        {
			SetAnimation("Duck",LOOP);
			SwapUVs(DOWN);
			m_v3Position += Vector3(0.0f, -1.f, 0.0f);
		}

		if (GLFW_PRESS == glfwGetKey(GameWindow, GLFW_KEY_D))
			{
				if(FacingCheck("RIGHT") != true) // if the sprite isn't already facing right..
					{
					SetAnimation("TurnAround", ONCE); //Set the animation to turn around...
					SwapUVs(RIGHT); //Swap UV's to flip the sprite...
					iFacing = "Right"; // Sets the facing flag to Right.
						if (currentAnimation !="Run")
						{
							SetAnimation("Run",LOOP);
							m_v3Position += Vector3(1.f, 0.0f, 0.0f);
						}
					}
				else
					SwapUVs(RIGHT);
					 m_v3Position += Vector3(1.f, 0.0f, 0.0f);
        }

		if (GLFW_PRESS	== glfwGetKey(GameWindow, GLFW_KEY_SPACE))
		{
			//if(this->Hitbox.CheckGrounded)
		}
	

		 if (GLFW_PRESS == glfwGetKey(GameWindow, GLFW_KEY_V))
        {
			
               SetColor(
				   Vector4((rand()%255)/255.f,(rand()%255)/255.f,(rand()%255)/255.f,1.f),
				   Vector4((rand()%255)/255.f,(rand()%255)/255.f,(rand()%255)/255.f,1.f),
				   Vector4((rand()%255)/255.f,(rand()%255)/255.f,(rand()%255)/255.f,1.f),
				   Vector4((rand()%255)/255.f,(rand()%255)/255.f,(rand()%255)/255.f,1.f)
				   );

        }
}
Exemple #4
0
void OpheliaREV::MC_BestWeapon()
{
	CWeapon* pW	= m_InventoryMgr.GetCurrentWeapon();

	if(pW == DNULL)
	{
		SetNewState(STATE_Idle);
		return;
	}

    if (m_bAnimating == DFALSE)
    {
		if(pW)
		{
			if(m_InventoryMgr.GetAmmoCount(pW->GetAmmoType(DFALSE)) <= 0.0)
			{
				SetAnimation( m_pAnim_Sound->m_nAnim_SWITCH_WEAPON[pW->GetFireType()]);

				m_pServerDE->SetModelLooping(m_hObject, DFALSE);

				m_bAnimating = DTRUE;
			}
			else
			{
				m_bAnimating = DFALSE;
				Metacmd++;
			}
		}
	}
	else
	{
		//Are we done?
		if(m_pServerDE->GetModelPlaybackState(m_hObject) & MS_PLAYDONE)
        {
			if(pW->GetType() == WEAP_TESLACANNON)
			{
				m_InventoryMgr.ChangeWeapon(WEAP_SNIPERRIFLE);
				pW = m_InventoryMgr.GetCurrentWeapon();
				pW->ShowHandModel(DFALSE);
				SetAnimation( m_pAnim_Sound->m_nAnim_SWITCH_WEAPON[pW->GetFireType()]);
			}
			else
			{
				if(m_InventoryMgr.GetAmmoCount(pW->GetAmmoType(DFALSE)) <= 0.0)
				{
					SetNewState(STATE_FindAmmo);
				}
				else
				{
					m_bAnimating = DFALSE;
					Metacmd++;
				}
			}
        }
	}

	return;
}
void EnemyPunk::stop()
{
	//Stop All Movement
	velMovement = 0;

	//Reset Animation
	if(ipFlags.PrevMState != move_stop)	SetAnimation(ENEMY_PUNK_ANIM_STAND, 0, false, false, 15, true);
	else SetAnimation(ENEMY_PUNK_ANIM_STAND, 0, false, false, 15, false);
}
void EnemyJunkbotFlying::processDown()
{
	if(ipFlags.PrevMState != move_down)
		SetAnimation(ENEMY_JUNKBOT_FLYING_MOVE, 0, true, false, 15, true);
	else
		SetAnimation(ENEMY_JUNKBOT_FLYING_MOVE, 0, true, false, 15, false);

	velYModifier = maxWalkSpeed;
}
void EnemyGMonsterFire::stop()
{
	/* Stop All Directional Movement */
	StopMovement();

	/* Set Frame 0 of Attack Animation */
	if(ipFlags.PrevMState != move_stop) SetAnimation(ENEMY_FIRE_MONSTER_ATTACK, 0, false, false, 15, true);
	else SetAnimation(ENEMY_FIRE_MONSTER_ATTACK, 0, false, false, 15, false);
}
void EnemyGreenNinja::stop()
{
	//Stop All Movement
	velMovement = 0;

	//Reset Animation
	if(ipFlags.PrevMState != move_stop)
		SetAnimation(ENEMY_GREEN_NINJA_ANIM_MOVE, 0, false, false, 22, true);
	else
		SetAnimation(ENEMY_GREEN_NINJA_ANIM_MOVE, 0, false, false, 22, false);
}
void Protagonist::ChangeStance(ePLAYER_STANCE eSTANCE)
{
	if( !Player::IsDead() && eCURRENTSTANCE != eSTANCE )
	{
		SetAnimation(eSTANCE);
	}
	else if( Player::IsDead() )
	{
		SetAnimation(DEAD);
	}
}
void EnemyZombiePrisoner::stop()
{
	//Stop All Movement
	velMovement = 0;

	//Reset Animation
	if(ipFlags.PrevMState != move_stop)
		SetAnimation(ENEMY_PRISONER_ZOMBIE_ANIM_MOVE, 0, true, false, 15, true);
	else
		SetAnimation(ENEMY_PRISONER_ZOMBIE_ANIM_MOVE, 0, true, false, 15, false);
}
Exemple #11
0
void Actor::SetAnimation(string s) {
	if(s == "move-down") {
		SetAnimation(rect.x, 550, 200);
	} else if(s == "move-up") {
		SetAnimation(rect.x, 0, 60);
	} else if(s == "move-left") {
		SetAnimation(-100, rect.y, 150);
	} else if(s == "move-right") {
		SetAnimation(800, rect.y, 150);
	}
}
void EnemyDockWorkerWrench::stop()
{
	//Stop All Movement
	velMovement = 0;

	//Reset Animation
	if(ipFlags.PrevMState != move_stop)
		SetAnimation(ENEMY_DOCK_WORKER_ANIM_MOVE, 0, false, false, 22, true);
	else
		SetAnimation(ENEMY_DOCK_WORKER_ANIM_MOVE, 0, false, false, 22, false);
}
void AnimatedSprite::Input() {
	Sprite::Input();
	if(GLFW_PRESS == glfwGetKey(GameWindow, GLFW_KEY_P)) {

		SetAnimation("idle to run", LOOPSECTION, 1);
	}
	if (GLFW_PRESS == glfwGetKey(GameWindow, GLFW_KEY_T)) {

		SetAnimation("teleport", ONCE);
	}
}
void EnemyPrisonerRock::stop()
{
	//Stop All Movement
	velMovement = 0;

	//Reset Animation
	if(ipFlags.PrevMState != move_stop)
		SetAnimation(ENEMY_PRISONER_ANIM_THROW, 0, false, false, 22, true);
	else
		SetAnimation(ENEMY_PRISONER_ANIM_THROW, 0, false, false, 22, false);
}
void EnemyShadowElitePistol::stop()
{
	//Stop All Movement
	velMovement = 0;

	//Reset Animation
	if(ipFlags.PrevMState != move_stop)
		SetAnimation(ENEMY_PISTOL_ELITE_GUARD_ANIM_MOVE, 0, false, false, 22, true);
	else
		SetAnimation(ENEMY_PISTOL_ELITE_GUARD_ANIM_PISTOL_ATTACK, 0, false, false, 22, false);
}
void EnemyJunkbotFlying::processRight()
{
	if(ipFlags.PrevMState != move_right)
		SetAnimation(ENEMY_JUNKBOT_FLYING_MOVE, 0, true, false, 15, true);
	else
		SetAnimation(ENEMY_JUNKBOT_FLYING_MOVE, 0, true, false, 15, false);

	velMovement = maxWalkSpeed;

	//Set Sprite Direction
	ipFlags.S_DIRECTION = true;
}
void EnemyDockWorkerWrench::processRight()
{
	//If Not Previously Moving Right - Reset Animation
	if(ipFlags.PrevMState != move_right)
		SetAnimation(ENEMY_DOCK_WORKER_ANIM_MOVE, 0, true, false, 22, true);
	else
		SetAnimation(ENEMY_DOCK_WORKER_ANIM_MOVE, 0, true, false, 22, false);

	velMovement = maxWalkSpeed;

	//Set Sprite Direction
	ipFlags.S_DIRECTION = true;
}
void EnemyZombiePrisoner::processRight()
{
	//If Not Previously Moving Left - Reset Animation
	if(ipFlags.PrevMState != move_right)
		SetAnimation(ENEMY_PRISONER_ZOMBIE_ANIM_MOVE, 0, true, false, 15, true);
	else
		SetAnimation(ENEMY_PRISONER_ZOMBIE_ANIM_MOVE, 0, true, false, 15, false);

	velMovement = maxWalkSpeed;

	//Set Sprite Direction
	ipFlags.S_DIRECTION = true;
}
void CHL2MP_Player::ResetAnimation( void )
{
	if ( IsAlive() )
	{
		SetSequence ( -1 );
		SetActivity( ACT_INVALID );

		if (!GetAbsVelocity().x && !GetAbsVelocity().y)
			SetAnimation( PLAYER_IDLE );
		else if ((GetAbsVelocity().x || GetAbsVelocity().y) && ( GetFlags() & FL_ONGROUND ))
			SetAnimation( PLAYER_WALK );
		else if (GetWaterLevel() > 1)
			SetAnimation( PLAYER_WALK );
	}
}
void AnimSprite::SetAnimation(std::string a_sAnimation, AnimCycle cycle, int frame = 0)
{
	m_sCurrentAnimation = a_sAnimation;
	iCurrentFrame = 0;
	iLoopMarker = frame;
	iPlayDirection = 1;
	currentCycle = cycle;

	switch (cycle)
	{
	case ONCE:
		break;
	case LOOP:
		iLoopMarker = 0;
		break;
	case PINGPONG:
		break;
	case REVERSE:
		iCurrentFrame = m_mAnimations[m_sCurrentAnimation].size();
		iLoopMarker = iCurrentFrame;
		break;
	case RANDOM:
		break;
	case SINGLE:
		break;
	default:
		SetAnimation(a_sAnimation, cycle);
		break;
	}

	m_sCurrentSlice = m_mAnimations.at(m_sCurrentAnimation)[iCurrentFrame];
	SetSlice();
	UVSetup();
}
bool CXModel::LoadXFile(char *file)
{
   if(!m_device) return false;

   CD3DAllocate alh;

   // Load X mesh from a file.
   if(FAILED(D3DXLoadMeshHierarchyFromX(file, D3DXMESH_MANAGED,
      m_device, &alh, NULL, &m_root, &m_animControl))) return false;

   // Record max number of animation sets in the X model.
   if(m_animControl)
      m_numAnimations = m_animControl->GetMaxNumAnimationSets();

   // Setup Bones.
   if(m_root)
      {
         SetupMatrices((stD3DFrameEx*)m_root, NULL);

         m_boneMatrices = new D3DXMATRIX[m_maxBones];
         ZeroMemory(m_boneMatrices, sizeof(D3DXMATRIX)*m_maxBones);

         D3DXFrameCalculateBoundingSphere(m_root, &m_center,
                                          &m_radius);
      }

   // Set initialize animation.
   SetAnimation(0);

   return true;
}
void EnemyShadowElitePistol::processRight()
{
	//If Not Previously Moving Right - Reset Animation
	if(ipFlags.PrevMState != move_right)
		SetAnimation(ENEMY_PISTOL_ELITE_GUARD_ANIM_MOVE, 0, true, false, 22, true);
	else
		SetAnimation(ENEMY_PISTOL_ELITE_GUARD_ANIM_MOVE, 0, true, false, 22, false);

	//Accelerate Right Velocity
//	velMovement += walkAcceleration;
//	if(velMovement >= maxWalkSpeed)
		velMovement = maxWalkSpeed;

	//Set Sprite Direction
	ipFlags.S_DIRECTION = true;
}
Exemple #23
0
void Protagonist::SelectRocketLauncher()  
{  
	eCURRENTWEAPON = RocketLauncher.GetWeaponID();  
	pCurrentWeapon = &RocketLauncher;
	SetAnimation(eCURRENTSTANCE);
	if( eCURRENTSTANCE==DUCK ) 	MainAnimation->SetFrame(1);
}
Exemple #24
0
void Protagonist::SelectAssaultRifle()    
{  
	eCURRENTWEAPON = AssaultRifle.GetWeaponID();    
	pCurrentWeapon = &AssaultRifle;
	SetAnimation(eCURRENTSTANCE);
	if( eCURRENTSTANCE==DUCK ) 	MainAnimation->SetFrame(1);
}
Exemple #25
0
void CCritter::AddObject(uint8_t aslot,uint32_t o_id,uint32_t broken_info,uint32_t time_wear,stat_obj* s_obj)
{
  __invariant();
  dyn_obj* new_obj=new dyn_obj;
  new_obj->id=o_id;
  new_obj->object=s_obj;
  new_obj->type=new_obj->object->type;
  new_obj->time_wear=time_wear;
  new_obj->broken_info=broken_info;

  switch(aslot)
  {
  case DOBJ_SLOT_INV:
    obj[o_id]=new_obj;
    break;
  case DOBJ_SLOT_HAND1:
    if(new_obj->type!=OBJ_TYPE_ARMOR) a_obj=new_obj;
    break;
  case DOBJ_SLOT_HAND2:
    break;
  case DOBJ_SLOT_TWOHAND:
    break;
  case DOBJ_SLOT_ARMOR:
    if(new_obj->type==OBJ_TYPE_ARMOR) a_obj_arm=new_obj;
    break;
  }

  SetAnimation();
}
ProjectilePrisonerRock::ProjectilePrisonerRock(bool bDirection, int xPos, int yPos)
{
	/* Set Sprite Number */
	SetSprite(1, CR::AssetList::prisoner_rock);

	/* Set Sprite Direction */
	SetDirection(bDirection);

	/* Set Weapon Bounding Box */
	SetWeaponBounds(12,12);

	/* Set Activate & Delay Timer */
	SetActiveTime(3);
	SetDelayTime(.25);

	/* Set Velocity Direction */	
	if(bDirection) SetVelocityVector((float)(rand()%50+75), 0);
	else SetVelocityVector((float)(-(rand()%50+75)), 0);

	/* Set Acceleration Vector */
	SetAccelerationVector(0, (float)(rand()%75 + 65));
	
	/* Set Start Position */
	SetPosition(xPos, yPos);

	/* Set Damage Value */
	SetWeaponDamage(5);

	proj_flags.S_NON_PROJECTILE = true;

	/* Initialize Sprite */
	SetAnimation(0, 0, true, false, 10, true);
}
bool wxAnimationCtrl::Create( wxWindow *parent, wxWindowID id,
                              const wxAnimation& anim,
                              const wxPoint& pos,
                              const wxSize& size,
                              long style,
                              const wxString& name)
{
    if (!PreCreation( parent, pos, size ) ||
        !base_type::CreateBase(parent, id, pos, size, style & wxWINDOW_STYLE_MASK,
                               wxDefaultValidator, name))
    {
        wxFAIL_MSG( wxT("wxAnimationCtrl creation failed") );
        return false;
    }

    SetWindowStyle(style);

    m_widget = gtk_image_new();
    g_object_ref(m_widget);
    gtk_widget_show(m_widget);

    m_parent->DoAddChild( this );

    PostCreation(size);
    SetInitialSize(size);

    if (anim.IsOk())
        SetAnimation(anim);

    // init the timer used for animation
    m_timer.SetOwner(this);

    return true;
}
ProjectileNinjaStar::ProjectileNinjaStar(bool bDirection, int xPos, int yPos)
{
	/* Set Sprite Number */
	SetSprite(1, CR::AssetList::ninja_star);


	/* Set Sprite Direction */
	SetDirection(bDirection);

	/* Set Weapon Bounding Box */
	SetWeaponBounds(16,16);

	/* Set Activate & Delay Timer */
	SetActiveTime(4);
	SetDelayTime(.25);

	/* Set Velocity Direction */
	if(bDirection) SetVelocityVector(80, 0);
	else SetVelocityVector(-80, 0);

	/* Set Start Position */
	SetPosition(xPos, yPos);

	/* Set Damage Value */
	SetWeaponDamage(2);	
	
	/* Initialize Sprite */
	SetAnimation(0, 0, true, false, 30, true);
	projectile_spr->EnableFrameSkip(false);
}
Exemple #29
0
void Protagonist::SelectShotGun()  
{  
	eCURRENTWEAPON = ShotGun.GetWeaponID();  
	pCurrentWeapon = &ShotGun;
	SetAnimation(eCURRENTSTANCE);
	if( eCURRENTSTANCE==DUCK ) 	MainAnimation->SetFrame(1);
}
void Player::Update()
{
	if (CheckAuthorization())
	{
		if (isJumping)
		{
			velocity.y = jumpVelocity;
			jumpVelocity += 0.4f;

			if (jumpVelocity > scene->GetGravity())
				isJumping = false;
		}

		if (!isClimbing)
		{
			if (velocity.x != 0.0f)
				SetAnimation("walk");
			else sprite->SetToStaticAnimation();
		}

		if (game->GetClient() != nullptr)
			game->GetClient()->SendMessage("1", Serialize());
	}

	FunctionalObject::Update();
}