void InputRemapperSystem::touchDown(float x, float y)
{
    TimeSystem* pTime = getSystem<TimeSystem>();
    const float time = pTime->getGameTime();

    Vector2 motion(x, y);
    int xAxis = GameButtons::BUTTON_leftAxisX;
    int yAxis = GameButtons::BUTTON_leftAxisY;
    if (x <= getScreenWidth() / 2)
    {
        motion -= getLeftThumbStickCenter();
    }
    else
    {
        motion -= getRightThumbStickCenter();
        xAxis = GameButtons::BUTTON_rightAxisX;
        yAxis = GameButtons::BUTTON_rightAxisY;
    }

    motion[0] = Clamp(motion[0], -getThumbStickRadius(), getThumbStickRadius());
    motion[1] = Clamp(motion[1], -getThumbStickRadius(), getThumbStickRadius());


    motion /= getThumbStickRadius();

    mButtons[xAxis]->updateDeflection(motion[0], time);
    mButtons[yAxis]->updateDeflection(motion[1], time);
}
Пример #2
0
void LifetimeComponent::update(const float timeDelta, GameObject* pParentObject)
{
	bool timeToDie = false;
	
	if (pParentObject->getRuntimeData()->exists("deathTime"))
	{
		TimeSystem* time = getSystem<TimeSystem>();
		float currentTime = time->getGameTime();
		if (currentTime  > pParentObject->getRuntimeData()->getFloat("deathTime"))
		{
			timeToDie = true;
		}
	}
	
	if (timeToDie)
	{
		pParentObject->getRuntimeData()->insertInt(0, "visible");
		
		GameObjectPoolSystem* poolSystem = getSystem<GameObjectPoolSystem>();
		if (poolSystem && poolSystem->isPooledObject(pParentObject))
		{
			poolSystem->release(pParentObject);
		}
		
		GameObjectSystem* objectManager = getSystem<GameObjectSystem>();
		if (objectManager)
		{
			objectManager->remove(pParentObject);
		}
	}

}
void InputRemapperSystem::rollDown(float x, float y)
{
    TimeSystem* pTime = getSystem<TimeSystem>();
    const float time = pTime->getGameTime();
    mButtons[GameButtons::BUTTON_rightAxisX]->updateDeflection(x, time);
    mButtons[GameButtons::BUTTON_rightAxisY]->updateDeflection(y, time);
    mLastRollTime = time;
}
void InputRemapperSystem::update(const float timeDelta, const UpdatePhase phase)
{
    TimeSystem* pTime = getSystem<TimeSystem>();
    const float time = pTime->getGameTime();

    if (mLastRollTime > 0.0f && time - mLastRollTime > timeDelta)
    {
        mButtons[GameButtons::BUTTON_rightAxisX]->release(time);
        mButtons[GameButtons::BUTTON_rightAxisY]->release(time);
    }
}
void InputRemapperSystem::touchUp(float x, float y)
{
    TimeSystem* pTime = getSystem<TimeSystem>();
    const float time = pTime->getGameTime();

    if (x <= getScreenWidth() / 2)
    {
        mButtons[GameButtons::BUTTON_leftAxisX]->release(time);
        mButtons[GameButtons::BUTTON_leftAxisY]->release(time);
    }
    else
    {
        mButtons[GameButtons::BUTTON_rightAxisX]->release(time);
        mButtons[GameButtons::BUTTON_rightAxisY]->release(time);
    }

}