예제 #1
0
void Game_Vehicle::LoadSystemSettings() {
	switch (type) {
		case None:
			break;
		case Boat:
			SetSpriteName(Data::system.boat_name);
			SetSpriteIndex(Data::system.boat_index);
			bgm = Data::system.boat_music;
			SetMapId(Data::treemap.start.boat_map_id);
			SetX(Data::treemap.start.boat_x);
			SetY(Data::treemap.start.boat_y);
			break;
		case Ship:
			SetSpriteName(Data::system.ship_name);
			SetSpriteIndex(Data::system.ship_index);
			bgm = Data::system.ship_music;
			SetMapId(Data::treemap.start.ship_map_id);
			SetX(Data::treemap.start.ship_x);
			SetY(Data::treemap.start.ship_y);
			break;
		case Airship:
			SetSpriteName(Data::system.airship_name);
			SetSpriteIndex(Data::system.airship_index);
			bgm = Data::system.airship_music;
			SetMapId(Data::treemap.start.airship_map_id);
			SetX(Data::treemap.start.airship_x);
			SetY(Data::treemap.start.airship_y);
			break;
	}
}
예제 #2
0
void Game_Event::Setup(RPG::EventPage* new_page) {
	bool from_null = page == NULL;
	page = new_page;

	// Free resources if needed
	if (interpreter) {
		// If the new page is null and the interpreter is running, it should
		// carry on executing its command list during this frame
		if (page)
			interpreter->Clear();
		Game_Map::ReserveInterpreterDeletion(interpreter);
		interpreter.reset();
	}

	if (page == NULL) {
		tile_id = 0;
		SetSpriteName("");
		SetSpriteIndex(0);
		SetDirection(RPG::EventPage::Direction_down);
		//move_type = 0;
		trigger = -1;
		list.clear();
		return;
	}
	SetSpriteName(page->character_name);
	SetSpriteIndex(page->character_index);

	tile_id = page->character_name.empty() ? page->character_index : 0;

	if (original_pattern != page->character_pattern) {
		pattern = page->character_pattern;
		original_pattern = pattern;
	}

	move_type = page->move_type;
	SetMoveSpeed(page->move_speed);
	SetMoveFrequency(page->move_frequency);
	max_stop_count = (GetMoveFrequency() > 7) ? 0 : (int)pow(2.0, 8 - GetMoveFrequency());
	original_move_frequency = page->move_frequency;
	original_move_route = page->move_route;
	SetOriginalMoveRouteIndex(0);

	bool last_direction_fixed = IsDirectionFixed() || IsFacingLocked();
	animation_type = page->animation_type;

	if (from_null || !(last_direction_fixed || IsMoving()) || IsDirectionFixed())
		SetSpriteDirection(page->character_direction);
	if (!IsMoving())
		SetDirection(page->character_direction);

	SetOpacity(page->translucent ? 160 : 255);
	SetLayer(page->layer);
	data.overlap_forbidden = page->overlap_forbidden;
	trigger = page->trigger;
	list = page->event_commands;

	if (trigger == RPG::EventPage::Trigger_parallel) {
		interpreter.reset(new Game_Interpreter_Map());
	}
}
예제 #3
0
void RandomizeSpriteSystem::OnActorEvent(::ActorEvent const& Evt)
{
    if (Evt.mState != ActorEvent::Added)
    {
        return;
    }
    auto renderableC( Evt.mActor->Get<IRenderableComponent>() );
    if (!renderableC.IsValid())
    {
        return;
    }
    int32_t ind = 0;
    if (!renderableC->GetRandomSprites().empty())
    {
        ind = GetRandomIndex( renderableC->GetRandomSprites() );
    }
    renderableC->SetSpriteIndex( ind );
    
    auto borderC( Evt.mActor->Get<IBorderComponent>() );
    if (!borderC.IsValid())
    {
        return;
    }
    ind = 0;
    if (!borderC->GetRandomSprites().empty())
    {
        ind = GetRandomIndex( borderC->GetRandomSprites() );
    }
    borderC->SetSpriteIndex( ind );
}
예제 #4
0
void Game_Event::Setup(RPG::EventPage* new_page) {
	page = new_page;

	// Free resources if needed
	if (interpreter) {
		interpreter->Clear();
		Game_Map::ReserveInterpreterDeletion(interpreter);
		interpreter.reset();
	}

	if (page == NULL) {
		tile_id = 0;
		SetSpriteName("");
		SetSpriteIndex(0);
		SetDirection(RPG::EventPage::Direction_down);
		//move_type = 0;
		trigger = -1;
		list.clear();
		return;
	}
	SetSpriteName(page->character_name);
	SetSpriteIndex(page->character_index);

	tile_id = page->character_name.empty() ? page->character_index : 0;

	if (GetDirection() != page->character_direction) {
		SetDirection(page->character_direction);
		SetSpriteDirection(page->character_direction);
	}

	if (original_pattern != page->character_pattern) {
		pattern = page->character_pattern;
		original_pattern = pattern;
	}
	
	move_type = page->move_type;
	SetMoveSpeed(page->move_speed);
	SetMoveFrequency(page->move_frequency);
	max_stop_count = (GetMoveFrequency() > 7) ? 0 : pow(2.0, 8 - GetMoveFrequency());
	original_move_frequency = page->move_frequency;
	original_move_route = page->move_route;
	SetOriginalMoveRouteIndex(0);
	animation_type = page->animation_type;
	SetOpacity(page->translucent ? 160 : 255);

	SetLayer(page->layer);
	trigger = page->trigger;
	list = page->event_commands;

	if (trigger == RPG::EventPage::Trigger_parallel) {
		interpreter.reset(new Game_Interpreter_Map());
	}
	CheckEventTriggerAuto();
}
예제 #5
0
void Game_Event::Setup(RPG::EventPage* new_page) {
	page = new_page;

	if (page == NULL) {
		tile_id = 0;
		SetSpriteName("");
		SetSpriteIndex(0);
		SetDirection(RPG::EventPage::Direction_down);
		//move_type = 0;
		through = true;
		trigger = -1;
		list.clear();
		interpreter.reset();
		return;
	}
	SetSpriteName(page->character_name);
	SetSpriteIndex(page->character_index);

	tile_id = page->character_name.empty() ? page->character_index : 0;

	if (GetDirection() != page->character_direction) {
		SetDirection(page->character_direction);
		SetPrelockDirection(page->character_direction);
	}

	if (original_pattern != page->character_pattern) {
		pattern = page->character_pattern;
		original_pattern = pattern;
	}
	//opacity = page.opacity;
	//opacity = page.translucent ? 192 : 255;
	//blend_type = page.blend_type;
	move_type = page->move_type;
	SetMoveSpeed(page->move_speed);
	SetMoveFrequency(page->move_frequency);
	original_move_route = page->move_route;
	SetOriginalMoveRouteIndex(0);
	animation_type = page->animation_type;

	SetLayer(page->layer);
	trigger = page->trigger;
	list = page->event_commands;
	through = false;

	// Free resources if needed
	interpreter.reset();
	if (trigger == RPG::EventPage::Trigger_parallel) {
		interpreter.reset(new Game_Interpreter_Map());
	}
	CheckEventTriggerAuto();
}
예제 #6
0
void Game_Character::SetGraphic(const std::string& name, int index) {
	if (GetSpriteName() != name || GetSpriteIndex() != index) {
		SetSpriteName(name);
		SetSpriteIndex(index);
		tile_id = 0;
		pattern = RPG::EventPage::Frame_middle;
	}
}
예제 #7
0
void Game_Player::Refresh() {
	Game_Actor* actor;

	if (Main_Data::game_party->GetActors().empty()) {
		SetSpriteName("");
		return;
	}

	actor = Main_Data::game_party->GetActors()[0];

	SetSpriteName(actor->GetSpriteName());
	SetSpriteIndex(actor->GetSpriteIndex());
}
예제 #8
0
void Actor::Update(int delta) {
	//motion
	if (motion.x && motion.y) {
		position += motion * delta * 0.71; //moving diagonally
	}
	else if (motion.x || motion.y) {
		position += motion * delta; //moving in a cardinal direction
	}

	//graphics
	if (motion != 0) {
		if (motion.y > 0) SetSpriteIndex(0);
		else if (motion.y < 0) SetSpriteIndex(1);
		else if (motion.x > 0) SetSpriteIndex(3);
		else if (motion.x < 0) SetSpriteIndex(2);

		//update the frame
		animator.Update();
	}
	else {
		SetSpriteFrame(0);
	}
}
예제 #9
0
void Game_Player::Refresh() {
	Game_Actor* actor;

	if (Main_Data::game_party->GetActors().empty()) {
		SetSpriteName("");
		return;
	}

	actor = Main_Data::game_party->GetActors()[0];

	SetSpriteName(actor->GetSpriteName());
	SetSpriteIndex(actor->GetSpriteIndex());

	if (location.aboard)
		GetVehicle()->SyncWithPlayer();
}
예제 #10
0
void Game_Character::SetGraphic(const std::string& name, int index) {
	SetSpriteName(name);
	SetSpriteIndex(index);
	pattern = RPG::EventPage::Frame_middle;
}