예제 #1
0
void Player::updateInvincibility( int dt )
{
	static int direction = 1;

	if (_invincible)
	{
		if (_invincibilityTimer >= _invincibilityTimerBase)
		{
			setInvincible( false );
		}
		else
		{
			_invincibilityTimer += dt;

			_alphaFlash = _alphaFlash + direction*dt*0.01f;

			if (_alphaFlash <= 0.0f)
			{
				direction = -direction;
				_alphaFlash = 0.0f;
			}
			else
			{
				if (_alphaFlash >= 1.0f)
				{
					direction = -direction;
					_alphaFlash = 1.0f;
				}
			}

			_currentSprite.set_alpha( _alphaFlash );
		}
	}
}
예제 #2
0
void SpeedUpProtect::initBody()
{
	auto s = getContentSize();
	Vec2 vec[7] = 
	{
		Vec2(0,0),
		Vec2(s.width * 0.1, s.height * 0.4),
		Vec2(s.width * 0.26, s.height * 0.72),
		Vec2(s.width * 0.5, s.height),
		Vec2(s.width * 0.74, s.height * 0.72),
		Vec2(s.width * 0.9, s.height * 0.4),
		Vec2(s.width,0),
	};

	PhysicsBody* body = PhysicsBody::createPolygon(vec, 7, PHYSICSBODY_MATERIAL_DEFAULT, Vec2(-s.width*0.5,-s.height*0.5));
	body->setGravityEnable(false);
	body->setRotationEnable(false);
	body->setDynamic(false);
	body->setMass(10000000);
	body->setCategoryBitmask(SELF_SCOPE_CATEGORYBITMASK);
	body->setCollisionBitmask(SELF_SCOPE_COLLISIONBITMASK);
	body->setContactTestBitmask(SELF_SCOPE_CONTACTTESTBITMASK);
	setPhysicsBody(body);
	setInvincible(true);
	m_ContactPro.hurts = -Ene_Plane_Hp_max - 10;
}
void LVL_Player::harm(int _damage)
{
    if(invincible||PGE_Debugger::cheat_pagangod) return;

    //doHarm=true;
    health-=_damage;
    if(health<=0)
    {
        kill(DEAD_killed);
    } else {
        PGE_Audio::playSoundByRole(obj_sound_role::PlayerShrink);
        if(health==2)
            setCharacterSafe(characterID, 2);
        if(health==1)
            setCharacterSafe(characterID, 1);
        setInvincible(true, 3000, true);
    }
}
예제 #4
0
/**
 *  input_ is available only on server or on the local client, not for
 *  remote tanks.
 */
void Tank::frameMove(float dt)
{
    PROFILE(Tank::frameMove);

    setSleeping(false);
    Controllable::frameMove(dt);

    // Weapon firing code is handled on client for local player only
    // to have immediate feedback. Remote players receive weapon
    // feedback by received state.
    bool firing = false;
    if (getLocation() == CL_SERVER_SIDE ||
        (getLocation() == CL_CLIENT_SIDE && isLocallyControlled()))
    {
        firing |= weapon_system_[0]->handleInput(input_.fire1_);
        firing |= weapon_system_[1]->handleInput(input_.fire2_);
        firing |= weapon_system_[2]->handleInput(input_.fire3_);
        firing |= weapon_system_[3]->handleInput(input_.fire4_);
    }

    if (getLocation() != CL_REPLAY_SIM)
    {
        for(unsigned w=0; w < NUM_WEAPON_SLOTS; w++)
        {
            weapon_system_[w]->frameMove(dt);
        }
    }
    
    

    if (is_locally_controlled_ && getLocation() == CL_CLIENT_SIDE)
    {
        frameMoveTurret(dt, true);
    }
    frameMoveTurret(dt, false);

    
    if (is_locally_controlled_ || getLocation() == CL_SERVER_SIDE)
    {
        // remote tanks don't have accurate wheel info, and no extra
        // dampening needed anyway
        handleExtraDampening();
        
        // Don't calc tire physics for uncontrolled objects on client.
        frameMoveTires(dt);
    }

    
    if (location_ == CL_SERVER_SIDE)
    {
        /// heal logic
        if (!firing &&
            params_.get<bool>("tank.heal_skill") &&
            getGlobalLinearVel().length() < s_params.get<float>("server.logic.tank_heal_velocity_threshold") &&
            getOwner() != UNASSIGNED_SYSTEM_ADDRESS)
        {
            startHealing();
        } else
        {
            stopHealing();
        }

        // object is positioned by visual on client side. Avoid redundant
        // positioning
        positionCarriedObject();
        
        if (firing)
        {
            setInvincible(false);
        }
    }
}
예제 #5
0
void ExplisonScreen::initPro()
{
	setInvincible(true);
	m_ContactPro.hurts = -Ene_Plane_Hp_max- 10;
	setUnitId(UnitId::eScreenExplosion);
}