コード例 #1
0
//------------------------------------------------------------------------
bool CVehicleSeatActionRotateTurret::Init(IVehicle* pVehicle, IVehicleSeat* pSeat, const CVehicleParams &table)
{
	m_pUserEntity = NULL;
	m_aimGoal.zero();
	m_aimGoalPriority = 0;

	m_rotTestHelpers[0] = NULL;
	m_rotTestHelpers[1] = NULL;
	m_rotTestRadius     = 0.f;

	m_pVehicle = static_cast<CVehicle*>(pVehicle);
	m_pSeat    = static_cast<CVehicleSeat*>(pSeat);
	assert(m_pSeat);

	CVehicleParams rotationTable = table.findChild("RotateTurret");
	if (!rotationTable)
		return false;

	// first the actual rotation setups
	if (CVehicleParams pitchTable = rotationTable.findChild("Pitch"))
	{
		InitRotation(pVehicle, pitchTable, eVTRT_Pitch);
		InitRotationSounds(pitchTable, eVTRT_Pitch);
	}
	if (CVehicleParams yawTable = rotationTable.findChild("Yaw"))
	{
		InitRotation(pVehicle, yawTable, eVTRT_Yaw);
		InitRotationSounds(yawTable, eVTRT_Yaw);
	}

	// then the (optional) rotation testing
	if (CVehicleParams rotationTestTable = rotationTable.findChild("RotationTest"))
	{
		if (rotationTestTable.haveAttr("helper1"))
		{
			const char* helpName = rotationTestTable.getAttr("helper1");
			if (IVehicleHelper* pHelper = m_pVehicle->GetHelper(helpName))
				m_rotTestHelpers[0] = pHelper;
		}
		if (rotationTestTable.haveAttr("helper2"))
		{
			const char* helpName = rotationTestTable.getAttr("helper2");
			if (IVehicleHelper* pHelper = m_pVehicle->GetHelper(helpName))
				m_rotTestHelpers[1] = pHelper;
		}

		rotationTestTable.getAttr("radius", m_rotTestRadius);
	}

	return true;
}
コード例 #2
0
ファイル: Weapon.c プロジェクト: Gamerlios123/GAM150_Project
int WeaponSysFire(List *list, GameInstance *instance)
{
    short int i;
    Vector2D weapvel;
    Vector2D weappos;
    float proj_vel;
    int proj_type;
    float proj_lifetime;
    float degrees = CONVERT;     //in degrees
    float degrees_adjust = 0.0f;
    int proj_num;

    // Add check player weapon type statement
    /////////////////////////////////////////
    switch (instance->WeaponType_)
    {
    case PLAYER_BASIC:
        proj_vel = SHIP_BUL_VELOCITY;
        proj_type = Player_Bullet;
        proj_lifetime = BUL_LIFETIME;
        degrees *= 0.0;
        proj_num = 1;
        break;
    case PLAYER_SECOND:
        proj_vel = SHIP_BUL_VELOCITY;
        proj_type = Enemy_Bullet;
        proj_lifetime = BUL_LIFETIME;
        degrees *= 20.0f;
        degrees_adjust = -20.0f;
        proj_num = 3;
        break;
    case ENEMY_BASIC:
        proj_vel = ENEMY_BUL_VELOCITY;
        proj_type = Enemy_Bullet;
        proj_lifetime = BUL_LIFETIME; //Temporary value, replace with whatever is best
        degrees *= 0.0;
        proj_num = 1;
        break;
    default:
        return 0;
    }

    if (instance->reload_ != NO_RELOAD)
    {
        if (instance->reload_counter > instance->reload_)
        {
            for (i = 0; i < proj_num; ++i)
            {
                Vector2DSet(&weapvel, proj_vel * sinf(degrees), proj_vel * cosf(degrees));
                Vector2DSet(&weappos, instance->position_.x, instance->position_.y);

                Create_Instance(list, proj_type);

                InitScale(1.0f, 2.0f);
                InitPosition(&weappos);
                InitVelocity(&weapvel);
                InitRotation(-degrees);
                InitLifetime(proj_lifetime);

                //FMOD_System_PlaySound(sys, sounds[0], 0, FALSE, &channel[0]);

                instance->reload_counter = 0;
                degrees += degrees_adjust * CONVERT;
            }
        }
        instance->reload_counter++;
    }
    return 1;
}