Exemplo n.º 1
0
bool StateTutorial::handleInput(const sf::Event& event)
{
	if(event.type == sf::Event::MouseButtonPressed)
	{
		switch(event.mouseButton.button)
		{
		case sf::Mouse::Left:
		{
			++index_;

			if(index_ < instructionDatas.size())
				updateInstruction();

			else
				requestStackPop();

			break;
		}
		case sf::Mouse::Right:
		{
			index_ = (index_ != 0) ? index_ - 1 : index_;

			updateInstruction();

			break;
		}
		default:
			break;
		}

		return false;
	}

	return true;
}
Exemplo n.º 2
0
StateTutorial::StateTutorial(StateStack& stack, Context context)
	: State(stack, context)
	, index_(0)
	, instruction_()
	, arrow_()
{
	instruction_.setFont(context.fonts->get(FontID::ForcedSquare));
	instruction_.setColor(sf::Color::Black);
	instruction_.setCharacterSize(25);

	context.textures->load(TextureID::Arrow, "./media/sprites/Arrow.png");
	arrow_.setTexture(context.textures->get(TextureID::Arrow));
	arrow_.setColor(sf::Color::Black);

	updateInstruction();
}
Exemplo n.º 3
0
void Changer::repeater(RepeaterParams* params) {
    int index = params->bacterium_index;
    int total_commands = params->commands;
    while (!endOfMove(index) &&
           (completed_commands_[index] < total_commands)) {
        remainingActionsDecrement(
            params->remaining_commands_vect,
            index
        );
        completed_commands_[index]++;
        LogicalMethod method = params->logic_function;
        (logical_changer_.*method)(index);
    }
    if (model_->isAlive(team_, index)) {
        if (completed_commands_[index] == (total_commands)) {
            updateInstruction(index);
        }
    }
}
Exemplo n.º 4
0
void Changer::jl_impl(
    const Abstract::Params* params,
    int bacterium_index
) {
    int mass = model_->getMass(team_, bacterium_index);
    if (mass < params->p1) {
        int instruction = params->p2;
        if ((instruction >= 0) && instruction < instructions_) {
            model_->setInstruction(team_, bacterium_index, instruction);
        } else {
            throw Exception("Invalid instruction in jl command.");
        }
    } else {
        updateInstruction(bacterium_index);
    }
    remainingActionsDecrement(
        remaining_pseudo_actions_,
        bacterium_index
    );
    penalize(bacterium_index);
}
Exemplo n.º 5
0
void Changer::je_impl(
    const Abstract::Params* params,
    int bacterium_index
) {
    Abstract::Point en;
    bool enemy = logical_changer_.roundEnemySearch(bacterium_index, &en);
    if (enemy) {
        int instruction = params->p1;
        if ((instruction >= 0) && instruction < instructions_) {
            model_->setInstruction(team_, bacterium_index, instruction);
        } else {
            throw Exception("Invalid instruction in je command.");
        }
    } else {
        updateInstruction(bacterium_index);
    }
    remainingActionsDecrement(
        remaining_pseudo_actions_,
        bacterium_index
    );
    penalize(bacterium_index);
}