예제 #1
0
void CASW_Simple_Alien::ReachedEndOfSequence()
{
	bool bShouldAttack = ShouldAttack();
	if (bShouldAttack != m_bAttacking)	// make sure we're playing the right sequence for running/attacking
	{
		m_bAttacking = bShouldAttack;
		if (!m_bOnGround)
			PlayFallingAnimation();
		else if (m_bAttacking)
			PlayAttackingAnimation();
		else
			PlayRunningAnimation();

		m_flPlaybackRate = 1.25f;
	}
	else
	{
		if (!m_bOnGround)
			PlayFallingAnimation();
		else
			PlayRunningAnimation();
	}
	
}
예제 #2
0
void CASW_Simple_Alien::Spawn(void)
{
	BaseClass::Spawn();
	Precache();

	// appearance
	SetModel( SWARM_NEW_DRONE_MODEL );
	m_flAnimTime = gpGlobals->curtime;	
	SetCycle( 0 );
	PlayRunningAnimation();

	// collision
	SetHullType( HULL_MEDIUMBIG ); 
	UTIL_SetSize(this, Vector(-19,-19,0), Vector(19,19,69));
	SetSolid( SOLID_BBOX );
	AddSolidFlags( FSOLID_NOT_STANDABLE );
	SetCollisionGroup( ASW_COLLISION_GROUP_ALIEN );	

	// movement
	SetMoveType( MOVETYPE_STEP );
	m_fArrivedTolerance = 30.0f;

	// health
	m_iHealth = ASWGameRules()->ModifyAlienHealthBySkillLevel(asw_drone_health.GetInt());

	SetMaxHealth(m_iHealth);
	m_takedamage		= DAMAGE_YES;
		
	// state
	SetState(ASW_SIMPLE_ALIEN_IDLING);
	SetSleeping(true);
	m_fLastThinkTime = gpGlobals->curtime;
	SetThink( &CASW_Simple_Alien::SleepThink );
	SetNextThink( gpGlobals->curtime + random->RandomFloat(0.01f, 0.2f) );

	UpdateSleeping();
}
예제 #3
0
파일: Player.cpp 프로젝트: jojizaidi/Gnome
void Player::Update(float dt)
{

    if (movePowerup)
    {
        powerup->setPosition(ccp(powerup->getPosition().x + pathSpeed , powerup->getPosition().y));
        
        if (powerup->getPosition().x < -powerup->getContentSize().width)
        {
            powerup->setPosition(ccp(winSize.width + powerup->getContentSize().width, powerup->getPosition().y));
            movePowerup = false;
        }
    }
    
    if (movePouch)
    {
        rockPouch->setPosition(ccp(rockPouch->getPosition().x + pathSpeed , rockPouch->getPosition().y));
        
        if (rockPouch->getPosition().x < -rockPouch->getContentSize().width)
        {
            rockPouch->setPosition(ccp(winSize.width + rockPouch->getContentSize().width, rockPouch->getPosition().y));
            movePouch = false;
        }
    }
    
    playerYpos = playerSprite->getPosition().y;
    
    playerRect = CCRectMake(playerSprite->getPosition().x - playerSprite->getContentSize().width * 0.15,
                            playerSprite->getPosition().y + playerSprite->getContentSize().height * 0.15,
                            playerSprite->getContentSize().width * 0.2f,
                            playerSprite->getContentSize().height * 0.5f);
    
    if (playerRect.intersectsRect(powerup->boundingBox()) && checkPowerupCollision)
    {
        powerup->setPosition(ccp(winSize.width + powerup->getContentSize().width , powerup->getPosition().y));
        movePowerup = false;
        tempPowerupState = CCRANDOM_0_1() > 0.5f ? scooter : threeWheeler;
        PlayPowerPickupAnimation();
        ShowEmp();
        checkPowerupCollision = false;
    }
    
    if (playerRect.intersectsRect(rockPouch->boundingBox()) && checkPouchCollision)
    {
        CocosDenshion::SimpleAudioEngine::sharedEngine()->playEffect("Audio/Rock_Bag_Pick_up.wav");
        rockPouch->setPosition(ccp(winSize.width + rockPouch->getContentSize().width , rockPouch->getPosition().y));
        movePouch = false;
        totalRocks++;
        checkPouchCollision = false;
        AnimateRockLabel();
    }
    
    //playerBoundingBox->DestroyAll();
    //playerBoundingBox->appendRect(playerRect);
    
    SetPlayerShadow();

    gravity = gravity - 0.5;
    playerSprite->setPosition(ccp(playerSprite->getPosition().x ,playerSprite->getPosition().y + gravity));
    
    if (playerCurrentState != playerPreviousState)
        playAnim = true;
    
    if (playAnim)
    {
        if (playerCurrentState == jumpState && playerPowerupState == noPowerup)
        {
            PlayJumpAnimation();
        }
        else if (playerCurrentState == rollState && playerPowerupState == noPowerup)
        {
            PlayRollAnimation();
        }
        else if (playerCurrentState == runState && playerPowerupState == noPowerup)
        {
            PlayRunningAnimation();
        }
        else if (playerCurrentState == gotHitState)
        {
            PlayGotHitAnimation();
        }
        else if (playerCurrentState == gameOverState)
        {
            GameOver();
        }
        
        playAnim = false;
    }

    playerPreviousState = playerCurrentState;
    
    ClampPlayerLocation();
}