コード例 #1
0
void CHeavyInfantry::Update(float fElapsedTime)
{
    if( GetDead() == false )
    {
        // If the unit is either not in a squad or it has been issued the order to attack from the squad
        if( Attack() == true )
        {
            if( GetCalculate() == true )
            {
                GetState()->CalculateAI(fElapsedTime, this);
            }

            if( GetHealth() < GetMaxHealth() * 0.5f )
            {
                SetCalculate(false);
                tVector2D vectorToPlayer;
                vectorToPlayer.fX = GetTarget()->GetPosX() - GetPosX();
                vectorToPlayer.fY = GetTarget()->GetPosY() - GetPosY();
                vectorToPlayer = Vector2DNormalize(vectorToPlayer);
                SetVelX(vectorToPlayer.fX*(GetSpeed()*2));
                SetVelX(vectorToPlayer.fY*(GetSpeed()*2));
            }
        }

        // Set Facing
        if( GetVelX() > GetVelY() )
        {
            SetFacing(1.0f,0.0f);
        }
        else if( -GetVelX() < -GetVelY() )
        {
            SetFacing(-1.0f,0.0f);
        }
        else if( GetVelY() > GetVelX() )
        {
            SetFacing(0.0f,1.0f);
        }
        else if( -GetVelY() < -GetVelX() )
        {
            SetFacing(0.0f,-1.0f);
        }

        SetPosX(GetPosX()+(GetVelX()*fElapsedTime));
        SetPosY(GetPosY()+(GetVelY()*fElapsedTime));
    }

    CEnemy::Update(fElapsedTime);
}
コード例 #2
0
void
SpriteEditWindow::AddFacing	(sint32 add)
{
	m_facing += add;

	SetFacing(m_facing);
}
コード例 #3
0
void main()
{
    effect glow = EffectVisualEffect(VFX_DUR_AURA_PULSE_PURPLE_BLACK);
    ApplyEffectToObject(DURATION_TYPE_PERMANENT, glow, OBJECT_SELF);
    SetFacing(270.0);
    ActionPlayAnimation(ANIMATION_LOOPING_CONJURE1, 1.0, 5.0);
}
コード例 #4
0
void scene_gestalt()
{
    float time = 0.0;
    float offset = 1.0;
    object p1 = GetObjectByTag("intro_p1_start");
    object p2 = GetObjectByTag("intro_p2_start");
    object p2e = GetObjectByTag("intro_p2_end");
    object p3 = GetObjectByTag("intro_p3");

    /* Initialize */
    GestaltStartCutscene(pc);
    GestaltCameraFade(time, pc, FADE_CROSS, FADE_SPEED_MEDIUM, fade_duration);
    ghost();

    /* Setup */
    time = 2*delay;
    GestaltInvisibility(time, pc);
    GestaltCameraFacing(time, 63.0, 10.0, 85.0, pc);
    play_audio(time);

    /* Pass 1 */
    GestaltJump(time, pc, p1);
    GestaltActionMove(time + offset, pc, p2, FALSE, 0.0, 5*delay);

    /* Pass 2 */
    time = 7*delay;
    GestaltCameraFade(time - offset, pc, FADE_CROSS, FADE_SPEED_MEDIUM, fade_duration);
    GestaltCameraFacing(time + offset, 293.0, 10.0, 85.0, pc);
    GestaltJump(time, pc, p2);
    GestaltActionMove(time + offset, pc, p2e, FALSE, 0.0, 5*delay);


    /* Pass 3 (zoom into shadow) */
    time = 12*delay;
    GestaltCameraFade(time - offset, pc, FADE_CROSS, FADE_SPEED_MEDIUM, fade_duration);
    GestaltJump(time + offset, pc, p3);
    GestaltCameraMove(time + offset, 260.0, 20.0, 85.0, 280.0, 10.0, 85.0, 5*delay, 60.0, pc);

    /* Clean up and end cutscene */
    time = 16 * delay;
    DelayCommand(time, FadeToBlack(pc));
    //GestaltCameraFade(time - offset, pc, FADE_CROSS, FADE_SPEED_MEDIUM, fade_duration);

    /* Trigger ScriptEase */
    time = 18 * delay;
    GestaltClearEffect(time, pc);
    GestaltStopCutscene(time, pc, "intro_end");

    time = time + offset;
    // GestaltCameraFacing(time, 270.0, 10.0, 75.0, pc);
    AssignCommand(pc, SetCameraFacing(270.0, 10.0));
    DelayCommand(time, AssignCommand(pc, SetFacing(270.0)));
    DelayCommand(time, SetLocked(GetObjectByTag("activate_easel_trigger"), FALSE));
    DelayCommand(time, FadeFromBlack(pc));
}
コード例 #5
0
ファイル: camera.cpp プロジェクト: shuidong/Vox
// Constructor
Camera::Camera(Renderer* pRenderer)
{
	m_pRenderer = pRenderer;

	SetPosition(vec3(0.0f, 0.0f, 0.0f));
	SetFacing(vec3(0.0f, 0.0f, -1.0f));
	SetUp(vec3(0.0f, 1.0f, 0.0f));
	SetRight(vec3(1.0f, 0.0f, 0.0f));

	m_zoomAmount = 3.0f;
	m_minZoomAmount = 0.1f;
	m_maxZoomAmount = 100.0f;
}
コード例 #6
0
ファイル: Protagonist.cpp プロジェクト: codinpsycho/The_Siege
void Protagonist::Update( HGE*engine, float ftime )    
{ 
	MainAnimation->Update( ftime );

	if( Player::IsDead() ) return;
	
	if( eCURRENTSTANCE != JUMPING  && eCURRENTSTANCE != DEAD )
	if(engine->Input_GetKeyState(HGEK_ALT) )
	{
		if( ThrowGrenade() )
		{ 
			ChangeStance( THROW_GRENADE);	
		}
	}
	else
	if (engine->Input_GetKeyState(HGEK_SHIFT) )
	{
		ChangeStance( MELEE );
	}
 	else
	if( ( engine->Input_KeyUp(HGEK_DOWN) ) && eCURRENTSTANCE == DUCK /* && eCURRENTSTANCE != THROW_GRENADE */)
	{
			ChangeStance( DUCK );
			MainAnimation->SetMode(HGEANIM_REV);
			Play(); 
	
	}
	else
	if( ( engine->Input_KeyUp(HGEK_UP) )  && eCURRENTSTANCE == LOOKUP && eCURRENTSTANCE != THROW_GRENADE )
	{
		ChangeStance( LOOKUP );
		MainAnimation->SetMode(HGEANIM_REV);
		Play();
	}
	else     ///////////////////////
		if ( !MainAnimation->IsPlaying()  || eCURRENTSTANCE == RUNNING || eCURRENTSTANCE == LOWMOVE || eCURRENTSTANCE == MOVE_BACK )
	    {	
		if ( engine->Input_KeyUp(HGEK_DOWN) /*&& eCURRENTSTANCE != LOOKUP*/ )
		{
			ChangeStance( DUCK );
			MainAnimation->SetMode(HGEANIM_REV);
			Play();
		}
		else
		if (engine->Input_GetKeyState(HGEK_UP) )
		{
			ChangeStance( LOOKUP );	
		}
		else
		if (engine->Input_GetKeyState(HGEK_DOWN) )
		{
				if( engine->Input_GetKeyState(HGEK_RIGHT)  ) // Stealth Move Right
				{
					if( eCURRENTSTANCE == LOWMOVE && !MainAnimation->IsPlaying() ) eCURRENTSTANCE = IDLE;
					ChangeStance( LOWMOVE ); 
					SetFacing( FACERIGHT,false );
					vDirection.x = +1;
				}
				else 
				if( engine->Input_GetKeyState(HGEK_LEFT)  )  // Stealth Move Left
				{
					if( eCURRENTSTANCE == LOWMOVE && !MainAnimation->IsPlaying() ) eCURRENTSTANCE = IDLE;
					ChangeStance( LOWMOVE );
					SetFacing( FACELEFT,true );
					vDirection.x = -1;
				}
				else if(eCURRENTSTANCE == LOWMOVE)   // Stealth Move
				{ 
					ChangeStance( DUCK );  MainAnimation->SetFrame(1);  
				}
 				else
				{ 
					ChangeStance( DUCK ); 
					vDirection.x = ( eFACING == FACERIGHT ) ? 1 : -1;
				}
		}
		else
		if (engine->Input_GetKeyState(HGEK_LEFT) )     // move left
		{
			if ( engine->Input_GetKeyState( HGEK_CTRL ) && eFACING == FACERIGHT )
			{
				if(eCURRENTSTANCE == MOVE_BACK && !MainAnimation->IsPlaying() ) ChangeStance(IDLE);
				ChangeStance(MOVE_BACK);		
				vDirection.x = -1;
			}
			else
			{
				if(eCURRENTSTANCE==RUNNING && !MainAnimation->IsPlaying()) eCURRENTSTANCE = IDLE;
				SetFacing( FACELEFT,true );
				ChangeStance( RUNNING ); 
				vDirection.x = -1;
			}
		}
		else
		if (engine->Input_GetKeyState(HGEK_RIGHT) )  // move right
		{
			if ( engine->Input_GetKeyState( HGEK_CTRL ) && eFACING == FACELEFT )
			{
				if(eCURRENTSTANCE == MOVE_BACK && !MainAnimation->IsPlaying() ) ChangeStance(IDLE);
				ChangeStance(MOVE_BACK);		vDirection.x = 1;
			}
			else
			{
				if(eCURRENTSTANCE==RUNNING && !MainAnimation->IsPlaying()) eCURRENTSTANCE = IDLE;
				SetFacing( FACERIGHT,false );
				ChangeStance( RUNNING );	
				vDirection.x = +1;
			}
		}
		else
		{
			ChangeStance( IDLE );
		}

	}
		/*
		if( eCURRENTSTANCE == MOVE_BACK )
		vDirection.x = ( eFACING == FACERIGHT ) ? -1 :  1;
		else
		vDirection.x = ( eFACING == FACERIGHT ) ?  1 : -1;
		*/
}	
コード例 #7
0
ファイル: Pacman.cpp プロジェクト: JohnBali/Pac-Man
void Pacman::Update(sf::Time elapsed, int ghostMode, sf::Color spriteColor)
{
	if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
	{
		if ((!map->isCollision(GetRow(), GetColumn() + 1) || !ColumnBoundary() || (GetColumn() >= 27 || GetColumn() < 0)) && RowBoundary())
		{
			SetFacing(Pacman::RIGHT);
		}		
	}
	else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
	{
		if ((!map->isCollision(GetRow(), GetColumn() - 1) || !ColumnBoundary() || (GetColumn() - 1) < 0) && RowBoundary())
		{
			SetFacing(Pacman::LEFT);
		}		
	}
	else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
	{
		if ((!map->isCollision(GetRow() + 1, GetColumn()) || !RowBoundary()) && ColumnBoundary())
		{
			SetFacing(Pacman::DOWN);
		}		
	}
	else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
	{
		if ((!map->isCollision(GetRow() - 1, GetColumn()) || !RowBoundary()) && ColumnBoundary())
		{
			SetFacing(Pacman::UP);
		}		
	}

	timeBetweenMoves -= elapsed;
	if (timeBetweenMoves <= sf::Time::Zero)
	{
		if (GetFacing() == Pacman::RIGHT)
		{
			if (RowBoundary())
			{
				if (!map->isCollision(GetRow(), GetColumn() + 1) || !ColumnBoundary() || (GetColumn() >= 27 || GetColumn() < 0))
				{
					walk(map);
				}
			}
		}
		else if (GetFacing() == Pacman::LEFT)
		{
			if (RowBoundary())
			{
				if (!map->isCollision(GetRow(), GetColumn() - 1) || !ColumnBoundary() || (GetColumn() - 1) < 0)
				{
					walk(map);
				}
			}

		}
		else if (GetFacing() == Pacman::DOWN)
		{
			if (ColumnBoundary())
			{
				if (!map->isCollision(GetRow() + 1, GetColumn()) || !RowBoundary())
				{
					walk(map);
				}
			}
		}
		else if (GetFacing() == Pacman::UP)
		{
			if (ColumnBoundary())
			{
				std::cout << "row:" << RowBoundary() << std::endl;

				if (!map->isCollision(GetRow() - 1, GetColumn()) || !RowBoundary())
				{
					walk(map);
				}
			}
		}
		timeBetweenMoves = sf::milliseconds(25);

		if (debug)
		{
			Debug();
		}
	}
}