FallingCube(ci::JsonTree& params, ci::TimelineRef timeline, Event<EventParam>& event, const ci::Vec3i& entry_pos, const float interval, const float delay) noexcept : params_(params), event_(event), active_(true), id_(getUniqueNumber()), color_(Json::getColor<float>(params["game.falling.color"])), block_position_(entry_pos), rotation_(ci::Quatf::identity()), animation_timeline_(ci::Timeline::create()), on_stage_(false), status_(Status::IDLE), fall_ease_(params["game.falling.fall_ease"].getValue<std::string>()), fall_duration_(params["game.falling.fall_duration"].getValue<float>()), fall_y_(params["game.falling.fall_y"].getValue<float>()), interval_(interval), up_ease_(params["game.falling.up_ease"].getValue<std::string>()), up_duration_(params["game.falling.up_duration"].getValue<float>()), up_y_(params["game.falling.up_y"].getValue<float>()), down_ease_(params["game.falling.down_ease"].getValue<std::string>()), down_duration_(params["game.falling.down_duration"].getValue<float>()), quake_duration_(params["game.falling.quake_duration"].getValue<float>()) { DOUT << "FallingCube()" << std::endl; auto current_time = timeline->getCurrentTime(); animation_timeline_->setStartTime(current_time); timeline->apply(animation_timeline_); position_ = ci::Vec3f(block_position_); // block_positionが同じ高さなら、StageCubeの上に乗るように位置を調整 position_().y += 1.0f; // 登場演出 auto entry_y = Json::getVec2<float>(params["game.falling.entry_y"]); float y = ci::randFloat(entry_y.x, entry_y.y); ci::Vec3f start_value(position() + ci::Vec3f(0, y, 0)); auto options = animation_timeline_->apply(&position_, start_value, position_(), params["game.falling.entry_duration"].getValue<float>(), getEaseFunc(params["game.falling.entry_ease"].getValue<std::string>())); options.finishFn([this, delay]() noexcept { on_stage_ = true; EventParam params = { { "id", id_ }, { "block_pos", block_position_ }, }; event_.signal("falling-on-stage", params); startUpEase(delay); }); }
void addTransConnector( SLSF::TransConnector transConnector ) { _internalTransConnectorMap.insert( std::make_pair( transConnector, TransConnectorData( getUniqueNumber() ) ) ); }
ItemCube(ci::JsonTree& params, ci::TimelineRef timeline, Event<EventParam>& event, const ci::Vec3i& entry_pos) noexcept : params_(params), event_(event), active_(true), id_(getUniqueNumber()), color_(Json::getHsvColor(params["game.item.color"])), offset_(ci::Vec3f::zero()), block_position_(entry_pos), block_position_new_(block_position_), rotation_(ci::Vec3f::zero()), rotation_speed_(Json::getVec3<float>(params["game.item.rotation_speed"])), rotation_speed_rate_(0), scale_(ci::Vec3f::one()), on_stage_(false), getatable_(true), fall_ease_(params["game.item.fall_ease"].getValue<std::string>()), fall_duration_(params["game.item.fall_duration"].getValue<float>()), fall_y_(params["game.item.fall_y"].getValue<float>()), move_ease_(params["game.stage.move_ease"].getValue<std::string>()), move_duration_(params["game.stage.move_duration"].getValue<float>()), move_delay_(params["game.stage.move_delay"].getValue<float>()), shadow_ease_(params["game.item.shadow_ease"].getValue<std::string>()), shadow_duration_(params["game.item.shadow_duration"].getValue<float>()), shadow_alpha_(0.0f), animation_timeline_(ci::Timeline::create()) { DOUT << "ItemCube()" << std::endl; auto current_time = timeline->getCurrentTime(); animation_timeline_->setStartTime(current_time); timeline->apply(animation_timeline_); position_ = ci::Vec3f(block_position_); // block_positionが同じ高さなら、StageCubeの上に乗るように位置を調整 position_().y += 1.0f; // 登場演出 auto entry_y = Json::getVec2<float>(params["game.item.entry_y"]); float y = ci::randFloat(entry_y.x, entry_y.y); ci::Vec3f start_value(position() + ci::Vec3f(0, y, 0)); float duration = params["game.item.entry_duration"].getValue<float>(); auto options = animation_timeline_->apply(&position_, start_value, position_(), duration, getEaseFunc(params["game.item.entry_ease"].getValue<std::string>())); options.finishFn([this]() noexcept { on_stage_ = true; startTween("idle_tween"); startShadowAlphaTween(1.0f); EventParam params = { { "block_pos", block_position_ }, }; event_.signal("item-on-stage", params); }); setFloatTween(*animation_timeline_, rotation_speed_rate_, params["game.item.entry_rotate_speed"], true); }