Example #1
0
void cRokko::Set_Direction(const ObjectDirection dir, bool new_start_direction /* = true */)
{
    // already set
    if (m_start_direction == dir) {
        return;
    }

    // clear old images
    //Clear_Images();

    cEnemy::Set_Direction(dir, new_start_direction);

    if (m_direction == DIR_LEFT) {
        Set_Rotation(0.0f, 0.0f, 0.0f, 1);
    }
    else if (m_direction == DIR_RIGHT) {
        Set_Rotation(0.0f, 180.0f, 0.0f, 1);
    }
    else if (m_direction == DIR_UP) {
        Set_Rotation(0.0f, 0.0f, 90.0f, 1);
    }
    else if (m_direction == DIR_DOWN) {
        Set_Rotation(0.0f, 0.0f, 270.0f, 1);
    }
    else {
        printf("Warning: Unknown Rokko direction %s\n", Get_Direction_Name(dir).c_str());
    }

    Update_Rotation_Hor();
    Update_Distance_rect();
    //Set_Image_Num( 0, 1 );
}
Example #2
0
void cFlyon::Set_Direction(const ObjectDirection dir)
{
    // already set
    if (dir == m_direction) {
        return;
    }

    if (dir != DIR_UP && dir != DIR_DOWN && dir != DIR_LEFT && dir != DIR_RIGHT) {
        printf("Error : Unknown Flyon direction %d\n", m_direction);
        return;
    }

    cEnemy::Set_Direction(dir, 1);

    // clear
    Set_Rotation(0.0f, 0.0f, 0.0f, 1);

    if (m_start_direction == DIR_UP) {
        // default
    }
    else if (m_start_direction == DIR_LEFT) {
        Set_Rotation_Z(270.0f, 1);
    }
    else if (m_start_direction == DIR_RIGHT) {
        Set_Rotation_Z(90.0f, 1);
    }
    else if (m_start_direction == DIR_DOWN) {
        Set_Rotation_Z(180.0f, 1);
    }

    Set_Velocity(0.0f, 0.0f);
    Update_Dest_Vel();
}
Example #3
0
void cRokko :: Set_Direction( const ObjectDirection dir )
{
	// already set
	if( m_start_direction == dir )
	{
		return;
	}

	// clear old images
	Clear_Images();

	cEnemy::Set_Direction( dir, 1 );
	m_name = "Rokko ";
	m_name += _(Get_Direction_Name(m_start_direction).c_str());

	Add_Image( pVideo->Get_Surface( "enemy/rokko/r.png" ) );

	if( m_direction == DIR_LEFT )
	{
		Set_Rotation( 0.0f, 180.0f, 0.0f, 1 );
	}
	else if( m_direction == DIR_RIGHT )
	{
		Set_Rotation( 0.0f, 0.0f, 0.0f, 1 );
	}
	else if( m_direction == DIR_UP )
	{
		Set_Rotation( 0.0f, 0.0f, 270.0f, 1 );
	}
	else if( m_direction == DIR_DOWN )
	{
		Set_Rotation( 0.0f, 0.0f, 90.0f, 1 );
	}
	else
	{
		printf( "Warning: Unknown Rokko direction %s\n", Get_Direction_Name( dir ).c_str() );
	}

	Update_Distance_rect();
	Set_Image_Num( 0, 1 );
}
Example #4
0
//---------------------------------------------------------
CSG_3DView_Projector::CSG_3DView_Projector(void)
{
	Set_Center  (0.0, 0.0, 0.0);
	Set_Scaling (1.0, 1.0, 1.0);
	Set_Rotation(0.0, 0.0, 0.0);
	Set_Shift   (0.0, 0.0, 1500.0);
	Set_Screen  (100, 100);

	m_Scale		= 1.0;
	m_bCentral	= true;
	m_dCentral	= 1500.0;
}
Example #5
0
void cEato::Set_Direction(const ObjectDirection dir)
{
    if (m_start_direction == dir)
    {
        return;
    }

    cEnemy::Set_Direction(dir, 1);

    Set_Rotation(0.0f, 0.0f, 0.0f, 1);

    if (m_start_direction == DIR_UP_LEFT)
    {
        Set_Rotation_Y(180.0f, 1);
    }
    else if (m_start_direction == DIR_UP_RIGHT)
    {
    }
    else if (m_start_direction == DIR_LEFT_UP)
    {
        Set_Rotation_Z(90.0f, 1);
        Set_Rotation_X(180.0f, 1);
    }
    else if (m_start_direction == DIR_LEFT_DOWN)
    {
        Set_Rotation_Z(90.0f, 1);
    }
    else if (m_start_direction == DIR_RIGHT_UP)
    {
        Set_Rotation_Z(270.0f, 1);
    }
    else if (m_start_direction == DIR_RIGHT_DOWN)
    {
        Set_Rotation_Z(270.0f, 1);
        Set_Rotation_X(180.0f, 1);
    }
    else if (m_start_direction == DIR_DOWN_LEFT)
    {
        Set_Rotation_X(180.0f, 1);
    }
    else if (m_start_direction == DIR_DOWN_RIGHT)
    {
        Set_Rotation_Z(180.0f, 1);
    }

    Create_Name();
}
void CCharacterControllerEnemy::Update(void)
{
    float fTrackTexCoordOffsetMoveFactor  = 0.2f;
    
    m_vRotation.y = CMathHelper::Instance()->Get_WrapAngle(m_vRotation.y, 0.0f, 360.0f);
    
    switch (m_eState)
    {
        case E_AI_STATE_NONE:
            std::cout<<"[CCharacterControllerEnemy::Update]"<<"state -> AI_STATE_NONE"<<std::endl;
            m_pChassis->StartExhaustEmitt(false);
            m_pChassis->StartDirtEmitt(false);
            break;
        case E_AI_STATE_STAND:
        {
            m_pChassis->StartExhaustEmitt(false);
            m_pChassis->StartDirtEmitt(false);
            std::cout<<"[CCharacterControllerEnemy::Update]"<<"state -> E_AI_STATE_STAND"<<std::endl;
        }
            break;
        case E_AI_STATE_MOVE:
        {
            float fMoveSpeed = GameSDBStorage::Instance()->Get_UserMoveSpeed(m_eFullSetType);
            glm::vec2 vPoint_01 = glm::vec2(m_vPosition.x, m_vPosition.z);
            glm::vec2 vPoint_02 = glm::vec2(m_vMovePoint.x, m_vMovePoint.z);
            
            if(glm::distance(vPoint_01, vPoint_02) < 1.0f)
            {
                m_eState = E_AI_STATE_NONE;
                break;
            }
            
            float fAngleFromSeekerToTarget = CMathHelper::Instance()->Get_RotationBetweenPoints(m_vMovePoint, m_vPosition) + 180.0f;
            //glm::degrees(CMathHelper::Instance()->Get_RotationBetweenPointsDot(vPoint_01, vPoint_02));
            fAngleFromSeekerToTarget = CMathHelper::Instance()->Get_WrapAngle(fAngleFromSeekerToTarget, 0.0f, 360.0f);
            if(m_eStreerMode == E_AI_STEER_MODE_LEFT)
            {
                if(fabsf(fAngleFromSeekerToTarget - m_vRotation.y) > 45.0f)
                {
                    m_pNavigationHelper->MoveLeft();
                    m_pTrack->Move_LeftTrack(-fTrackTexCoordOffsetMoveFactor);
                    m_pTrack->Move_RightTrack(fTrackTexCoordOffsetMoveFactor);
                }
                else
                {
                    if(fabs(fAngleFromSeekerToTarget - m_vRotation.y) > 1.0f)
                    {
                        m_pNavigationHelper->MoveLeft();
                    }
                    //MoveForward();
                    if(m_pBox2dBody != NULL)
                    {
                        b2Vec2 vForce = b2Vec2(0.0f, 0.0f);
                        vForce.x += sinf(glm::radians(m_vRotation.y)) * fMoveSpeed;
                        vForce.y += cosf(glm::radians(m_vRotation.y)) * fMoveSpeed;
                        m_pBox2dBody->SetAwake(true);
                        m_pBox2dBody->SetLinearVelocity(vForce);
                    }
                    m_pTrack->Move_LeftTrack(-fTrackTexCoordOffsetMoveFactor);
                    m_pTrack->Move_RightTrack(-fTrackTexCoordOffsetMoveFactor);
                }
            }
            else if(m_eStreerMode == E_AI_STEER_MODE_RIGHT)
            {
                if(fabsf(fAngleFromSeekerToTarget - m_vRotation.y) > 45.0f)
                {
                    m_pNavigationHelper->MoveRight();
                    m_pTrack->Move_LeftTrack(-fTrackTexCoordOffsetMoveFactor);
                    m_pTrack->Move_RightTrack(fTrackTexCoordOffsetMoveFactor);
                }
                else
                {
                    if(fabs(fAngleFromSeekerToTarget - m_vRotation.y) > 1.0f)
                    {
                        m_pNavigationHelper->MoveRight();
                    }
                    //MoveForward();
                    if(m_pBox2dBody != NULL)
                    {
                        b2Vec2 vForce = b2Vec2(0.0f, 0.0f);
                        vForce.x += sinf(glm::radians(m_vRotation.y)) * fMoveSpeed;
                        vForce.y += cosf(glm::radians(m_vRotation.y)) * fMoveSpeed;
                        m_pBox2dBody->SetAwake(true);
                        m_pBox2dBody->SetLinearVelocity(vForce);
                    }
                    m_pTrack->Move_LeftTrack(-fTrackTexCoordOffsetMoveFactor);
                    m_pTrack->Move_RightTrack(-fTrackTexCoordOffsetMoveFactor);
                }
            }
            m_pChassis->StartExhaustEmitt(true);
            m_pChassis->StartDirtEmitt(true);
        }
            break;
        default:
            break;
    }
    
    if(m_pBox2dBody != NULL)
    {
        m_pBox2dBody->SetTransform(m_pBox2dBody->GetPosition(), glm::radians(m_vRotation.y));
    }
    
    m_pTrack->Update();
    m_pTower->Update();
    m_pChassis->Update();
    
    //Shoot();
    
    glm::vec3 vTargetPoint;
    if(m_pTarget != NULL)
    {
        vTargetPoint = m_pTarget->Get_Position();
    }
    else
    {
        vTargetPoint = m_vMovePoint;
    }
    
    //m_fTowerRotationY = CMathHelper::Instance()->Get_RotationBetweenPoints(m_vPosition, vTargetPoint);
    m_vRotation.y = CMathHelper::Instance()->Get_RotationBetweenPoints(m_vPosition, vTargetPoint);
    
    /*glm::vec3 vStepPosition = m_vPosition;
    vStepPosition.x += sinf(glm::radians(m_vRotation.y)) * m_fMoveSpeed;
    vStepPosition.z += cosf(glm::radians(m_vRotation.y)) * m_fMoveSpeed;
    m_fTowerRotationY = CMathHelper::Instance()->Get_RotationBetweenPointsDot(m_vPosition - vStepPosition, m_vPosition - vTargetPoint);
    */
    Set_Position(m_vPosition);
    _SmoothRotation();
    Set_Rotation(m_vRotation);
}
void CCharacterControllerPlayer::Update(void)
{   
    float fTrackTexCoordOffsetMoveFactor  = 0.2f;
    float fTrackTexCoordOffsetSteerFactor = 0.1f;
    
    ICamera* pCamera = CSceneMgr::Instance()->Get_Camera();
    switch (m_eMoveState)
    {
        case ICharacterController::E_CHARACTER_CONTROLLER_MOVE_STATE_NONE:
            if(pCamera->Get_FovY() > k_CAMERA_FOV_Y_STATE_NONE)
            {
                pCamera->Set_FovY(pCamera->Get_FovY() - k_CAMERA_FOV_Y_DELTA_STATE_NONE);
            }
            m_pChassis->StartExhaustEmitt(false);
            m_pChassis->StartDirtEmitt(false);
            break;
        case ICharacterController::E_CHARACTER_CONTROLLER_MOVE_STATE_FORWARD:
            
            //MoveForward();
            m_pTrack->Move_LeftTrack(-fTrackTexCoordOffsetMoveFactor);
            m_pTrack->Move_RightTrack(-fTrackTexCoordOffsetMoveFactor);
            
            if(pCamera->Get_FovY() < k_CAMERA_FOV_Y_STATE_FORWARD)
            {
                pCamera->Set_FovY(pCamera->Get_FovY() + k_CAMERA_FOV_Y_DELTA_STATE_FORWARD);
            }
            m_pChassis->StartExhaustEmitt(true);
            m_pChassis->StartDirtEmitt(true);
            break;
        case ICharacterController::E_CHARACTER_CONTROLLER_MOVE_STATE_BACKWARD:
            
            //MoveBackward();
            m_pTrack->Move_LeftTrack(fTrackTexCoordOffsetMoveFactor);
            m_pTrack->Move_RightTrack(fTrackTexCoordOffsetMoveFactor);
            
            if(pCamera->Get_FovY() > k_CAMERA_FOV_Y_STATE_BACKWARD)
            {
                pCamera->Set_FovY(pCamera->Get_FovY() - k_CAMERA_FOV_Y_DELTA_STATE_BACKWARD);
            }
            m_pChassis->StartExhaustEmitt(true);
            m_pChassis->StartDirtEmitt(true);
            break;
        default:
            break;
    }
    
    switch (m_eSteerState)
    {
        case ICharacterController::E_CHARACTER_CONTROLLER_STEER_STATE_NONE:
            
            break;
        case ICharacterController::E_CHARACTER_CONTROLLER_STEER_STATE_LEFT:
            m_pNavigationHelper->SteerRight();
            m_pTrack->Move_LeftTrack(-fTrackTexCoordOffsetMoveFactor);
            m_pTrack->Move_RightTrack(fTrackTexCoordOffsetSteerFactor);
            m_pChassis->StartExhaustEmitt(true);
            m_pChassis->StartDirtEmitt(true);
            break;
        case ICharacterController::E_CHARACTER_CONTROLLER_STEER_STATE_RIGHT:
            m_pNavigationHelper->SteerLeft();
            m_pTrack->Move_LeftTrack(fTrackTexCoordOffsetSteerFactor);
            m_pTrack->Move_RightTrack(-fTrackTexCoordOffsetMoveFactor);
            m_pChassis->StartExhaustEmitt(true);
            m_pChassis->StartDirtEmitt(true);
            break;
        default:
            break;
    }
    
    /*if(fabsf(CSettings::g_fAccellerometer_Y) > 0.1f && fabsf(m_fTowerRotationY + CSettings::g_fAccellerometer_Y * m_fTowerSteerSpeed) < 60.0f)
    {
        m_fTowerRotationY += CSettings::g_fAccellerometer_Y * m_fTowerSteerSpeed;
    }
    
    std::cout<<"[ BODY ANGLE ] :"<<_Get_WrapAngle(m_vRotation.y, 0.0f, 360.0f)<<std::endl;
    std::cout<<"[ TOWER ANGLE ] :"<<_Get_WrapAngle(m_fTowerRotationY + m_vRotation.y, 0.0f, 360.0f)<<std::endl;
   
    if(fabsf(_Get_WrapAngle(m_vRotation.y, 0.0f, 360.0f) - _Get_WrapAngle(m_fTowerRotationY + m_vRotation.y, 0.0f, 360.0f)) > 60.0f)
    {
        if(_Get_WrapAngle(m_vRotation.y, 0.0f, 360.0f) < _Get_WrapAngle((m_fTowerRotationY + m_vRotation.y), 0.0f, 360.0f))
        {
            m_fTowerRotationY -= m_fSteerSpeed;
            SteerLeft();
        }
        else
        {
            m_fTowerRotationY += m_fSteerSpeed;
            SteerRight();
        }
    }*/
    
    float fTowerSteerSpeed = GameSDBStorage::Instance()->Get_UserSteerSpeed(m_eFullSetType);
    switch (m_eSteerTowerState)
    {
        case ICharacterController::E_CHARACTER_CONTROLLER_STEER_STATE_TOWER_NONE:
            
            break;
        case ICharacterController::E_CHARACTER_CONTROLLER_STEER_STATE_TOWER_RIGHT:
        {
            if((m_fTowerRotationY + fTowerSteerSpeed) > 60.0f)
            {
                m_pNavigationHelper->MoveLeft();
            }
            else
            {
                m_fTowerRotationY += fTowerSteerSpeed;
            }
        }
            break;
        case ICharacterController::E_CHARACTER_CONTROLLER_STEER_STATE_TOWER_LEFT:
        {
            if((m_fTowerRotationY - fTowerSteerSpeed) < -60.0f)
            {
                m_pNavigationHelper->MoveRight();
            }
            else
            {
                m_fTowerRotationY -= fTowerSteerSpeed;
            }
        }
            break;
            
        default:
            break;
    }
    
    float fMoveSpeed = GameSDBStorage::Instance()->Get_UserMoveSpeed(m_eFullSetType);

    if(m_pBox2dBody != NULL)
    {
        b2Vec2 vForce = b2Vec2(0.0f, 0.0f);
        switch (m_eMoveState)
        {
            case 1:
            {
                vForce.x += sinf(glm::radians(m_vRotation.y)) * fMoveSpeed;
                vForce.y += cosf(glm::radians(m_vRotation.y)) * fMoveSpeed;
            }
                break;
            case 2:
            {
                vForce.x -= sinf(glm::radians(m_vRotation.y)) * fMoveSpeed;
                vForce.y -= cosf(glm::radians(m_vRotation.y)) * fMoveSpeed;
            }
                break;
            default:
                break;
        }
        
        m_pBox2dBody->SetAwake(true);
        m_pBox2dBody->SetLinearVelocity(vForce);
    }
    
    if(m_pBox2dBody != NULL)
    {
        m_pBox2dBody->SetTransform(m_pBox2dBody->GetPosition(), glm::radians(m_vRotation.y));
    }
    
    /*if(m_pBox2dBody != NULL)
    {
        _UpdateFriction();
        _UpdateDrive(static_cast<int>(m_eMoveState));
        _UpdateTurn(static_cast<int>(m_eSteerState));
    }*/
    
    glm::vec3 vTargetDecalPosition = m_pTargetDecal->Get_Position();
    vTargetDecalPosition.x = m_vPosition.x + sin(glm::radians(m_fTowerRotationY + m_vRotation.y)) * 6.0f;
    vTargetDecalPosition.z = m_vPosition.z + cos(-glm::radians(m_fTowerRotationY + m_vRotation.y)) * 6.0f;
    m_pTargetDecal->Set_Position(vTargetDecalPosition);
    
    m_pTrack->Update();
    m_pTower->Update();
    m_pChassis->Update();

    Set_Position(m_vPosition);
    _SmoothRotation();
    Set_Rotation(m_vRotation);
}
Example #8
0
void CBuilding::OnBox2dRotationChanged(float _fAngleY)
{
    Set_Rotation(m_vRotation);
}